Skip to content

Commit

Permalink
Update tests to NUnit 4.
Browse files Browse the repository at this point in the history
  • Loading branch information
wo80 committed Dec 28, 2023
1 parent aea7434 commit 58c0e1b
Show file tree
Hide file tree
Showing 17 changed files with 260 additions and 260 deletions.
4 changes: 2 additions & 2 deletions src/Triangle.Tests/Geomerty/ContourTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void TestFindInteriorPoint()

var p = contour.FindInteriorPoint();

Assert.IsTrue(p.X > 0d && p.X < 1d && p.Y > 0d && p.Y < 1d);
Assert.That(p.X > 0d && p.X < 1d && p.Y > 0d && p.Y < 1d, Is.True);
}

[Test]
Expand Down Expand Up @@ -58,7 +58,7 @@ public void TestFindInteriorPointL()
{
double ccw = p.CounterClockwise(points[i], h, points[j]);

Assert.Greater(Math.Abs(ccw), 1e-12);
Assert.That(Math.Abs(ccw), Is.GreaterThan(1e-12));

i = j;
}
Expand Down
28 changes: 14 additions & 14 deletions src/Triangle.Tests/Geomerty/PolygonTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ public void TestAddContour()

p.Add(contour);

Assert.AreEqual(3, p.Points.Count);
Assert.AreEqual(3, p.Segments.Count);
Assert.AreEqual(0, p.Holes.Count);
Assert.AreEqual(0, p.Regions.Count);
Assert.That(p.Points.Count, Is.EqualTo(3));
Assert.That(p.Segments.Count, Is.EqualTo(3));
Assert.That(p.Holes.Count, Is.EqualTo(0));
Assert.That(p.Regions.Count, Is.EqualTo(0));
}

[Test]
Expand All @@ -37,10 +37,10 @@ public void TestAddContourAsHole()

p.Add(contour, true);

Assert.AreEqual(3, p.Points.Count);
Assert.AreEqual(3, p.Segments.Count);
Assert.AreEqual(1, p.Holes.Count);
Assert.AreEqual(0, p.Regions.Count);
Assert.That(p.Points.Count, Is.EqualTo(3));
Assert.That(p.Segments.Count, Is.EqualTo(3));
Assert.That(p.Holes.Count, Is.EqualTo(1));
Assert.That(p.Regions.Count, Is.EqualTo(0));
}

[Test]
Expand All @@ -52,10 +52,10 @@ public void TestAddContourAsRegion()

p.Add(contour, 1);

Assert.AreEqual(3, p.Points.Count);
Assert.AreEqual(3, p.Segments.Count);
Assert.AreEqual(0, p.Holes.Count);
Assert.AreEqual(1, p.Regions.Count);
Assert.That(p.Points.Count, Is.EqualTo(3));
Assert.That(p.Segments.Count, Is.EqualTo(3));
Assert.That(p.Holes.Count, Is.EqualTo(0));
Assert.That(p.Regions.Count, Is.EqualTo(1));
}

[Test]
Expand All @@ -69,8 +69,8 @@ public void TestBounds()

var bounds = p.Bounds();

Assert.AreEqual(2d, bounds.Width);
Assert.AreEqual(1.5, bounds.Height);
Assert.That(bounds.Width, Is.EqualTo(2d));
Assert.That(bounds.Height, Is.EqualTo(1.5));
}
}
}
24 changes: 12 additions & 12 deletions src/Triangle.Tests/Meshing/Algorithm/TriangulatorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public void TestTriangulateIncremental()

var mesh = t.Triangulate(vertices, new Configuration());

Assert.AreEqual(6, vertices.Count);
Assert.AreEqual(6, mesh.Vertices.Count);
Assert.AreEqual(1, mesh.Vertices
Assert.That(vertices.Count, Is.EqualTo(6));
Assert.That(mesh.Vertices.Count, Is.EqualTo(6));
Assert.That(mesh.Vertices
.Where(v => v.Type == VertexType.UndeadVertex)
.Count());
.Count(), Is.EqualTo(1));
}

[Test]
Expand All @@ -33,11 +33,11 @@ public void TestTriangulateSweepLine()

var mesh = t.Triangulate(vertices, new Configuration());

Assert.AreEqual(6, vertices.Count);
Assert.AreEqual(6, mesh.Vertices.Count);
Assert.AreEqual(1, mesh.Vertices
Assert.That(vertices.Count, Is.EqualTo(6));
Assert.That(mesh.Vertices.Count, Is.EqualTo(6));
Assert.That(mesh.Vertices
.Where(v => v.Type == VertexType.UndeadVertex)
.Count());
.Count(), Is.EqualTo(1));
}

[Test]
Expand All @@ -49,11 +49,11 @@ public void TestTriangulateDwyer()

var mesh = t.Triangulate(vertices, new Configuration());

Assert.AreEqual(6, vertices.Count);
Assert.AreEqual(6, mesh.Vertices.Count);
Assert.AreEqual(1, mesh.Vertices
Assert.That(vertices.Count, Is.EqualTo(6));
Assert.That(mesh.Vertices.Count, Is.EqualTo(6));
Assert.That(mesh.Vertices
.Where(v => v.Type == VertexType.UndeadVertex)
.Count());
.Count(), Is.EqualTo(1));
}

