Skip to content

Commit

Permalink
update NUnit to 4.1.0
Browse files Browse the repository at this point in the history
* breaking changes in NUnit 4 require many mechnical
  replacements of "Assert." by "ClassicAssert."
  • Loading branch information
janusw committed Jul 8, 2024
1 parent d3582f7 commit c384561
Show file tree
Hide file tree
Showing 17 changed files with 295 additions and 280 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using GeoJSON.Net.Geometry;
using Newtonsoft.Json;
using NUnit.Framework;
using NUnit.Framework.Legacy;

namespace GeoJSON.Net.Tests.CoordinateReferenceSystem
{
Expand All @@ -16,7 +17,7 @@ public void Can_Serialize_Does_Not_Output_Crs_Property()

var json = JsonConvert.SerializeObject(collection);

Assert.IsTrue(!json.Contains("\"crs\""));
ClassicAssert.IsTrue(!json.Contains("\"crs\""));
}

[Test]
Expand All @@ -26,7 +27,7 @@ public void Can_Deserialize_When_Json_Does_Not_Contain_Crs_Property()

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

Assert.IsNull(point.CRS);
ClassicAssert.IsNull(point.CRS);
}

[Test]
Expand All @@ -36,8 +37,8 @@ public void Can_Deserialize_CRS_issue_89()

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

Assert.IsNotNull(point.CRS);
Assert.AreEqual(CRSType.Name, point.CRS.Type);
ClassicAssert.IsNotNull(point.CRS);
ClassicAssert.AreEqual(CRSType.Name, point.CRS.Type);
}

[Test]
Expand All @@ -49,8 +50,8 @@ public void Can_Serialize_CRS_issue_89()

var json = JsonConvert.SerializeObject(point);

Assert.IsNotNull(json);
Assert.AreEqual(expected, json);
ClassicAssert.IsNotNull(json);
ClassicAssert.AreEqual(expected, json);
}

[Test]
Expand All @@ -62,8 +63,8 @@ public void Can_Serialize_DefaultCRS_issue_89()

var json = JsonConvert.SerializeObject(point);

Assert.IsNotNull(json);
Assert.AreEqual(expected, json);
ClassicAssert.IsNotNull(json);
ClassicAssert.AreEqual(expected, json);
}
}
}
57 changes: 29 additions & 28 deletions src/GeoJSON.Net.Tests/CoordinateReferenceSystem/LinkedCRSTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using GeoJSON.Net.Geometry;
using Newtonsoft.Json;
using NUnit.Framework;
using NUnit.Framework.Legacy;

namespace GeoJSON.Net.Tests.CoordinateReferenceSystem
{
Expand All @@ -15,16 +16,16 @@ public class LinkedCRSTests : TestBase
public void Has_Correct_Type()
{
var crs = new LinkedCRS(Href);
Assert.AreEqual(CRSType.Link, crs.Type);
ClassicAssert.AreEqual(CRSType.Link, crs.Type);
}

[Test]
public void Has_Href_Property_With_Href()
{
var crs = new LinkedCRS(Href);

Assert.IsTrue(crs.Properties.ContainsKey("href"));
Assert.AreEqual(Href, crs.Properties["href"]);
ClassicAssert.IsTrue(crs.Properties.ContainsKey("href"));
ClassicAssert.AreEqual(Href, crs.Properties["href"]);
}

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

Assert.IsTrue(crs.Properties.ContainsKey("type"));
Assert.AreEqual(type, crs.Properties["type"]);
ClassicAssert.IsTrue(crs.Properties.ContainsKey("type"));
ClassicAssert.AreEqual(type, crs.Properties["type"]);
}

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

Assert.IsNotNull(linkCRS);
Assert.AreEqual(CRSType.Link, linkCRS.Type);
Assert.AreEqual(Href, linkCRS.Properties["href"]);
ClassicAssert.IsNotNull(linkCRS);
ClassicAssert.AreEqual(CRSType.Link, linkCRS.Type);
ClassicAssert.AreEqual(Href, linkCRS.Properties["href"]);
}

