From 4b63cb71a85a66f16dca959c305fe89f1aae59b6 Mon Sep 17 00:00:00 2001 From: visose Date: Sat, 23 Mar 2024 18:30:27 +0000 Subject: [PATCH] Update to NUnit 4 --- build/Robots.Build/Robots.Build.csproj | 4 ++-- tests/Robots.Tests/ABBTests.cs | 25 ++++++++++++------------- tests/Robots.Tests/Robots.Tests.csproj | 8 ++++---- tests/Robots.Tests/URTests.cs | 11 +++++------ 4 files changed, 23 insertions(+), 25 deletions(-) diff --git a/build/Robots.Build/Robots.Build.csproj b/build/Robots.Build/Robots.Build.csproj index 03910c3..c9eb88e 100644 --- a/build/Robots.Build/Robots.Build.csproj +++ b/build/Robots.Build/Robots.Build.csproj @@ -2,14 +2,14 @@ Exe - net7.0 + net8.0 $(RootDir) CA1852 - + \ No newline at end of file diff --git a/tests/Robots.Tests/ABBTests.cs b/tests/Robots.Tests/ABBTests.cs index 7f34074..6b908c2 100644 --- a/tests/Robots.Tests/ABBTests.cs +++ b/tests/Robots.Tests/ABBTests.cs @@ -28,7 +28,7 @@ public ABBTests() public void AbbCorrectDuration() { const double expected = 1.6432545251573487; - Assert.AreEqual(expected, _program.Duration, 1e-14); + Assert.That(_program.Duration, Is.EqualTo(expected).Within(1e-14)); } [Test] @@ -36,18 +36,17 @@ public void AbbCorrectJoints() { double[] expected = [ - -0.72007069377409672, - 1.5806369662963811, - -0.075569321979534809, - -1.4960590345094886, - 0.72252891341688164, - 3.042104596978858 - ]; + -0.72007069377409672, + 1.5806369662963811, + -0.075569321979534809, + -1.4960590345094886, + 0.72252891341688164, + 3.042104596978858 + ]; var actual = _program.Targets[1].Joints; - for (int i = 0; i < 6; i++) - Assert.AreEqual(expected[i], actual[i], 1e-14); + Assert.That(actual, Is.EqualTo(expected).Within(1e-14)); } [Test] @@ -62,8 +61,7 @@ public void AbbCorrectPlanes() .SelectMany(p => new[] { (Vector3d)p.Origin, p.XAxis, p.YAxis }) .SelectMany(v => new[] { v.X, v.Y, v.Z }); - foreach (var (e, a) in expected.Zip(actual)) - Assert.AreEqual(e, a, 1e-12); + Assert.That(actual, Is.EqualTo(expected).Within(1e-12)); } [Test] @@ -85,6 +83,7 @@ PROC Main() var code = _program.Code ?? throw new InvalidOperationException("Program code not generated"); var actual = string.Join(Environment.NewLine, code[0].SelectMany(c => c)); - Assert.AreEqual(expected, actual); + + Assert.That(actual, Is.EqualTo(expected)); } } diff --git a/tests/Robots.Tests/Robots.Tests.csproj b/tests/Robots.Tests/Robots.Tests.csproj index 9ba0251..317d5dd 100644 --- a/tests/Robots.Tests/Robots.Tests.csproj +++ b/tests/Robots.Tests/Robots.Tests.csproj @@ -1,15 +1,15 @@ - net6.0 + net8.0 false true - - - + + + diff --git a/tests/Robots.Tests/URTests.cs b/tests/Robots.Tests/URTests.cs index de86e2e..b6e387c 100644 --- a/tests/Robots.Tests/URTests.cs +++ b/tests/Robots.Tests/URTests.cs @@ -28,7 +28,7 @@ public URTests() public void URCorrectDuration() { const double expected = 1.7425663263380393; - Assert.AreEqual(expected, _program.Duration, 1e-14); + Assert.That(_program.Duration, Is.EqualTo(expected).Within(1e-14)); } [Test] @@ -41,8 +41,7 @@ public void URCorrectJoints() var actual = _program.Targets[1].Joints; - for (int i = 0; i < 6; i++) - Assert.AreEqual(expected[i], actual[i], 1e-14); + Assert.That(actual, Is.EqualTo(expected).Within(1e-14)); } [Test] @@ -57,8 +56,7 @@ public void URCorrectPlanes() .SelectMany(p => new[] { (Vector3d)p.Origin, p.XAxis, p.YAxis }) .SelectMany(v => new[] { v.X, v.Y, v.Z }); - foreach (var (e, a) in expected.Zip(actual)) - Assert.AreEqual(e, a, 1e-12); + Assert.That(actual, Is.EqualTo(expected).Within(1e-12)); } [Test] @@ -79,6 +77,7 @@ public void URCorrectCode() var code = _program.Code ?? throw new InvalidOperationException("Program code not generated"); var actual = string.Join(Environment.NewLine, code[0].SelectMany(c => c)).ReplaceLineEndings(); - Assert.AreEqual(expected, actual); + + Assert.That(actual, Is.EqualTo(expected)); } }