Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit a030887

Browse files
committed
Move Point, NumberTypes to support
1 parent b0f0e6c commit a030887

File tree

4 files changed

+79
-29
lines changed

4 files changed

+79
-29
lines changed

tests/ServiceStack.Text.Tests/CultureInfoTests.cs

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,14 @@
22
using System.Globalization;
33
using System.Threading;
44
using NUnit.Framework;
5+
using ServiceStack.Text.Tests.Support;
56

67
namespace 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

tests/ServiceStack.Text.Tests/ServiceStack.Text.Tests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@
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" />
@@ -187,6 +188,8 @@
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" />
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
}

0 commit comments

Comments
 (0)