[Test]
public void Ctor_Throws_ArgumentNullExpection_When_Href_String_Is_Null()
{
Assert.Throws<ArgumentNullException>(() => { var crs = new LinkedCRS((string)null); });
ClassicAssert.Throws<ArgumentNullException>(() => { var crs = new LinkedCRS((string)null); });
}

[Test]
public void Ctor_Throws_ArgumentNullExpection_When_Href_Uri_Is_Null()
{
Assert.Throws<ArgumentNullException>(() => { var crs = new LinkedCRS((Uri)null); });
ClassicAssert.Throws<ArgumentNullException>(() => { var crs = new LinkedCRS((Uri)null); });
}

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

var argumentExpection = Assert.Throws<ArgumentException>(() => { var crs = new LinkedCRS("http://not-a-valid-<>-url"); });
Assert.AreEqual(expected, argumentExpection.Message);
var argumentExpection = ClassicAssert.Throws<ArgumentException>(() => { var crs = new LinkedCRS("http://not-a-valid-<>-url"); });
ClassicAssert.AreEqual(expected, argumentExpection.Message);
}

[Test]
public void Ctor_Does_Not_Throw_When_Href_Is_Dereferencable_Uri()
{
Assert.DoesNotThrow(() => { var crs = new LinkedCRS("data.crs"); });
ClassicAssert.DoesNotThrow(() => { var crs = new LinkedCRS("data.crs"); });
}

[Test]
public void Ctor_Throws_ArgumentNullExpection_When_Name_Is_Empty()
{
Assert.Throws<ArgumentException>(() => { var crs = new LinkedCRS(string.Empty); });
ClassicAssert.Throws<ArgumentException>(() => { var crs = new LinkedCRS(string.Empty); });
}

[Test]
Expand All @@ -106,30 +107,30 @@ public void Equals_GetHashCode_Contract()
var left = new LinkedCRS(Href);
var right = new LinkedCRS(Href);

Assert.AreEqual(left, right);
ClassicAssert.AreEqual(left, right);

Assert.IsTrue(left == right);
Assert.IsTrue(right == left);
ClassicAssert.IsTrue(left == right);
ClassicAssert.IsTrue(right == left);

Assert.IsTrue(left.Equals(right));
Assert.IsTrue(right.Equals(left));
ClassicAssert.IsTrue(left.Equals(right));
ClassicAssert.IsTrue(right.Equals(left));

Assert.IsTrue(left.Equals(left));
Assert.IsTrue(right.Equals(right));
ClassicAssert.IsTrue(left.Equals(left));
ClassicAssert.IsTrue(right.Equals(right));

Assert.AreEqual(left.GetHashCode(), right.GetHashCode());
ClassicAssert.AreEqual(left.GetHashCode(), right.GetHashCode());

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

Assert.AreNotEqual(left, right);
ClassicAssert.AreNotEqual(left, right);

Assert.IsFalse(left == right);
Assert.IsFalse(right == left);
ClassicAssert.IsFalse(left == right);
ClassicAssert.IsFalse(right == left);

Assert.IsFalse(left.Equals(right));
Assert.IsFalse(right.Equals(left));
ClassicAssert.IsFalse(left.Equals(right));
ClassicAssert.IsFalse(right.Equals(left));

Assert.AreNotEqual(left.GetHashCode(), right.GetHashCode());
ClassicAssert.AreNotEqual(left.GetHashCode(), right.GetHashCode());
}
}
}
39 changes: 20 additions & 19 deletions src/GeoJSON.Net.Tests/CoordinateReferenceSystem/NamedCrsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using GeoJSON.Net.Feature;
using Newtonsoft.Json;
using NUnit.Framework;
using NUnit.Framework.Legacy;

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

Assert.AreEqual(CRSType.Name, crs.Type);
ClassicAssert.AreEqual(CRSType.Name, crs.Type);
}

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

Assert.IsTrue(crs.Properties.ContainsKey("name"));
Assert.AreEqual(name, crs.Properties["name"]);
ClassicAssert.IsTrue(crs.Properties.ContainsKey("name"));
ClassicAssert.AreEqual(name, crs.Properties["name"]);
}