private List<Vertex> GetVertices()
Expand Down
8 changes: 4 additions & 4 deletions src/Triangle.Tests/Meshing/GenericMesherTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public void TestTriangulateDwyer()

var mesh = m.Triangulate(vertices);

Assert.AreEqual(6, vertices.Count);
Assert.AreEqual(6, mesh.Vertices.Count);
Assert.AreEqual(1, mesh.Vertices
Assert.That(vertices.Count, Is.EqualTo(6));
Assert.That(mesh.Vertices.Count, Is.EqualTo(6));
Assert.That(mesh.Vertices
.Where(v => v.Type == VertexType.UndeadVertex)
.Count());
.Count(), Is.EqualTo(1));
}

private List<Vertex> GetVertices()
Expand Down
2 changes: 1 addition & 1 deletion src/Triangle.Tests/Meshing/Iterators/RegionIteratorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void TestProcessRegionProtected()
// Find a seeding triangle in region 1.
var seed = (Triangle)qtree.Query(0.0, 0.0);

iterator.Process(seed, t => Assert.AreEqual(1, t.Label));
iterator.Process(seed, t => Assert.That(t.Label, Is.EqualTo(1)));
}
}
}
6 changes: 3 additions & 3 deletions src/Triangle.Tests/Meshing/Iterators/VertexCirculatorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public void TestEnumerateVertices()
var p = vertices[0];

var list = circulator.EnumerateVertices(p).ToList();
Assert.AreEqual(2, list.Count);

Assert.That(list.Count, Is.EqualTo(2));
}

[Test]
Expand All @@ -45,7 +45,7 @@ public void TestEnumerateTriangles()

var list = circulator.EnumerateTriangles(p).ToList();

Assert.AreEqual(1, list.Count);
Assert.That(list.Count, Is.EqualTo(1));
}

private Mesh CreateMesh(out Vertex[] vertices)
Expand Down
20 changes: 10 additions & 10 deletions src/Triangle.Tests/RobustPredicatesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public void TestCounterClockwise()
var a = new Point(-1d, 0d);
var b = new Point( 0d, 1d);

Assert.IsTrue(robust.CounterClockwise(a, b, new Point(1d, 0d)) < 0d);
Assert.IsTrue(robust.CounterClockwise(a, b, new Point(0d, 2d)) > 0d);
Assert.IsTrue(robust.CounterClockwise(a, b, new Point(1d, 2d)) == 0d);
Assert.That(robust.CounterClockwise(a, b, new Point(1d, 0d)), Is.LessThan(0d));
Assert.That(robust.CounterClockwise(a, b, new Point(0d, 2d)), Is.GreaterThan(0d));
Assert.That(robust.CounterClockwise(a, b, new Point(1d, 2d)), Is.EqualTo(0d));
}

[Test]
Expand All @@ -27,9 +27,9 @@ public void TestInCircle()
var b = new Point(0d, 1d);
var c = new Point(1d, 0d);

Assert.IsTrue(robust.InCircle(a, b, c, new Point(0d, 0.5)) < 0d);
Assert.IsTrue(robust.InCircle(a, b, c, new Point(0d, 1.5)) > 0d);
Assert.IsTrue(robust.InCircle(a, b, c, new Point(0d, 1d)) == 0d);
Assert.That(robust.InCircle(a, b, c, new Point(0d, 0.5)), Is.LessThan(0d));
Assert.That(robust.InCircle(a, b, c, new Point(0d, 1.5)), Is.GreaterThan(0d));
Assert.That(robust.InCircle(a, b, c, new Point(0d, 1.0)), Is.EqualTo(0d));
}

[Test]
Expand All @@ -46,10 +46,10 @@ public void TestFindCircumcenter()
var actual = robust.FindCircumcenter(a, b, c, ref xi, ref eta);
var expected = new Point(0d, 0d);

Assert.AreEqual(expected.X, actual.X);
Assert.AreEqual(expected.Y, actual.Y);
Assert.AreEqual(0.0, xi);
Assert.AreEqual(0.5, eta);
Assert.That(actual.X, Is.EqualTo(expected.X));
Assert.That(actual.Y, Is.EqualTo(expected.Y));
Assert.That(xi, Is.EqualTo(0.0));
Assert.That(eta, Is.EqualTo(0.5));
}
}
}
10 changes: 5 additions & 5 deletions src/Triangle.Tests/Smoothing/SimpleSmootherTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@ public void TestSmoothWithDuplicate()

var mesh = poly.Triangulate(options, quality);

Assert.AreEqual(1, mesh.Vertices
Assert.That(mesh.Vertices
.Where(v => v.Type == VertexType.UndeadVertex)
.Count());
.Count(), Is.EqualTo(1));

quality.MaximumArea = 0.2;

mesh.Refine(quality, true);

