Skip to content

Commit

Permalink
Update to NUnit 4
Browse files Browse the repository at this point in the history
  • Loading branch information
visose committed Mar 23, 2024
1 parent 3b49937 commit 4b63cb7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 25 deletions.
4 changes: 2 additions & 2 deletions build/Robots.Build/Robots.Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<StartWorkingDirectory>$(RootDir)</StartWorkingDirectory>
<StartArguments><!--debug--></StartArguments>
<NoWarn>CA1852</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="RhinoPackager" Version="1.3.0" />
<PackageReference Include="RhinoPackager" Version="1.4.0" />
</ItemGroup>

</Project>
25 changes: 12 additions & 13 deletions tests/Robots.Tests/ABBTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,25 @@ 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]
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]
Expand All @@ -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]
Expand All @@ -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));
}
}
8 changes: 4 additions & 4 deletions tests/Robots.Tests/Robots.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<GenerateProgramFile>true</GenerateProgramFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
11 changes: 5 additions & 6 deletions tests/Robots.Tests/URTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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));
}
}

0 comments on commit 4b63cb7

Please sign in to comment.