[Test]
Expand All @@ -40,13 +41,13 @@ public void Can_Serialize()
[Test]
public void Ctor_Throws_ArgumentNullExpection_When_Name_Is_Null()
{
Assert.Throws<ArgumentNullException>(() => { var collection = new FeatureCollection() { CRS = new NamedCRS(null) }; });
ClassicAssert.Throws<ArgumentNullException>(() => { var collection = new FeatureCollection() { CRS = new NamedCRS(null) }; });
}

[Test]
public void Ctor_Throws_ArgumentNullExpection_When_Name_Is_Empty()
{
Assert.Throws<ArgumentException>(() => { var collection = new FeatureCollection() { CRS = new NamedCRS(string.Empty) }; });
ClassicAssert.Throws<ArgumentException>(() => { var collection = new FeatureCollection() { CRS = new NamedCRS(string.Empty) }; });
}

[Test]
Expand All @@ -57,31 +58,31 @@ public void Equals_GetHashCode_Contract()
var left = new NamedCRS(name);
var right = new NamedCRS(name);

Assert.AreEqual(left, right);
ClassicAssert.AreEqual(left, right);

Assert.IsTrue(left == right);
Assert.IsTrue(right == left);
ClassicAssert.IsTrue(left == right);
ClassicAssert.IsTrue(right == left);

Assert.IsTrue(left.Equals(right));
Assert.IsTrue(right.Equals(left));
ClassicAssert.IsTrue(left.Equals(right));
ClassicAssert.IsTrue(right.Equals(left));

Assert.IsTrue(left.Equals(left));
Assert.IsTrue(right.Equals(right));
ClassicAssert.IsTrue(left.Equals(left));
ClassicAssert.IsTrue(right.Equals(right));

Assert.AreEqual(left.GetHashCode(), right.GetHashCode());
ClassicAssert.AreEqual(left.GetHashCode(), right.GetHashCode());

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

Assert.AreNotEqual(left, right);
ClassicAssert.AreNotEqual(left, right);

Assert.IsFalse(left == right);
Assert.IsFalse(right == left);
ClassicAssert.IsFalse(left == right);
ClassicAssert.IsFalse(right == left);

Assert.IsFalse(left.Equals(right));
Assert.IsFalse(right.Equals(left));
ClassicAssert.IsFalse(left.Equals(right));
ClassicAssert.IsFalse(right.Equals(left));

Assert.AreNotEqual(left.GetHashCode(), right.GetHashCode());
ClassicAssert.AreNotEqual(left.GetHashCode(), right.GetHashCode());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using GeoJSON.Net.Feature;
using Newtonsoft.Json;
using NUnit.Framework;
using NUnit.Framework.Legacy;

namespace GeoJSON.Net.Tests.CoordinateReferenceSystem
{
Expand All @@ -13,7 +14,7 @@ public void Has_Correct_Type()
{
var crs = new UnspecifiedCRS();

Assert.AreEqual(CRSType.Unspecified, crs.Type);
ClassicAssert.AreEqual(CRSType.Unspecified, crs.Type);
}

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

Assert.IsInstanceOf<UnspecifiedCRS>(featureCollection.CRS);
ClassicAssert.IsInstanceOf<UnspecifiedCRS>(featureCollection.CRS);
}

[Test]
Expand All @@ -41,18 +42,18 @@ public void Equals_GetHashCode_Contract()
var left = new UnspecifiedCRS();
var right = new UnspecifiedCRS();

Assert.AreEqual(left, right);
ClassicAssert.AreEqual(left, right);

Assert.IsTrue(left == right);
Assert.IsTrue(right == left);
ClassicAssert.IsTrue(left == right);
ClassicAssert.IsTrue(right == left);

Assert.IsTrue(left.Equals(right));
Assert.IsTrue(right.Equals(left));
ClassicAssert.IsTrue(left.Equals(right));
ClassicAssert.IsTrue(right.Equals(left));

Assert.IsTrue(left.Equals(left));
Assert.IsTrue(right.Equals(right));
ClassicAssert.IsTrue(left.Equals(left));
ClassicAssert.IsTrue(right.Equals(right));

Assert.AreEqual(left.GetHashCode(), right.GetHashCode());
ClassicAssert.AreEqual(left.GetHashCode(), right.GetHashCode());
}
}
}
Loading

0 comments on commit c384561

Please sign in to comment.