Assert.AreEqual(1, mesh.Vertices
Assert.That(mesh.Vertices
.Where(v => v.Type == VertexType.UndeadVertex)
.Count());
.Count(), Is.EqualTo(1));

var smoother = new SimpleSmoother();

// Smooth mesh.
Assert.IsTrue(smoother.Smooth(mesh, 25) > 0);
Assert.That(smoother.Smooth(mesh, 25), Is.GreaterThan(0));
}

private Polygon GetPolygon()
Expand Down
12 changes: 6 additions & 6 deletions src/Triangle.Tests/Tools/AdjacencyMatrixTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ public void TestAdjacencyMatrix()
var mesher = new GenericMesher();
var mesh = (Mesh)mesher.Triangulate(p);

Assert.AreEqual(5, mesh.Vertices.Max(v => v.ID));
Assert.That(mesh.Vertices.Max(v => v.ID), Is.EqualTo(5));

mesh.Renumber();

var matrix = new AdjacencyMatrix(mesh);

// Highest vertex id after renumbering is 4, since there
// is no duplicate vertex.
Assert.AreEqual(4, matrix.RowIndices.Max());
Assert.AreEqual(5, matrix.ColumnCount);
Assert.That(matrix.RowIndices.Max(), Is.EqualTo(4));
Assert.That(matrix.ColumnCount, Is.EqualTo(5));
}

[Test]
Expand All @@ -43,7 +43,7 @@ public void TestAdjacencyMatrixDuplicate()

// Highest vertex id after renumbering is 4, duplicates
// are ignored.
Assert.AreEqual(4, ai.Max());
Assert.That(ai.Max(), Is.EqualTo(4));

// Get the single, duplicate vertex.
var dup = mesh.Vertices
Expand All @@ -52,8 +52,8 @@ public void TestAdjacencyMatrixDuplicate()

// Side effect: undead vertices will have negative indices
// after computing the adjacency matrix.
Assert.IsTrue(dup.id < 0);
Assert.IsTrue(!ai.Contains(dup.id));
Assert.That(dup.id, Is.LessThan(0));
Assert.That(!ai.Contains(dup.id), Is.True);
}

private List<Vertex> GetVertices(bool includeDuplicate)
Expand Down
16 changes: 8 additions & 8 deletions src/Triangle.Tests/Tools/CuthillMcKeeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ public void TestCuthillMcKee()

var matrix = new AdjacencyMatrix(mesh);

CollectionAssert.AreEqual(matrix.ColumnPointers, new int[] { 0, 4, 7, 11, 17, 21, 24 });
CollectionAssert.AreEqual(matrix.RowIndices, new int[] {
Assert.That(new int[] { 0, 4, 7, 11, 17, 21, 24 }, Is.EqualTo(matrix.ColumnPointers).AsCollection);
Assert.That(new int[] {
0, 1, 2, 3,
0, 1, 3,
0, 2, 3, 4,
0, 1, 2, 3, 4, 5,
2, 3, 4, 5,
3, 4, 5 });
3, 4, 5 }, Is.EqualTo(matrix.RowIndices).AsCollection);

Assert.AreEqual(7, matrix.Bandwidth());
Assert.That(matrix.Bandwidth(), Is.EqualTo(7));

var p = new CuthillMcKee().Renumber(matrix);

Expand All @@ -33,17 +33,17 @@ public void TestCuthillMcKee()

var pmatrix = new AdjacencyMatrix(mesh, false);

CollectionAssert.AreEqual(pmatrix.ColumnPointers, new int[] { 0, 3, 7, 11, 15, 21, 24 });
CollectionAssert.AreEqual(pmatrix.RowIndices, new int[] {
Assert.That(new int[] { 0, 3, 7, 11, 15, 21, 24 }, Is.EqualTo(pmatrix.ColumnPointers).AsCollection);
Assert.That(new int[] {
0, 2, 4,
1, 2, 3, 4,
0, 1, 2, 4,
1, 3, 4, 5,
0, 1, 2, 3, 4, 5,
3, 4, 5 });
3, 4, 5 }, Is.EqualTo(pmatrix.RowIndices).AsCollection);

// For structured meshes we cannot expect an improved bandwidth.
Assert.AreEqual(9, pmatrix.Bandwidth());
Assert.That(pmatrix.Bandwidth(), Is.EqualTo(9));
}
}
}
6 changes: 3 additions & 3 deletions src/Triangle.Tests/Tools/InterpolationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void TestInterpolatePoint()
actual = Interpolation.InterpolatePoint(tri, vertices[i], values);
expected = values[i];

Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}

// Check the edge midpoints.
Expand All @@ -52,7 +52,7 @@ public void TestInterpolatePoint()
actual = Interpolation.InterpolatePoint(tri, p, values);
expected = (values[i] + values[(i + 1) % 3]) / 2;

Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}

// Check centroid.
Expand All @@ -62,7 +62,7 @@ public void TestInterpolatePoint()
actual = Interpolation.InterpolatePoint(tri, new Point(x, y), values);
expected = (values[0] + values[1] + values[2]) / 3;

Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}
}
}
Loading

0 comments on commit 58c0e1b

Please sign in to comment.