This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +79
-29
lines changed
tests/ServiceStack.Text.Tests Expand file tree Collapse file tree 4 files changed +79
-29
lines changed Original file line number Diff line number Diff line change 22using System . Globalization ;
33using System . Threading ;
44using NUnit . Framework ;
5+ using ServiceStack . Text . Tests . Support ;
56
67namespace ServiceStack . Text . Tests
78{
8- [ TestFixture ]
9+ [ TestFixture ]
910 public class CultureInfoTests
1011 : TestBase
1112 {
12- public class Point
13- {
14- public double Latitude { get ; set ; }
15- public double Longitude { get ; set ; }
16-
17- public bool Equals ( Point other )
18- {
19- if ( ReferenceEquals ( null , other ) ) return false ;
20- if ( ReferenceEquals ( this , other ) ) return true ;
21- return other . Latitude == Latitude && other . Longitude == Longitude ;
22- }
23-
24- public override bool Equals ( object obj )
25- {
26- if ( ReferenceEquals ( null , obj ) ) return false ;
27- if ( ReferenceEquals ( this , obj ) ) return true ;
28- if ( obj . GetType ( ) != typeof ( Point ) ) return false ;
29- return Equals ( ( Point ) obj ) ;
30- }
31-
32- public override int GetHashCode ( )
33- {
34- unchecked
35- {
36- return ( Latitude . GetHashCode ( ) * 397 ) ^ Longitude . GetHashCode ( ) ;
37- }
38- }
39- }
4013
4114 private CultureInfo previousCulture = CultureInfo . InvariantCulture ;
4215
Original file line number Diff line number Diff line change 177177 </ItemGroup >
178178 <ItemGroup >
179179 <Compile Include =" AutoMappingObjectDictionaryTests.cs" />
180+ <Compile Include =" CustomCultureInfoTests.cs" />
180181 <Compile Include =" EnumerableTests.cs" />
181182 <Compile Include =" AttributeTests.cs" />
182183 <Compile Include =" CsvTypeTests.cs" />
187188 <Compile Include =" JsonTests\OnDeserializationErrorTests.cs" />
188189 <Compile Include =" JsonTests\TypeInfoTests.cs" />
189190 <Compile Include =" PclApiTests.cs" />
191+ <Compile Include =" Support\NumberTypes.cs" />
192+ <Compile Include =" Support\Point.cs" />
190193 <Compile Include =" SerializationDelegatePerformanceTests.cs" />
191194 <Compile Include =" SerializationHookTests.cs" />
192195 <Compile Include =" StaticAccessorTests.cs" />
Original file line number Diff line number Diff line change 1+ namespace ServiceStack . Text . Tests . Support
2+ {
3+ public class NumberTypes
4+ {
5+ public int Int { get ; set ; }
6+ public float Float { get ; set ; }
7+ public double Double { get ; set ; }
8+ public decimal Decimal { get ; set ; }
9+
10+ public NumberTypes ( double num = 0 )
11+ {
12+ Int = ( int ) num ;
13+ Float = ( float ) num ;
14+ Double = num ;
15+ Decimal = ( decimal ) num ;
16+ }
17+
18+ protected bool Equals ( NumberTypes other )
19+ {
20+ return Int == other . Int && Float . Equals ( other . Float ) && Double . Equals ( other . Double ) && Decimal == other . Decimal ;
21+ }
22+
23+ public override bool Equals ( object obj )
24+ {
25+ if ( ReferenceEquals ( null , obj ) ) return false ;
26+ if ( ReferenceEquals ( this , obj ) ) return true ;
27+ if ( obj . GetType ( ) != this . GetType ( ) ) return false ;
28+ return Equals ( ( NumberTypes ) obj ) ;
29+ }
30+
31+ public override int GetHashCode ( )
32+ {
33+ unchecked
34+ {
35+ var hashCode = Int ;
36+ hashCode = ( hashCode * 397 ) ^ Float . GetHashCode ( ) ;
37+ hashCode = ( hashCode * 397 ) ^ Double . GetHashCode ( ) ;
38+ hashCode = ( hashCode * 397 ) ^ Decimal . GetHashCode ( ) ;
39+ return hashCode ;
40+ }
41+ }
42+ }
43+ }
Original file line number Diff line number Diff line change 1+ namespace ServiceStack . Text . Tests . Support
2+ {
3+ public class Point
4+ {
5+ public double Latitude { get ; set ; }
6+ public double Longitude { get ; set ; }
7+
8+ public bool Equals ( Point other )
9+ {
10+ if ( ReferenceEquals ( null , other ) ) return false ;
11+ if ( ReferenceEquals ( this , other ) ) return true ;
12+ return other . Latitude == Latitude && other . Longitude == Longitude ;
13+ }
14+
15+ public override bool Equals ( object obj )
16+ {
17+ if ( ReferenceEquals ( null , obj ) ) return false ;
18+ if ( ReferenceEquals ( this , obj ) ) return true ;
19+ if ( obj . GetType ( ) != typeof ( Point ) ) return false ;
20+ return Equals ( ( Point ) obj ) ;
21+ }
22+
23+ public override int GetHashCode ( )
24+ {
25+ unchecked
26+ {
27+ return ( Latitude . GetHashCode ( ) * 397 ) ^ Longitude . GetHashCode ( ) ;
28+ }
29+ }
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments