Skip to content

Commit a93bd25

Browse files
committed
Converted classic assert to constraint model
1 parent c384561 commit a93bd25

17 files changed

+291
-304
lines changed

src/GeoJSON.Net.Tests/CoordinateReferenceSystem/DefaultCrsTests.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using GeoJSON.Net.Geometry;
44
using Newtonsoft.Json;
55
using NUnit.Framework;
6-
using NUnit.Framework.Legacy;
76

87
namespace GeoJSON.Net.Tests.CoordinateReferenceSystem
98
{
@@ -17,7 +16,7 @@ public void Can_Serialize_Does_Not_Output_Crs_Property()
1716

1817
var json = JsonConvert.SerializeObject(collection);
1918

20-
ClassicAssert.IsTrue(!json.Contains("\"crs\""));
19+
Assert.That(!json.Contains("\"crs\""));
2120
}
2221

2322
[Test]
@@ -27,7 +26,7 @@ public void Can_Deserialize_When_Json_Does_Not_Contain_Crs_Property()
2726

2827
var point = JsonConvert.DeserializeObject<Point>(json);
2928

30-
ClassicAssert.IsNull(point.CRS);
29+
Assert.That(point.CRS, Is.Null);
3130
}
3231

3332
[Test]
@@ -37,8 +36,8 @@ public void Can_Deserialize_CRS_issue_89()
3736

3837
var point = JsonConvert.DeserializeObject<Point>(json);
3938

40-
ClassicAssert.IsNotNull(point.CRS);
41-
ClassicAssert.AreEqual(CRSType.Name, point.CRS.Type);
39+
Assert.That(point.CRS, Is.Not.Null);
40+
Assert.That(point.CRS.Type, Is.EqualTo(CRSType.Name));
4241
}
4342

4443
[Test]
@@ -50,8 +49,8 @@ public void Can_Serialize_CRS_issue_89()
5049

5150
var json = JsonConvert.SerializeObject(point);
5251

53-
ClassicAssert.IsNotNull(json);
54-
ClassicAssert.AreEqual(expected, json);
52+
Assert.That(json, Is.Not.Null);
53+
Assert.That(json, Is.EqualTo(expected));
5554
}
5655

5756
[Test]
@@ -63,8 +62,8 @@ public void Can_Serialize_DefaultCRS_issue_89()
6362

6463
var json = JsonConvert.SerializeObject(point);
6564

66-
ClassicAssert.IsNotNull(json);
67-
ClassicAssert.AreEqual(expected, json);
65+
Assert.That(json, Is.Not.Null);
66+
Assert.That(json, Is.EqualTo(expected));
6867
}
6968
}
7069
}

src/GeoJSON.Net.Tests/CoordinateReferenceSystem/LinkedCRSTests.cs

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using GeoJSON.Net.Geometry;
44
using Newtonsoft.Json;
55
using NUnit.Framework;
6-
using NUnit.Framework.Legacy;
76

87
namespace GeoJSON.Net.Tests.CoordinateReferenceSystem
98
{
@@ -16,16 +15,16 @@ public class LinkedCRSTests : TestBase
1615
public void Has_Correct_Type()
1716
{
1817
var crs = new LinkedCRS(Href);
19-
ClassicAssert.AreEqual(CRSType.Link, crs.Type);
18+
Assert.That(crs.Type, Is.EqualTo(CRSType.Link));
2019
}
2120

2221
[Test]
2322
public void Has_Href_Property_With_Href()
2423
{
2524
var crs = new LinkedCRS(Href);
2625

27-
ClassicAssert.IsTrue(crs.Properties.ContainsKey("href"));
28-
ClassicAssert.AreEqual(Href, crs.Properties["href"]);
26+
Assert.That(crs.Properties.ContainsKey("href"));
27+
Assert.That(crs.Properties["href"], Is.EqualTo(Href));
2928
}
3029

3130
[Test]
@@ -34,8 +33,8 @@ public void Has_Type_Property()
3433
const string type = "ogcwkt";
3534
var crs = new LinkedCRS(Href, type);
3635

37-
ClassicAssert.IsTrue(crs.Properties.ContainsKey("type"));
38-
ClassicAssert.AreEqual(type, crs.Properties["type"]);
36+
Assert.That(crs.Properties.ContainsKey("type"));
37+
Assert.That(crs.Properties["type"], Is.EqualTo(type));
3938
}
4039

4140
[Test]
@@ -54,21 +53,21 @@ public void Can_Deserialize_CRS_issue_101()
5453
var pointWithCRS = JsonConvert.DeserializeObject<Point>(pointJson);
5554
var linkCRS = pointWithCRS.CRS as LinkedCRS;
5655

57-
ClassicAssert.IsNotNull(linkCRS);
58-
ClassicAssert.AreEqual(CRSType.Link, linkCRS.Type);
59-
ClassicAssert.AreEqual(Href, linkCRS.Properties["href"]);
56+
Assert.That(linkCRS, Is.Not.Null);
57+
Assert.That(linkCRS.Type, Is.EqualTo(CRSType.Link));
58+
Assert.That(linkCRS.Properties["href"], Is.EqualTo(Href));
6059
}
6160

6261
[Test]
6362
public void Ctor_Throws_ArgumentNullExpection_When_Href_String_Is_Null()
6463
{
65-
ClassicAssert.Throws<ArgumentNullException>(() => { var crs = new LinkedCRS((string)null); });
64+
Assert.Throws<ArgumentNullException>(() => { var crs = new LinkedCRS((string)null); });
6665
}
6766

6867
[Test]
6968
public void Ctor_Throws_ArgumentNullExpection_When_Href_Uri_Is_Null()
7069
{
71-
ClassicAssert.Throws<ArgumentNullException>(() => { var crs = new LinkedCRS((Uri)null); });
70+
Assert.Throws<ArgumentNullException>(() => { var crs = new LinkedCRS((Uri)null); });
7271
}
7372

7473
[Test]
@@ -85,20 +84,20 @@ public void Ctor_Throws_ArgumentExpection_When_Href_Is_Not_Dereferencable_Uri()
8584
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
8685
#endif
8786

88-
var argumentExpection = ClassicAssert.Throws<ArgumentException>(() => { var crs = new LinkedCRS("http://not-a-valid-<>-url"); });
89-
ClassicAssert.AreEqual(expected, argumentExpection.Message);
87+
var argumentExpection = Assert.Throws<ArgumentException>(() => { var crs = new LinkedCRS("http://not-a-valid-<>-url"); });
88+
Assert.That(argumentExpection.Message, Is.EqualTo(expected));
9089
}
9190

9291
[Test]
9392
public void Ctor_Does_Not_Throw_When_Href_Is_Dereferencable_Uri()
9493
{
95-
ClassicAssert.DoesNotThrow(() => { var crs = new LinkedCRS("data.crs"); });
94+
Assert.DoesNotThrow(() => { var crs = new LinkedCRS("data.crs"); });
9695
}
9796

9897
[Test]
9998
public void Ctor_Throws_ArgumentNullExpection_When_Name_Is_Empty()
10099
{
101-
ClassicAssert.Throws<ArgumentException>(() => { var crs = new LinkedCRS(string.Empty); });
100+
Assert.Throws<ArgumentException>(() => { var crs = new LinkedCRS(string.Empty); });
102101
}
103102

104103
[Test]
@@ -107,30 +106,30 @@ public void Equals_GetHashCode_Contract()
107106
var left = new LinkedCRS(Href);
108107
var right = new LinkedCRS(Href);
109108

110-
ClassicAssert.AreEqual(left, right);
109+
Assert.That(right, Is.EqualTo(left));
111110

112-
ClassicAssert.IsTrue(left == right);
113-
ClassicAssert.IsTrue(right == left);
111+
Assert.That(left == right);
112+
Assert.That(right == left);
114113

115-
ClassicAssert.IsTrue(left.Equals(right));
116-
ClassicAssert.IsTrue(right.Equals(left));
114+
Assert.That(left.Equals(right));
115+
Assert.That(right.Equals(left));
117116

118-
ClassicAssert.IsTrue(left.Equals(left));
119-
ClassicAssert.IsTrue(right.Equals(right));
117+
Assert.That(left.Equals(left));
118+
Assert.That(right.Equals(right));
120119

121-
ClassicAssert.AreEqual(left.GetHashCode(), right.GetHashCode());
120+
Assert.That(right.GetHashCode(), Is.EqualTo(left.GetHashCode()));
122121

123122
right = new LinkedCRS(Href + "?query=null");
124123

125-
ClassicAssert.AreNotEqual(left, right);
124+
Assert.That(right, Is.Not.EqualTo(left));
126125

127-
ClassicAssert.IsFalse(left == right);
128-
ClassicAssert.IsFalse(right == left);
126+
Assert.That(left == right, Is.False);
127+
Assert.That(right == left, Is.False);
129128

130-
ClassicAssert.IsFalse(left.Equals(right));
131-
ClassicAssert.IsFalse(right.Equals(left));
129+
Assert.That(left.Equals(right), Is.False);
130+
Assert.That(right.Equals(left), Is.False);
132131

133-
ClassicAssert.AreNotEqual(left.GetHashCode(), right.GetHashCode());
132+
Assert.That(right.GetHashCode(), Is.Not.EqualTo(left.GetHashCode()));
134133
}
135134
}
136135
}

src/GeoJSON.Net.Tests/CoordinateReferenceSystem/NamedCrsTests.cs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using GeoJSON.Net.Feature;
44
using Newtonsoft.Json;
55
using NUnit.Framework;
6-
using NUnit.Framework.Legacy;
76

87
namespace GeoJSON.Net.Tests.CoordinateReferenceSystem
98
{
@@ -16,7 +15,7 @@ public void Has_Correct_Type()
1615
var name = "EPSG:31370";
1716
var crs = new NamedCRS(name);
1817

19-
ClassicAssert.AreEqual(CRSType.Name, crs.Type);
18+
Assert.That(crs.Type, Is.EqualTo(CRSType.Name));
2019
}
2120

2221
[Test]
@@ -25,8 +24,8 @@ public void Has_Name_Property_With_Name()
2524
var name = "EPSG:31370";
2625
var crs = new NamedCRS(name);
2726

28-
ClassicAssert.IsTrue(crs.Properties.ContainsKey("name"));
29-
ClassicAssert.AreEqual(name, crs.Properties["name"]);
27+
Assert.That(crs.Properties.ContainsKey("name"));
28+
Assert.That(crs.Properties["name"], Is.EqualTo(name));
3029
}
3130

3231
[Test]
@@ -41,13 +40,13 @@ public void Can_Serialize()
4140
[Test]
4241
public void Ctor_Throws_ArgumentNullExpection_When_Name_Is_Null()
4342
{
44-
ClassicAssert.Throws<ArgumentNullException>(() => { var collection = new FeatureCollection() { CRS = new NamedCRS(null) }; });
43+
Assert.Throws<ArgumentNullException>(() => { var collection = new FeatureCollection() { CRS = new NamedCRS(null) }; });
4544
}
4645

4746
[Test]
4847
public void Ctor_Throws_ArgumentNullExpection_When_Name_Is_Empty()
4948
{
50-
ClassicAssert.Throws<ArgumentException>(() => { var collection = new FeatureCollection() { CRS = new NamedCRS(string.Empty) }; });
49+
Assert.Throws<ArgumentException>(() => { var collection = new FeatureCollection() { CRS = new NamedCRS(string.Empty) }; });
5150
}
5251

5352
[Test]
@@ -58,31 +57,31 @@ public void Equals_GetHashCode_Contract()
5857
var left = new NamedCRS(name);
5958
var right = new NamedCRS(name);
6059

61-
ClassicAssert.AreEqual(left, right);
60+
Assert.That(right, Is.EqualTo(left));
6261

63-
ClassicAssert.IsTrue(left == right);
64-
ClassicAssert.IsTrue(right == left);
62+
Assert.That(left == right);
63+
Assert.That(right == left);
6564

66-
ClassicAssert.IsTrue(left.Equals(right));
67-
ClassicAssert.IsTrue(right.Equals(left));
65+
Assert.That(left.Equals(right));
66+
Assert.That(right.Equals(left));
6867

69-
ClassicAssert.IsTrue(left.Equals(left));
70-
ClassicAssert.IsTrue(right.Equals(right));
68+
Assert.That(left.Equals(left));
69+
Assert.That(right.Equals(right));
7170

72-
ClassicAssert.AreEqual(left.GetHashCode(), right.GetHashCode());
71+
Assert.That(right.GetHashCode(), Is.EqualTo(left.GetHashCode()));
7372

7473
name = "EPSG:25832";
7574
right = new NamedCRS(name);
7675

77-
ClassicAssert.AreNotEqual(left, right);
76+
Assert.That(right, Is.Not.EqualTo(left));
7877

79-
ClassicAssert.IsFalse(left == right);
80-
ClassicAssert.IsFalse(right == left);
78+
Assert.That(left == right, Is.False);
79+
Assert.That(right == left, Is.False);
8180

82-
ClassicAssert.IsFalse(left.Equals(right));
83-
ClassicAssert.IsFalse(right.Equals(left));
81+
Assert.That(left.Equals(right), Is.False);
82+
Assert.That(right.Equals(left), Is.False);
8483

85-
ClassicAssert.AreNotEqual(left.GetHashCode(), right.GetHashCode());
84+
Assert.That(right.GetHashCode(), Is.Not.EqualTo(left.GetHashCode()));
8685
}
8786
}
8887
}

src/GeoJSON.Net.Tests/CoordinateReferenceSystem/UnspecifiedCRSTests.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using GeoJSON.Net.Feature;
33
using Newtonsoft.Json;
44
using NUnit.Framework;
5-
using NUnit.Framework.Legacy;
65

76
namespace GeoJSON.Net.Tests.CoordinateReferenceSystem
87
{
@@ -14,7 +13,7 @@ public void Has_Correct_Type()
1413
{
1514
var crs = new UnspecifiedCRS();
1615

17-
ClassicAssert.AreEqual(CRSType.Unspecified, crs.Type);
16+
Assert.That(crs.Type, Is.EqualTo(CRSType.Unspecified));
1817
}
1918

2019
[Test]
@@ -23,7 +22,7 @@ public void Can_Serialize_To_Null()
2322
var collection = new FeatureCollection { CRS = new UnspecifiedCRS() };
2423
var expectedJson = "{\"type\":\"FeatureCollection\",\"crs\":null,\"features\":[] }";
2524
var actualJson = JsonConvert.SerializeObject(collection);
26-
25+
2726
JsonAssert.AreEqual(expectedJson, actualJson);
2827
}
2928

@@ -33,7 +32,7 @@ public void Can_Deserialize_From_Null()
3332
var json = "{\"type\":\"FeatureCollection\",\"crs\":null,\"features\":[] }";
3433
var featureCollection = JsonConvert.DeserializeObject<FeatureCollection>(json);
3534

36-
ClassicAssert.IsInstanceOf<UnspecifiedCRS>(featureCollection.CRS);
35+
Assert.That(featureCollection.CRS, Is.InstanceOf<UnspecifiedCRS>());
3736
}
3837

3938
[Test]
@@ -42,18 +41,18 @@ public void Equals_GetHashCode_Contract()
4241
var left = new UnspecifiedCRS();
4342
var right = new UnspecifiedCRS();
4443

45-
ClassicAssert.AreEqual(left, right);
44+
Assert.That(right, Is.EqualTo(left));
4645

47-
ClassicAssert.IsTrue(left == right);
48-
ClassicAssert.IsTrue(right == left);
46+
Assert.That(left == right);
47+
Assert.That(right == left);
4948

50-
ClassicAssert.IsTrue(left.Equals(right));
51-
ClassicAssert.IsTrue(right.Equals(left));
49+
Assert.That(left.Equals(right));
50+
Assert.That(right.Equals(left));
5251

53-
ClassicAssert.IsTrue(left.Equals(left));
54-
ClassicAssert.IsTrue(right.Equals(right));
52+
Assert.That(left.Equals(left));
53+
Assert.That(right.Equals(right));
5554

56-
ClassicAssert.AreEqual(left.GetHashCode(), right.GetHashCode());
55+
Assert.That(right.GetHashCode(), Is.EqualTo(left.GetHashCode()));
5756
}
5857
}
5958
}

0 commit comments

Comments
 (0)