diff --git a/zzio.tests/zzio/MyAssert.cs b/zzio.tests/zzio/MyAssert.cs index 60214f8c..9cd8493c 100644 --- a/zzio.tests/zzio/MyAssert.cs +++ b/zzio.tests/zzio/MyAssert.cs @@ -20,9 +20,9 @@ public static void Equals(string expected, Stream? stream) byte[] expectedBytes = Encoding.UTF8.GetBytes(expected); byte[] actualBytes = new byte[expectedBytes.Length]; Assert.NotNull(stream); - Assert.AreEqual(actualBytes.Length, stream!.Read(actualBytes, 0, actualBytes.Length)); - Assert.AreEqual(expectedBytes, actualBytes); - Assert.AreEqual(-1, stream.ReadByte()); + Assert.That(stream!.Read(actualBytes, 0, actualBytes.Length), Is.EqualTo(actualBytes.Length)); + Assert.That(actualBytes, Is.EqualTo(expectedBytes)); + Assert.That(stream.ReadByte(), Is.EqualTo(-1)); stream.Close(); } } diff --git a/zzio.tests/zzio/TestActorExDescription.cs b/zzio.tests/zzio/TestActorExDescription.cs index 6d098ffb..3a80d6fa 100644 --- a/zzio.tests/zzio/TestActorExDescription.cs +++ b/zzio.tests/zzio/TestActorExDescription.cs @@ -13,19 +13,19 @@ public class TestActorExDescription private void testInstance(ActorExDescription aed) { Assert.NotNull(aed); - Assert.AreEqual(1337, aed.headBoneID); - Assert.AreEqual("hello.dff", aed.body.model); - Assert.AreEqual("wings.dff", aed.wings.model); - - Assert.AreEqual(2, aed.body.animations.Length); - Assert.AreEqual("first.ani", aed.body.animations[0].filename); - Assert.AreEqual(AnimationType.Jump, aed.body.animations[0].type); - Assert.AreEqual("second.ani", aed.body.animations[1].filename); - Assert.AreEqual(AnimationType.Run, aed.body.animations[1].type); - - Assert.AreEqual(1, aed.wings.animations.Length); - Assert.AreEqual("third.ani", aed.wings.animations[0].filename); - Assert.AreEqual(AnimationType.RunForwardLeft, aed.wings.animations[0].type); + Assert.That(aed.headBoneID, Is.EqualTo(1337)); + Assert.That(aed.body.model, Is.EqualTo("hello.dff")); + Assert.That(aed.wings.model, Is.EqualTo("wings.dff")); + + Assert.That(aed.body.animations.Length, Is.EqualTo(2)); + Assert.That(aed.body.animations[0].filename, Is.EqualTo("first.ani")); + Assert.That(aed.body.animations[0].type, Is.EqualTo(AnimationType.Jump)); + Assert.That(aed.body.animations[1].filename, Is.EqualTo("second.ani")); + Assert.That(aed.body.animations[1].type, Is.EqualTo(AnimationType.Run)); + + Assert.That(aed.wings.animations.Length, Is.EqualTo(1)); + Assert.That(aed.wings.animations[0].filename, Is.EqualTo("third.ani")); + Assert.That(aed.wings.animations[0].type, Is.EqualTo(AnimationType.RunForwardLeft)); } [Test] diff --git a/zzio.tests/zzio/TestMapMarker.cs b/zzio.tests/zzio/TestMapMarker.cs index 0a444405..44be4150 100644 --- a/zzio.tests/zzio/TestMapMarker.cs +++ b/zzio.tests/zzio/TestMapMarker.cs @@ -13,22 +13,22 @@ public class TestMapMarker private void testMarkers(MapMarker[] mapMarkers) { Assert.NotNull(mapMarkers); - Assert.AreEqual(3, mapMarkers.Length); - - Assert.AreEqual(1234, mapMarkers[0].posX); - Assert.AreEqual(5678, mapMarkers[0].posY); - Assert.AreEqual(MapMarkerSection.EnchantedForest, mapMarkers[0].section); - Assert.AreEqual(1337, mapMarkers[0].sceneId); - - Assert.AreEqual(9876, mapMarkers[1].posX); - Assert.AreEqual(5432, mapMarkers[1].posY); - Assert.AreEqual(MapMarkerSection.DarkSwamp, mapMarkers[1].section); - Assert.AreEqual(42, mapMarkers[1].sceneId); - - Assert.AreEqual(1357, mapMarkers[2].posX); - Assert.AreEqual(2468, mapMarkers[2].posY); - Assert.AreEqual(MapMarkerSection.RealmOfClouds, mapMarkers[2].section); - Assert.AreEqual(1037, mapMarkers[2].sceneId); + Assert.That(mapMarkers.Length, Is.EqualTo(3)); + + Assert.That(mapMarkers[0].posX, Is.EqualTo(1234)); + Assert.That(mapMarkers[0].posY, Is.EqualTo(5678)); + Assert.That(mapMarkers[0].section, Is.EqualTo(MapMarkerSection.EnchantedForest)); + Assert.That(mapMarkers[0].sceneId, Is.EqualTo(1337)); + + Assert.That(mapMarkers[1].posX, Is.EqualTo(9876)); + Assert.That(mapMarkers[1].posY, Is.EqualTo(5432)); + Assert.That(mapMarkers[1].section, Is.EqualTo(MapMarkerSection.DarkSwamp)); + Assert.That(mapMarkers[1].sceneId, Is.EqualTo(42)); + + Assert.That(mapMarkers[2].posX, Is.EqualTo(1357)); + Assert.That(mapMarkers[2].posY, Is.EqualTo(2468)); + Assert.That(mapMarkers[2].section, Is.EqualTo(MapMarkerSection.RealmOfClouds)); + Assert.That(mapMarkers[2].sceneId, Is.EqualTo(1037)); } [Test] diff --git a/zzio.tests/zzio/TestPAKArchive.cs b/zzio.tests/zzio/TestPAKArchive.cs index f466dc32..fb485aba 100644 --- a/zzio.tests/zzio/TestPAKArchive.cs +++ b/zzio.tests/zzio/TestPAKArchive.cs @@ -18,27 +18,27 @@ public void containsfile() MemoryStream stream = new(sampleData, false); PAKArchive archive = PAKArchive.ReadNew(stream); - Assert.True(archive.ContainsFile("A/a.txt")); - Assert.True(archive.ContainsFile("a/B.txt")); - Assert.True(archive.ContainsFile("a/c/d.txt")); - Assert.True(archive.ContainsFile("a/e/f/g.txt")); - Assert.True(archive.ContainsFile("a/A.tXT")); - Assert.True(archive.ContainsFile("a/../a/./\\..\\A\\a.txt")); - - Assert.False(archive.ContainsFile("a.txt")); - Assert.False(archive.ContainsFile("..")); - Assert.False(archive.ContainsFile("../A/")); - Assert.False(archive.ContainsFile("../a/Z.txt")); + Assert.That(archive.ContainsFile("A/a.txt"), Is.True); + Assert.That(archive.ContainsFile("a/B.txt"), Is.True); + Assert.That(archive.ContainsFile("a/c/d.txt"), Is.True); + Assert.That(archive.ContainsFile("a/e/f/g.txt"), Is.True); + Assert.That(archive.ContainsFile("a/A.tXT"), Is.True); + Assert.That(archive.ContainsFile("a/../a/./\\..\\A\\a.txt"), Is.True); + + Assert.That(archive.ContainsFile("a.txt"), Is.False); + Assert.That(archive.ContainsFile(".."), Is.False); + Assert.That(archive.ContainsFile("../A/"), Is.False); + Assert.That(archive.ContainsFile("../a/Z.txt"), Is.False); } private void testStream(Stream stream, string expected) { byte[] expectedBuffer = Encoding.UTF8.GetBytes(expected); byte[] actualBuffer = new byte[expectedBuffer.Length]; - Assert.AreEqual(0, stream.Position); - Assert.AreEqual(expectedBuffer.Length, stream.Read(actualBuffer, 0, expectedBuffer.Length)); - Assert.AreEqual(-1, stream.ReadByte()); - Assert.AreEqual(expectedBuffer, actualBuffer); + Assert.That(stream.Position, Is.EqualTo(0)); + Assert.That(stream.Read(actualBuffer, 0, expectedBuffer.Length), Is.EqualTo(expectedBuffer.Length)); + Assert.That(stream.ReadByte(), Is.EqualTo(-1)); + Assert.That(actualBuffer, Is.EqualTo(expectedBuffer)); stream.Close(); } @@ -63,7 +63,7 @@ public void getdirectorycontent() MemoryStream stream = new(sampleData, false); PAKArchive archive = PAKArchive.ReadNew(stream); - Assert.AreEqual(Array.Empty(), archive.GetDirectoryContent("G/H/I")); + Assert.That(archive.GetDirectoryContent("G/H/I"), Is.EqualTo(Array.Empty())); Assert.That(archive.GetDirectoryContent("", true), Is.EquivalentTo(new string[] { diff --git a/zzio.tests/zzio/TestResettableLazy.cs b/zzio.tests/zzio/TestResettableLazy.cs index efea5e32..d131b6c8 100644 --- a/zzio.tests/zzio/TestResettableLazy.cs +++ b/zzio.tests/zzio/TestResettableLazy.cs @@ -8,10 +8,10 @@ public class TestResettableLazy public void IsEmptyByDefault() { var refLazy = new ResettableLazy(() => ""); - Assert.IsFalse(refLazy.HasValue); + Assert.That(refLazy.HasValue, Is.False); var valLazy = new ResettableLazyValue(() => 0); - Assert.IsFalse(valLazy.HasValue); + Assert.That(valLazy.HasValue, Is.False); } [Test] @@ -19,23 +19,23 @@ public void IsNotEmptyAfterAccess() { var refLazy = new ResettableLazy(() => ""); _ = refLazy.Value; - Assert.IsTrue(refLazy.HasValue); + Assert.That(refLazy.HasValue); var valLazy = new ResettableLazyValue(() => 0); _ = valLazy.Value; - Assert.IsTrue(valLazy.HasValue); + Assert.That(valLazy.HasValue); } [Test] public void CanBeInitialized() { var refLazy = new ResettableLazy(() => "", "Hello World"); - Assert.IsTrue(refLazy.HasValue); - Assert.AreEqual("Hello World", refLazy.Value); + Assert.That(refLazy.HasValue); + Assert.That(refLazy.Value, Is.EqualTo("Hello World")); var valLazy = new ResettableLazyValue(() => 0, 42); - Assert.IsTrue(valLazy.HasValue); - Assert.AreEqual(valLazy.Value, 42); + Assert.That(valLazy.HasValue); + Assert.That(valLazy.Value, Is.EqualTo(42)); } [Test] @@ -43,15 +43,15 @@ public void DoesNotCallCreatorEarly() { bool didCallRef = false; var refLazy = new ResettableLazy(() => { didCallRef = true; return ""; }); - Assert.IsFalse(didCallRef); + Assert.That(didCallRef, Is.False); _ = refLazy.Value; - Assert.IsTrue(didCallRef); + Assert.That(didCallRef); bool didCallVal = false; var valLazy = new ResettableLazyValue(() => { didCallVal = true; return 0; }); - Assert.IsFalse(didCallVal); + Assert.That(didCallVal, Is.False); _ = valLazy.Value; - Assert.IsTrue(didCallVal); + Assert.That(didCallVal); } [Test] @@ -62,24 +62,24 @@ public void CallsCreatorOnlyOnce() _ = refLazy.Value; _ = refLazy.Value; _ = refLazy.Value; - Assert.AreEqual(1, callCountRef); + Assert.That(callCountRef, Is.EqualTo(1)); int callCountVal = 0; var valLazy = new ResettableLazyValue(() => { callCountVal++; return 0; }); _ = valLazy.Value; _ = valLazy.Value; _ = valLazy.Value; - Assert.AreEqual(1, callCountVal); + Assert.That(callCountVal, Is.EqualTo(1)); } [Test] public void TakesValueFromCreator() { var refLazy = new ResettableLazy(() => "Hello World"); - Assert.AreEqual("Hello World", refLazy.Value); + Assert.That(refLazy.Value, Is.EqualTo("Hello World")); var valLazy = new ResettableLazyValue(() => 42); - Assert.AreEqual(42, valLazy.Value); + Assert.That(valLazy.Value, Is.EqualTo(42)); } [Test] @@ -88,12 +88,12 @@ public void CanBeReset() var refLazy = new ResettableLazy(() => ""); _ = refLazy.Value; refLazy.Reset(); - Assert.IsFalse(refLazy.HasValue); + Assert.That(refLazy.HasValue, Is.False); var valLazy = new ResettableLazyValue(() => 0); _ = valLazy.Value; valLazy.Reset(); - Assert.IsFalse(valLazy.HasValue); + Assert.That(valLazy.HasValue, Is.False); } [Test] @@ -109,7 +109,7 @@ public void UsesCreatorAfterReset() }); _ = refLazy.Value; refLazy.Reset(); - Assert.AreEqual("Second", refLazy.Value); + Assert.That(refLazy.Value, Is.EqualTo("Second")); bool didCallVal = false; var valLazy = new ResettableLazyValue(() => @@ -121,6 +121,6 @@ public void UsesCreatorAfterReset() }); _ = valLazy.Value; valLazy.Reset(); - Assert.AreEqual(1337, valLazy.Value); + Assert.That(valLazy.Value, Is.EqualTo(1337)); } } diff --git a/zzio.tests/zzio/TestSkeletalAnimation.cs b/zzio.tests/zzio/TestSkeletalAnimation.cs index 6bbbd648..d9aa2214 100644 --- a/zzio.tests/zzio/TestSkeletalAnimation.cs +++ b/zzio.tests/zzio/TestSkeletalAnimation.cs @@ -14,52 +14,52 @@ public class TestSkeletalAnimation private void testNullKeyFrame(AnimationKeyFrame frame) { - Assert.AreEqual(0.0f, frame.rot.X, TOLERANCE); - Assert.AreEqual(0.0f, frame.rot.Y, TOLERANCE); - Assert.AreEqual(0.0f, frame.rot.Z, TOLERANCE); - Assert.AreEqual(0.0f, frame.rot.W, TOLERANCE); - Assert.AreEqual(0.0f, frame.pos.X, TOLERANCE); - Assert.AreEqual(0.0f, frame.pos.Y, TOLERANCE); - Assert.AreEqual(0.0f, frame.pos.Z, TOLERANCE); + Assert.That(frame.rot.X, Is.EqualTo(0.0f).Within(TOLERANCE)); + Assert.That(frame.rot.Y, Is.EqualTo(0.0f).Within(TOLERANCE)); + Assert.That(frame.rot.Z, Is.EqualTo(0.0f).Within(TOLERANCE)); + Assert.That(frame.rot.W, Is.EqualTo(0.0f).Within(TOLERANCE)); + Assert.That(frame.pos.X, Is.EqualTo(0.0f).Within(TOLERANCE)); + Assert.That(frame.pos.Y, Is.EqualTo(0.0f).Within(TOLERANCE)); + Assert.That(frame.pos.Z, Is.EqualTo(0.0f).Within(TOLERANCE)); } private void testAnimation(SkeletalAnimation ani) { Assert.NotNull(ani); - Assert.AreEqual(4, ani.flags); - Assert.AreEqual(3.0f, ani.duration, TOLERANCE); - Assert.AreEqual(3, ani.BoneCount); - Assert.AreEqual(3, ani.boneFrames.Length); + Assert.That(ani.flags, Is.EqualTo(4)); + Assert.That(ani.duration, Is.EqualTo(3.0f).Within(TOLERANCE)); + Assert.That(ani.BoneCount, Is.EqualTo(3)); + Assert.That(ani.boneFrames.Length, Is.EqualTo(3)); - Assert.AreEqual(3, ani.boneFrames[0].Length); - Assert.AreEqual(1.0f, ani.boneFrames[0][0].rot.X, TOLERANCE); - Assert.AreEqual(2.0f, ani.boneFrames[0][0].rot.Y, TOLERANCE); - Assert.AreEqual(3.0f, ani.boneFrames[0][0].rot.Z, TOLERANCE); - Assert.AreEqual(4.0f, ani.boneFrames[0][0].rot.W, TOLERANCE); - Assert.AreEqual(5.0f, ani.boneFrames[0][0].pos.X, TOLERANCE); - Assert.AreEqual(6.0f, ani.boneFrames[0][0].pos.Y, TOLERANCE); - Assert.AreEqual(7.0f, ani.boneFrames[0][0].pos.Z, TOLERANCE); - Assert.AreEqual(0.0f, ani.boneFrames[0][0].time, TOLERANCE); + Assert.That(ani.boneFrames[0].Length, Is.EqualTo(3)); + Assert.That(ani.boneFrames[0][0].rot.X, Is.EqualTo(1.0f).Within(TOLERANCE)); + Assert.That(ani.boneFrames[0][0].rot.Y, Is.EqualTo(2.0f).Within(TOLERANCE)); + Assert.That(ani.boneFrames[0][0].rot.Z, Is.EqualTo(3.0f).Within(TOLERANCE)); + Assert.That(ani.boneFrames[0][0].rot.W, Is.EqualTo(4.0f).Within(TOLERANCE)); + Assert.That(ani.boneFrames[0][0].pos.X, Is.EqualTo(5.0f).Within(TOLERANCE)); + Assert.That(ani.boneFrames[0][0].pos.Y, Is.EqualTo(6.0f).Within(TOLERANCE)); + Assert.That(ani.boneFrames[0][0].pos.Z, Is.EqualTo(7.0f).Within(TOLERANCE)); + Assert.That(ani.boneFrames[0][0].time, Is.EqualTo(0.0f).Within(TOLERANCE)); testNullKeyFrame(ani.boneFrames[0][1]); - Assert.AreEqual(1.0f, ani.boneFrames[0][1].time, TOLERANCE); + Assert.That(ani.boneFrames[0][1].time, Is.EqualTo(1.0f).Within(TOLERANCE)); testNullKeyFrame(ani.boneFrames[0][2]); - Assert.AreEqual(2.0f, ani.boneFrames[0][2].time, TOLERANCE); + Assert.That(ani.boneFrames[0][2].time, Is.EqualTo(2.0f).Within(TOLERANCE)); - Assert.AreEqual(2, ani.boneFrames[1].Length); + Assert.That(ani.boneFrames[1].Length, Is.EqualTo(2)); testNullKeyFrame(ani.boneFrames[1][0]); - Assert.AreEqual(0.0f, ani.boneFrames[1][0].time, TOLERANCE); - Assert.AreEqual(8.0f, ani.boneFrames[1][1].rot.X, TOLERANCE); - Assert.AreEqual(9.0f, ani.boneFrames[1][1].rot.Y, TOLERANCE); - Assert.AreEqual(10.0f, ani.boneFrames[1][1].rot.Z, TOLERANCE); - Assert.AreEqual(11.0f, ani.boneFrames[1][1].rot.W, TOLERANCE); - Assert.AreEqual(12.0f, ani.boneFrames[1][1].pos.X, TOLERANCE); - Assert.AreEqual(13.0f, ani.boneFrames[1][1].pos.Y, TOLERANCE); - Assert.AreEqual(14.0f, ani.boneFrames[1][1].pos.Z, TOLERANCE); - Assert.AreEqual(1.5, ani.boneFrames[1][1].time); + Assert.That(ani.boneFrames[1][0].time, Is.EqualTo(0.0f).Within(TOLERANCE)); + Assert.That(ani.boneFrames[1][1].rot.X, Is.EqualTo(8.0f).Within(TOLERANCE)); + Assert.That(ani.boneFrames[1][1].rot.Y, Is.EqualTo(9.0f).Within(TOLERANCE)); + Assert.That(ani.boneFrames[1][1].rot.Z, Is.EqualTo(10.0f).Within(TOLERANCE)); + Assert.That(ani.boneFrames[1][1].rot.W, Is.EqualTo(11.0f).Within(TOLERANCE)); + Assert.That(ani.boneFrames[1][1].pos.X, Is.EqualTo(12.0f).Within(TOLERANCE)); + Assert.That(ani.boneFrames[1][1].pos.Y, Is.EqualTo(13.0f).Within(TOLERANCE)); + Assert.That(ani.boneFrames[1][1].pos.Z, Is.EqualTo(14.0f).Within(TOLERANCE)); + Assert.That(ani.boneFrames[1][1].time, Is.EqualTo(1.5)); - Assert.AreEqual(1, ani.boneFrames[2].Length); + Assert.That(ani.boneFrames[2].Length, Is.EqualTo(1)); testNullKeyFrame(ani.boneFrames[2][0]); - Assert.AreEqual(0.0f, ani.boneFrames[2][0].time, TOLERANCE); + Assert.That(ani.boneFrames[2][0].time, Is.EqualTo(0.0f).Within(TOLERANCE)); } [Test] diff --git a/zzio.tests/zzio/TestVarConfig.cs b/zzio.tests/zzio/TestVarConfig.cs index 07ceacaf..4b95e450 100644 --- a/zzio.tests/zzio/TestVarConfig.cs +++ b/zzio.tests/zzio/TestVarConfig.cs @@ -14,22 +14,22 @@ public class TestVarConfig private void testConfig(VarConfig cfg) { - Assert.AreEqual(new byte[] { 0xc0, 0xff, 0xee }, cfg.header); - Assert.AreEqual(1.0f, cfg.firstValue.floatValue, TOLERANCE); - Assert.AreEqual("", cfg.firstValue.stringValue); - Assert.AreEqual(3, cfg.variables.Count); - - Assert.True(cfg.variables.ContainsKey("MY_FLOAT_VAR")); - Assert.AreEqual(2.0f, cfg.variables["MY_FLOAT_VAR"].floatValue, TOLERANCE); - Assert.AreEqual("", cfg.variables["MY_FLOAT_VAR"].stringValue); - - Assert.True(cfg.variables.ContainsKey("MY_STRING_VAR")); - Assert.AreEqual(0.0f, cfg.variables["MY_STRING_VAR"].floatValue, TOLERANCE); - Assert.AreEqual("Zanzarah", cfg.variables["MY_STRING_VAR"].stringValue); - - Assert.True(cfg.variables.ContainsKey("MY_BOTH_VAR")); - Assert.AreEqual(3.0f, cfg.variables["MY_BOTH_VAR"].floatValue); - Assert.AreEqual("Hello", cfg.variables["MY_BOTH_VAR"].stringValue); + Assert.That(cfg.header, Is.EqualTo(new byte[] { 0xc0, 0xff, 0xee })); + Assert.That(cfg.firstValue.floatValue, Is.EqualTo(1.0f).Within(TOLERANCE)); + Assert.That(cfg.firstValue.stringValue, Is.EqualTo("")); + Assert.That(cfg.variables.Count, Is.EqualTo(3)); + + Assert.That(cfg.variables.ContainsKey("MY_FLOAT_VAR"), Is.True); + Assert.That(cfg.variables["MY_FLOAT_VAR"].floatValue, Is.EqualTo(2.0f).Within(TOLERANCE)); + Assert.That(cfg.variables["MY_FLOAT_VAR"].stringValue, Is.EqualTo("")); + + Assert.That(cfg.variables.ContainsKey("MY_STRING_VAR"), Is.True); + Assert.That(cfg.variables["MY_STRING_VAR"].floatValue, Is.EqualTo(0.0f).Within(TOLERANCE)); + Assert.That(cfg.variables["MY_STRING_VAR"].stringValue, Is.EqualTo("Zanzarah")); + + Assert.That(cfg.variables.ContainsKey("MY_BOTH_VAR"), Is.True); + Assert.That(cfg.variables["MY_BOTH_VAR"].floatValue, Is.EqualTo(3.0f)); + Assert.That(cfg.variables["MY_BOTH_VAR"].stringValue, Is.EqualTo("Hello")); } [Test] diff --git a/zzio.tests/zzio/db/TestCell.cs b/zzio.tests/zzio/db/TestCell.cs index 77dafa7e..be3a17ed 100644 --- a/zzio.tests/zzio/db/TestCell.cs +++ b/zzio.tests/zzio/db/TestCell.cs @@ -41,7 +41,7 @@ public class TestCell private void testCellType(CellDataType expected, Cell cell) { - Assert.AreEqual(expected, cell.Type); + Assert.That(cell.Type, Is.EqualTo(expected)); if (expected != CellDataType.String) Assert.That(() => cell.String, Throws.Exception); if (expected != CellDataType.Integer) @@ -58,32 +58,32 @@ private void testCellType(CellDataType expected, Cell cell) public void create() { testCellType(CellDataType.String, stringCell); - Assert.AreEqual(13, stringCell.ColumnIndex); - Assert.AreEqual("Hello", stringCell.String); + Assert.That(stringCell.ColumnIndex, Is.EqualTo(13)); + Assert.That(stringCell.String, Is.EqualTo("Hello")); testCellType(CellDataType.Integer, integerCell); - Assert.AreEqual(13, integerCell.ColumnIndex); - Assert.AreEqual(123456, integerCell.Integer); + Assert.That(integerCell.ColumnIndex, Is.EqualTo(13)); + Assert.That(integerCell.Integer, Is.EqualTo(123456)); testCellType(CellDataType.Byte, byteCell); - Assert.AreEqual(13, byteCell.ColumnIndex); - Assert.AreEqual(0xcd, byteCell.Byte); + Assert.That(byteCell.ColumnIndex, Is.EqualTo(13)); + Assert.That(byteCell.Byte, Is.EqualTo(0xcd)); testCellType(CellDataType.ForeignKey, foreignKeyCell); - Assert.AreEqual(-1, foreignKeyCell.ColumnIndex); - Assert.AreEqual(0xc0fffeee, foreignKeyCell.ForeignKey.uid.raw); - Assert.AreEqual(0xbadc0de, foreignKeyCell.ForeignKey.type.raw); + Assert.That(foreignKeyCell.ColumnIndex, Is.EqualTo(-1)); + Assert.That(foreignKeyCell.ForeignKey.uid.raw, Is.EqualTo(0xc0fffeee)); + Assert.That(foreignKeyCell.ForeignKey.type.raw, Is.EqualTo(0xbadc0de)); testCellType(CellDataType.Buffer, bufferCell); - Assert.AreEqual(-1, bufferCell.ColumnIndex); - Assert.AreEqual(new byte[] { 0x37, 0x53, 0x73 }, bufferCell.Buffer); + Assert.That(bufferCell.ColumnIndex, Is.EqualTo(-1)); + Assert.That(bufferCell.Buffer, Is.EqualTo(new byte[] { 0x37, 0x53, 0x73 })); } private void testCellEquality(bool expected, Cell compare, Cell actual) { - Assert.AreEqual(expected, compare.Equals(actual)); + Assert.That(compare.Equals(actual), Is.EqualTo(expected)); bool hashEquality = compare.GetHashCode() == actual.GetHashCode(); - Assert.AreEqual(expected, hashEquality); + Assert.That(hashEquality, Is.EqualTo(expected)); } [Test] @@ -106,7 +106,7 @@ private void testCellRead(Cell expected, byte[] sourceBytes) MemoryStream stream = new(sourceBytes, false); using BinaryReader reader = new(stream); Cell readCell = Cell.ReadNew(reader); - Assert.AreEqual(true, expected.Equals(readCell)); + Assert.That(expected.Equals(readCell), Is.EqualTo(true)); } [Test] @@ -124,7 +124,7 @@ private void testCellWrite(byte[] expected, Cell sourceCell) MemoryStream stream = new(); using BinaryWriter writer = new(stream); sourceCell.Write(writer); - Assert.AreEqual(expected, stream.ToArray()); + Assert.That(stream.ToArray(), Is.EqualTo(expected)); } [Test] diff --git a/zzio.tests/zzio/db/TestIndexTable.cs b/zzio.tests/zzio/db/TestIndexTable.cs index 4c1ef798..ded75df5 100644 --- a/zzio.tests/zzio/db/TestIndexTable.cs +++ b/zzio.tests/zzio/db/TestIndexTable.cs @@ -14,12 +14,12 @@ public class TestIndexTable private void testIndexTable(IndexTable table) { Assert.NotNull(table); - Assert.AreEqual(3, table.ColumnCount); - Assert.AreEqual(3, table.columnNames.Length); - Assert.AreEqual(3, table.columnNumbers.Length); + Assert.That(table.ColumnCount, Is.EqualTo(3)); + Assert.That(table.columnNames.Length, Is.EqualTo(3)); + Assert.That(table.columnNumbers.Length, Is.EqualTo(3)); - Assert.AreEqual(new string[] { "Mesh", "Name", "CardId" }, table.columnNames); - Assert.AreEqual(new uint[] { 1, 2, 3 }, table.columnNumbers); + Assert.That(table.columnNames, Is.EqualTo(new string[] { "Mesh", "Name", "CardId" })); + Assert.That(table.columnNumbers, Is.EqualTo(new uint[] { 1, 2, 3 })); } [Test] diff --git a/zzio.tests/zzio/db/TestRow.cs b/zzio.tests/zzio/db/TestRow.cs index 58f1412f..b6b1f02b 100644 --- a/zzio.tests/zzio/db/TestRow.cs +++ b/zzio.tests/zzio/db/TestRow.cs @@ -21,12 +21,12 @@ public class TestRow private void testRow(Row row) { Assert.NotNull(row); - Assert.AreEqual(new UID(0xdeadbeef), row.uid); - Assert.AreEqual(3, row.cells.Length); + Assert.That(row.uid, Is.EqualTo(new UID(0xdeadbeef))); + Assert.That(row.cells.Length, Is.EqualTo(3)); - Assert.AreEqual(new Cell("zzio", 1), row.cells[0]); - Assert.AreEqual(new Cell((1 << 16) - 1, 2), row.cells[1]); - Assert.AreEqual(new Cell(new byte[] { 0xc0, 0xff, 0xee }, 3), row.cells[2]); + Assert.That(row.cells[0], Is.EqualTo(new Cell("zzio", 1))); + Assert.That(row.cells[1], Is.EqualTo(new Cell((1 << 16) - 1, 2))); + Assert.That(row.cells[2], Is.EqualTo(new Cell(new byte[] { 0xc0, 0xff, 0xee }, 3))); } [Test] @@ -55,6 +55,6 @@ public void write() MemoryStream stream = new(); using BinaryWriter writer = new(stream); row.Write(writer); - Assert.AreEqual(rowBytes, stream.ToArray()); + Assert.That(stream.ToArray(), Is.EqualTo(rowBytes)); } } diff --git a/zzio.tests/zzio/db/TestTable.cs b/zzio.tests/zzio/db/TestTable.cs index 7ac8dee6..a086eade 100644 --- a/zzio.tests/zzio/db/TestTable.cs +++ b/zzio.tests/zzio/db/TestTable.cs @@ -15,25 +15,25 @@ private void testTable(Table table) { Row row; Assert.NotNull(table); - Assert.AreEqual(3, table.rows.Count); + Assert.That(table.rows.Count, Is.EqualTo(3)); - Assert.True(table.rows.ContainsKey(new UID(0xdeadbeef))); + Assert.That(table.rows.ContainsKey(new UID(0xdeadbeef)), Is.True); row = table.rows[new UID(0xdeadbeef)]; - Assert.AreEqual(2, row.cells.Length); - Assert.AreEqual(new Cell("Zan", 1), row.cells[0]); - Assert.AreEqual(new Cell((byte)0x10, 2), row.cells[1]); + Assert.That(row.cells.Length, Is.EqualTo(2)); + Assert.That(row.cells[0], Is.EqualTo(new Cell("Zan", 1))); + Assert.That(row.cells[1], Is.EqualTo(new Cell((byte)0x10, 2))); - Assert.True(table.rows.ContainsKey(new UID(0xdabbad00))); + Assert.That(table.rows.ContainsKey(new UID(0xdabbad00)), Is.True); row = table.rows[new UID(0xdabbad00)]; - Assert.AreEqual(2, row.cells.Length); - Assert.AreEqual(new Cell("za", 1), row.cells[0]); - Assert.AreEqual(new Cell((byte)0x20, 2), row.cells[1]); + Assert.That(row.cells.Length, Is.EqualTo(2)); + Assert.That(row.cells[0], Is.EqualTo(new Cell("za", 1))); + Assert.That(row.cells[1], Is.EqualTo(new Cell((byte)0x20, 2))); - Assert.True(table.rows.ContainsKey(new UID(0x00bada2a))); + Assert.That(table.rows.ContainsKey(new UID(0x00bada2a)), Is.True); row = table.rows[new UID(0x00bada2a)]; - Assert.AreEqual(2, row.cells.Length); - Assert.AreEqual(new Cell("rah", 1), row.cells[0]); - Assert.AreEqual(new Cell((byte)0x30, 2), row.cells[1]); + Assert.That(row.cells.Length, Is.EqualTo(2)); + Assert.That(row.cells[0], Is.EqualTo(new Cell("rah", 1))); + Assert.That(row.cells[1], Is.EqualTo(new Cell((byte)0x30, 2))); } [Test] diff --git a/zzio.tests/zzio/primitives/TestCardId.cs b/zzio.tests/zzio/primitives/TestCardId.cs index 125d1bf5..ca0bb43e 100644 --- a/zzio.tests/zzio/primitives/TestCardId.cs +++ b/zzio.tests/zzio/primitives/TestCardId.cs @@ -9,44 +9,44 @@ public class TestCardId public void fromRaw() { CardId fairy0 = new(512); - Assert.AreEqual(512, fairy0.raw); - Assert.AreEqual(CardType.Fairy, fairy0.Type); - Assert.AreEqual(0, fairy0.EntityId); + Assert.That(fairy0.raw, Is.EqualTo(512)); + Assert.That(fairy0.Type, Is.EqualTo(CardType.Fairy)); + Assert.That(fairy0.EntityId, Is.EqualTo(0)); CardId fairy76 = new(4981248); - Assert.AreEqual(4981248, fairy76.raw); - Assert.AreEqual(CardType.Fairy, fairy76.Type); - Assert.AreEqual(76, fairy76.EntityId); + Assert.That(fairy76.raw, Is.EqualTo(4981248)); + Assert.That(fairy76.Type, Is.EqualTo(CardType.Fairy)); + Assert.That(fairy76.EntityId, Is.EqualTo(76)); CardId spell105 = new(6881536); - Assert.AreEqual(6881536, spell105.raw); - Assert.AreEqual(CardType.Spell, spell105.Type); - Assert.AreEqual(105, spell105.EntityId); + Assert.That(spell105.raw, Is.EqualTo(6881536)); + Assert.That(spell105.Type, Is.EqualTo(CardType.Spell)); + Assert.That(spell105.EntityId, Is.EqualTo(105)); } [Test] public void fromComponents() { CardId fairy0 = new(CardType.Fairy, 0); - Assert.AreEqual(512, fairy0.raw); + Assert.That(fairy0.raw, Is.EqualTo(512)); CardId fairy76 = new(CardType.Fairy, 76); - Assert.AreEqual(4981248, fairy76.raw); + Assert.That(fairy76.raw, Is.EqualTo(4981248)); CardId spell105 = new(CardType.Spell, 105); - Assert.AreEqual(6881536, spell105.raw); + Assert.That(spell105.raw, Is.EqualTo(6881536)); } [Test] public void toString() { CardId fairy0 = new(CardType.Fairy, 0); - Assert.AreEqual("Fairy:0", fairy0.ToString()); + Assert.That(fairy0.ToString(), Is.EqualTo("Fairy:0")); CardId item49 = new(CardType.Item, 49); - Assert.AreEqual("Item:49", item49.ToString()); + Assert.That(item49.ToString(), Is.EqualTo("Item:49")); CardId spell105 = new(6881536); - Assert.AreEqual("Spell:105", spell105.ToString()); + Assert.That(spell105.ToString(), Is.EqualTo("Spell:105")); } } \ No newline at end of file diff --git a/zzio.tests/zzio/primitives/TestFColor.cs b/zzio.tests/zzio/primitives/TestFColor.cs index 525a7dc1..f77edabf 100644 --- a/zzio.tests/zzio/primitives/TestFColor.cs +++ b/zzio.tests/zzio/primitives/TestFColor.cs @@ -17,10 +17,10 @@ public class TestFColor public void ctor() { FColor color = new(0.1f, 0.2f, 0.3f, 0.4f); - Assert.AreEqual(0.1f, color.r); - Assert.AreEqual(0.2f, color.g); - Assert.AreEqual(0.3f, color.b); - Assert.AreEqual(0.4f, color.a); + Assert.That(color.r, Is.EqualTo(0.1f)); + Assert.That(color.g, Is.EqualTo(0.2f)); + Assert.That(color.b, Is.EqualTo(0.3f)); + Assert.That(color.a, Is.EqualTo(0.4f)); } [Test] @@ -29,10 +29,10 @@ public void read() MemoryStream stream = new(expected, false); using BinaryReader reader = new(stream); FColor color = FColor.ReadNew(reader); - Assert.AreEqual(0.1f, color.r); - Assert.AreEqual(0.3f, color.g); - Assert.AreEqual(0.7f, color.b); - Assert.AreEqual(1.0f, color.a); + Assert.That(color.r, Is.EqualTo(0.1f)); + Assert.That(color.g, Is.EqualTo(0.3f)); + Assert.That(color.b, Is.EqualTo(0.7f)); + Assert.That(color.a, Is.EqualTo(1.0f)); } [Test] @@ -44,6 +44,6 @@ public void write() color.Write(writer); byte[] actual = stream.ToArray(); - Assert.AreEqual(actual, expected); + Assert.That(expected, Is.EqualTo(actual)); } } diff --git a/zzio.tests/zzio/primitives/TestIColor.cs b/zzio.tests/zzio/primitives/TestIColor.cs index 6c4031b2..66773a54 100644 --- a/zzio.tests/zzio/primitives/TestIColor.cs +++ b/zzio.tests/zzio/primitives/TestIColor.cs @@ -14,10 +14,10 @@ public class TestIColor public void ctor() { IColor color = new(1, 2, 3, 4); - Assert.AreEqual(1, color.r); - Assert.AreEqual(2, color.g); - Assert.AreEqual(3, color.b); - Assert.AreEqual(4, color.a); + Assert.That(color.r, Is.EqualTo(1)); + Assert.That(color.g, Is.EqualTo(2)); + Assert.That(color.b, Is.EqualTo(3)); + Assert.That(color.a, Is.EqualTo(4)); } [Test] @@ -26,10 +26,10 @@ public void read() MemoryStream stream = new(expected, false); using BinaryReader reader = new(stream); IColor color = IColor.ReadNew(reader); - Assert.AreEqual(0x12, color.r); - Assert.AreEqual(0x34, color.g); - Assert.AreEqual(0x56, color.b); - Assert.AreEqual(0x78, color.a); + Assert.That(color.r, Is.EqualTo(0x12)); + Assert.That(color.g, Is.EqualTo(0x34)); + Assert.That(color.b, Is.EqualTo(0x56)); + Assert.That(color.a, Is.EqualTo(0x78)); } [Test] @@ -41,6 +41,6 @@ public void write() color.Write(writer); byte[] actual = stream.ToArray(); - Assert.AreEqual(actual, expected); + Assert.That(expected, Is.EqualTo(actual)); } } diff --git a/zzio.tests/zzio/primitives/TestNormal.cs b/zzio.tests/zzio/primitives/TestNormal.cs index 90f897ec..795f1a80 100644 --- a/zzio.tests/zzio/primitives/TestNormal.cs +++ b/zzio.tests/zzio/primitives/TestNormal.cs @@ -15,10 +15,10 @@ public class TestNormal public void ctor() { Normal norm = new(1, 2, 3, 4); - Assert.AreEqual(1, norm.x); - Assert.AreEqual(2, norm.y); - Assert.AreEqual(3, norm.z); - Assert.AreEqual(4, norm.p); + Assert.That(norm.x, Is.EqualTo(1)); + Assert.That(norm.y, Is.EqualTo(2)); + Assert.That(norm.z, Is.EqualTo(3)); + Assert.That(norm.p, Is.EqualTo(4)); } [Test] @@ -27,10 +27,10 @@ public void read() MemoryStream stream = new(expected, false); using BinaryReader reader = new(stream); Normal norm = Normal.ReadNew(reader); - Assert.AreEqual(0x12, norm.x); - Assert.AreEqual(0x34, norm.y); - Assert.AreEqual(0x56, norm.z); - Assert.AreEqual(-123, norm.p); + Assert.That(norm.x, Is.EqualTo(0x12)); + Assert.That(norm.y, Is.EqualTo(0x34)); + Assert.That(norm.z, Is.EqualTo(0x56)); + Assert.That(norm.p, Is.EqualTo(-123)); } [Test] @@ -42,6 +42,6 @@ public void write() norm.Write(writer); byte[] actual = stream.ToArray(); - Assert.AreEqual(actual, expected); + Assert.That(expected, Is.EqualTo(actual)); } } diff --git a/zzio.tests/zzio/primitives/TestQuaternion.cs b/zzio.tests/zzio/primitives/TestQuaternion.cs index 053955a3..c8255cb0 100644 --- a/zzio.tests/zzio/primitives/TestQuaternion.cs +++ b/zzio.tests/zzio/primitives/TestQuaternion.cs @@ -18,10 +18,10 @@ public class TestQuaternion public void ctor() { Quaternion quat = new(0.1f, 0.2f, 0.3f, 0.4f); - Assert.AreEqual(0.1f, quat.X); - Assert.AreEqual(0.2f, quat.Y); - Assert.AreEqual(0.3f, quat.Z); - Assert.AreEqual(0.4f, quat.W); + Assert.That(quat.X, Is.EqualTo(0.1f)); + Assert.That(quat.Y, Is.EqualTo(0.2f)); + Assert.That(quat.Z, Is.EqualTo(0.3f)); + Assert.That(quat.W, Is.EqualTo(0.4f)); } [Test] @@ -30,10 +30,10 @@ public void read() MemoryStream stream = new(expected, false); using BinaryReader reader = new(stream); Quaternion quat = reader.ReadQuaternion(); - Assert.AreEqual(-345.0f, quat.X); - Assert.AreEqual(678.0f, quat.Y); - Assert.AreEqual(23.8f, quat.Z); - Assert.AreEqual(89.12f, quat.W); + Assert.That(quat.X, Is.EqualTo(-345.0f)); + Assert.That(quat.Y, Is.EqualTo(678.0f)); + Assert.That(quat.Z, Is.EqualTo(23.8f)); + Assert.That(quat.W, Is.EqualTo(89.12f)); } [Test] @@ -45,6 +45,6 @@ public void write() writer.Write(quat); byte[] actual = stream.ToArray(); - Assert.AreEqual(actual, expected); + Assert.That(expected, Is.EqualTo(actual)); } } diff --git a/zzio.tests/zzio/primitives/TestTexCoord.cs b/zzio.tests/zzio/primitives/TestTexCoord.cs index 10585bcd..a8b8c468 100644 --- a/zzio.tests/zzio/primitives/TestTexCoord.cs +++ b/zzio.tests/zzio/primitives/TestTexCoord.cs @@ -16,8 +16,8 @@ public class TestVector2 public void ctor() { Vector2 tex = new(0.1f, 0.2f); - Assert.AreEqual(0.1f, tex.X); - Assert.AreEqual(0.2f, tex.Y); + Assert.That(tex.X, Is.EqualTo(0.1f)); + Assert.That(tex.Y, Is.EqualTo(0.2f)); } [Test] @@ -26,8 +26,8 @@ public void read() MemoryStream stream = new(expected, false); using BinaryReader reader = new(stream); Vector2 tex = reader.ReadVector2(); - Assert.AreEqual(-345.0f, tex.X); - Assert.AreEqual(678.0f, tex.Y); + Assert.That(tex.X, Is.EqualTo(-345.0f)); + Assert.That(tex.Y, Is.EqualTo(678.0f)); } [Test] @@ -39,6 +39,6 @@ public void write() writer.Write(tex); byte[] actual = stream.ToArray(); - Assert.AreEqual(actual, expected); + Assert.That(expected, Is.EqualTo(actual)); } } diff --git a/zzio.tests/zzio/primitives/TestTriangle.cs b/zzio.tests/zzio/primitives/TestTriangle.cs index 81fef580..4e247a37 100644 --- a/zzio.tests/zzio/primitives/TestTriangle.cs +++ b/zzio.tests/zzio/primitives/TestTriangle.cs @@ -17,10 +17,10 @@ public class TestTriangle public void ctor() { VertexTriangle tri = new(1, 2, 3, 4); - Assert.AreEqual(1, tri.v1); - Assert.AreEqual(2, tri.v2); - Assert.AreEqual(3, tri.v3); - Assert.AreEqual(4, tri.m); + Assert.That(tri.v1, Is.EqualTo(1)); + Assert.That(tri.v2, Is.EqualTo(2)); + Assert.That(tri.v3, Is.EqualTo(3)); + Assert.That(tri.m, Is.EqualTo(4)); } [Test] @@ -29,10 +29,10 @@ public void read() MemoryStream stream = new(expected, false); using BinaryReader reader = new(stream); VertexTriangle tri = VertexTriangle.ReadNew(reader); - Assert.AreEqual(30806, tri.v1); - Assert.AreEqual(48282, tri.v2); - Assert.AreEqual(61662, tri.v3); - Assert.AreEqual(13330, tri.m); + Assert.That(tri.v1, Is.EqualTo(30806)); + Assert.That(tri.v2, Is.EqualTo(48282)); + Assert.That(tri.v3, Is.EqualTo(61662)); + Assert.That(tri.m, Is.EqualTo(13330)); } [Test] @@ -44,6 +44,6 @@ public void write() tri.Write(writer); byte[] actual = stream.ToArray(); - Assert.AreEqual(actual, expected); + Assert.That(expected, Is.EqualTo(actual)); } } diff --git a/zzio.tests/zzio/primitives/TestUID.cs b/zzio.tests/zzio/primitives/TestUID.cs index 1b2d1968..8d91938f 100644 --- a/zzio.tests/zzio/primitives/TestUID.cs +++ b/zzio.tests/zzio/primitives/TestUID.cs @@ -12,16 +12,16 @@ public void properties() UID nullUid = new(); UID uid = new(0xabcdef01); - Assert.AreEqual((uint)0, nullUid.raw); - Assert.AreEqual(0, nullUid.Module); - Assert.AreEqual(nullUid.GetHashCode(), nullUid.GetHashCode()); - Assert.AreEqual(nullUid.GetHashCode(), new UID().GetHashCode()); - Assert.AreEqual(nullUid.GetHashCode(), new UID(0).GetHashCode()); - - Assert.AreEqual(0xabcdef01, uid.raw); - Assert.AreEqual(1, uid.Module); - Assert.AreEqual(uid.GetHashCode(), uid.GetHashCode()); - Assert.AreEqual(uid.GetHashCode(), new UID(0xabcdef01).GetHashCode()); + Assert.That(nullUid.raw, Is.EqualTo((uint)0)); + Assert.That(nullUid.Module, Is.EqualTo(0)); + Assert.That(nullUid.GetHashCode(), Is.EqualTo(nullUid.GetHashCode())); + Assert.That(new UID().GetHashCode(), Is.EqualTo(nullUid.GetHashCode())); + Assert.That(new UID(0).GetHashCode(), Is.EqualTo(nullUid.GetHashCode())); + + Assert.That(uid.raw, Is.EqualTo(0xabcdef01)); + Assert.That(uid.Module, Is.EqualTo(1)); + Assert.That(uid.GetHashCode(), Is.EqualTo(uid.GetHashCode())); + Assert.That(new UID(0xabcdef01).GetHashCode(), Is.EqualTo(uid.GetHashCode())); } [Test] @@ -32,8 +32,8 @@ public void read() using BinaryReader reader = new(stream); UID uid = UID.ReadNew(reader); - Assert.AreEqual(0xdeadbeef, uid.raw); - Assert.AreEqual(0xf, uid.Module); + Assert.That(uid.raw, Is.EqualTo(0xdeadbeef)); + Assert.That(uid.Module, Is.EqualTo(0xf)); } [Test] @@ -44,20 +44,20 @@ public void write() UID uid = new(0xdeadbeef); uid.Write(writer); - Assert.AreEqual(new byte[] { 0xef, 0xbe, 0xad, 0xde }, stream.ToArray()); + Assert.That(stream.ToArray(), Is.EqualTo(new byte[] { 0xef, 0xbe, 0xad, 0xde })); } [Test] public void parse() { - Assert.AreEqual(0xdeadbeef, UID.Parse("DEADBEEF").raw); - Assert.AreEqual(0x0000affe, UID.Parse("affe").raw); + Assert.That(UID.Parse("DEADBEEF").raw, Is.EqualTo(0xdeadbeef)); + Assert.That(UID.Parse("affe").raw, Is.EqualTo(0x0000affe)); } [Test] public void tostring() { - Assert.AreEqual("DEADBEEF", new UID(0xdeadbeef).ToString()); - Assert.AreEqual("0000AFFE", new UID(0xaffe).ToString()); + Assert.That(new UID(0xdeadbeef).ToString(), Is.EqualTo("DEADBEEF")); + Assert.That(new UID(0xaffe).ToString(), Is.EqualTo("0000AFFE")); } } diff --git a/zzio.tests/zzio/primitives/TestVector.cs b/zzio.tests/zzio/primitives/TestVector.cs index 40ec365d..92ff316b 100644 --- a/zzio.tests/zzio/primitives/TestVector.cs +++ b/zzio.tests/zzio/primitives/TestVector.cs @@ -17,9 +17,9 @@ public class TestVector3 public void ctor() { Vector3 vec = new(0.1f, 0.2f, 0.3f); - Assert.AreEqual(0.1f, vec.X); - Assert.AreEqual(0.2f, vec.Y); - Assert.AreEqual(0.3f, vec.Z); + Assert.That(vec.X, Is.EqualTo(0.1f)); + Assert.That(vec.Y, Is.EqualTo(0.2f)); + Assert.That(vec.Z, Is.EqualTo(0.3f)); } [Test] @@ -28,9 +28,9 @@ public void read() MemoryStream stream = new(expected, false); using BinaryReader reader = new(stream); Vector3 vec = reader.ReadVector3(); - Assert.AreEqual(-345.0f, vec.X); - Assert.AreEqual(678.0f, vec.Y); - Assert.AreEqual(23.8f, vec.Z); + Assert.That(vec.X, Is.EqualTo(-345.0f)); + Assert.That(vec.Y, Is.EqualTo(678.0f)); + Assert.That(vec.Z, Is.EqualTo(23.8f)); } [Test] @@ -42,6 +42,6 @@ public void write() writer.Write(vec); byte[] actual = stream.ToArray(); - Assert.AreEqual(actual, expected); + Assert.That(expected, Is.EqualTo(actual)); } } diff --git a/zzio.tests/zzio/rwbs/basic.cs b/zzio.tests/zzio/rwbs/basic.cs index 9b71a6b8..47e2e0cf 100644 --- a/zzio.tests/zzio/rwbs/basic.cs +++ b/zzio.tests/zzio/rwbs/basic.cs @@ -14,45 +14,45 @@ public class TestRWBSBasic private void testSection(Section section) { - Assert.IsInstanceOf(typeof(RWClump), section); + Assert.That(section, Is.InstanceOf(typeof(RWClump))); RWClump clump = (RWClump)section; - Assert.AreEqual(SectionId.Clump, section.sectionId); - Assert.AreEqual(null, section.parent); - Assert.AreEqual(0, clump.atomicCount); - Assert.AreEqual(0, clump.camCount); - Assert.AreEqual(0, clump.lightCount); - Assert.AreEqual(3, clump.children.Count); + Assert.That(section.sectionId, Is.EqualTo(SectionId.Clump)); + Assert.That(section.parent, Is.EqualTo(null)); + Assert.That(clump.atomicCount, Is.EqualTo(0)); + Assert.That(clump.camCount, Is.EqualTo(0)); + Assert.That(clump.lightCount, Is.EqualTo(0)); + Assert.That(clump.children.Count, Is.EqualTo(3)); - Assert.IsInstanceOf(typeof(RWFrameList), clump.children[0]); + Assert.That(clump.children[0], Is.InstanceOf(typeof(RWFrameList))); RWFrameList frameList = (RWFrameList)clump.children[0]; - Assert.AreSame(clump, frameList.parent); - Assert.AreEqual(SectionId.FrameList, frameList.sectionId); - Assert.AreEqual(1, frameList.children.Count); - Assert.AreEqual(1, frameList.frames.Length); + Assert.That(frameList.parent, Is.SameAs(clump)); + Assert.That(frameList.sectionId, Is.EqualTo(SectionId.FrameList)); + Assert.That(frameList.children.Count, Is.EqualTo(1)); + Assert.That(frameList.frames.Length, Is.EqualTo(1)); Frame frame = frameList.frames[0]; - Assert.AreEqual(0, frame.creationFlags); - Assert.AreEqual(0xffffffff, frame.frameIndex); - Assert.AreEqual(Vector3.UnitX, frame.rotMatrix0); - Assert.AreEqual(Vector3.UnitY, frame.rotMatrix1); - Assert.AreEqual(Vector3.UnitZ, frame.rotMatrix2); - Assert.AreEqual(0.0f, frame.position.X); - Assert.AreEqual(0.0f, frame.position.Y); - Assert.AreEqual(0.0f, frame.position.Z); + Assert.That(frame.creationFlags, Is.EqualTo(0)); + Assert.That(frame.frameIndex, Is.EqualTo(0xffffffff)); + Assert.That(frame.rotMatrix0, Is.EqualTo(Vector3.UnitX)); + Assert.That(frame.rotMatrix1, Is.EqualTo(Vector3.UnitY)); + Assert.That(frame.rotMatrix2, Is.EqualTo(Vector3.UnitZ)); + Assert.That(frame.position.X, Is.EqualTo(0.0f)); + Assert.That(frame.position.Y, Is.EqualTo(0.0f)); + Assert.That(frame.position.Z, Is.EqualTo(0.0f)); - Assert.IsInstanceOf(typeof(RWExtension), frameList.children[0]); + Assert.That(frameList.children[0], Is.InstanceOf(typeof(RWExtension))); - Assert.IsInstanceOf(typeof(RWGeometryList), clump.children[1]); + Assert.That(clump.children[1], Is.InstanceOf(typeof(RWGeometryList))); RWGeometryList geoList = (RWGeometryList)clump.children[1]; - Assert.AreSame(clump, geoList.parent); - Assert.AreEqual(SectionId.GeometryList, geoList.sectionId); - Assert.AreEqual(0, geoList.children.Count); - Assert.AreEqual(0, geoList.geometryCount); + Assert.That(geoList.parent, Is.SameAs(clump)); + Assert.That(geoList.sectionId, Is.EqualTo(SectionId.GeometryList)); + Assert.That(geoList.children.Count, Is.EqualTo(0)); + Assert.That(geoList.geometryCount, Is.EqualTo(0)); - Assert.IsInstanceOf(typeof(RWExtension), clump.children[2]); + Assert.That(clump.children[2], Is.InstanceOf(typeof(RWExtension))); RWExtension extension = (RWExtension)clump.children[2]; - Assert.AreSame(clump, extension.parent); - Assert.AreEqual(0, extension.children.Count); + Assert.That(extension.parent, Is.SameAs(clump)); + Assert.That(extension.children.Count, Is.EqualTo(0)); } [Test] diff --git a/zzio.tests/zzio/scn/basic.cs b/zzio.tests/zzio/scn/basic.cs index 43f602f6..431105aa 100644 --- a/zzio.tests/zzio/scn/basic.cs +++ b/zzio.tests/zzio/scn/basic.cs @@ -13,25 +13,25 @@ public class TestSceneBasic private void testScene(Scene scn) { - Assert.AreEqual(12, scn.ambientSound); - - Assert.AreEqual("Helco", scn.version.author); - Assert.AreEqual(4, scn.version.buildVersion); - Assert.AreEqual(VersionBuildCountry.Germany, scn.version.country); - Assert.AreEqual("22.05.2018", scn.version.date); - Assert.AreEqual("15:56", scn.version.time); - Assert.AreEqual(VersionBuildType.Debug, scn.version.type); - Assert.AreEqual(0, scn.version.v3); - Assert.AreEqual(2, scn.version.vv2); - Assert.AreEqual(2018, scn.version.year); - - Assert.AreEqual(2, scn.sceneItems.Length); - Assert.AreEqual(2, scn.sceneItems[0].index); - Assert.AreEqual(4, scn.sceneItems[0].type); - Assert.AreEqual("", scn.sceneItems[0].name); - Assert.AreEqual(3, scn.sceneItems[1].index); - Assert.AreEqual(4, scn.sceneItems[1].type); - Assert.AreEqual("", scn.sceneItems[1].name); + Assert.That(scn.ambientSound, Is.EqualTo(12)); + + Assert.That(scn.version.author, Is.EqualTo("Helco")); + Assert.That(scn.version.buildVersion, Is.EqualTo(4)); + Assert.That(scn.version.country, Is.EqualTo(VersionBuildCountry.Germany)); + Assert.That(scn.version.date, Is.EqualTo("22.05.2018")); + Assert.That(scn.version.time, Is.EqualTo("15:56")); + Assert.That(scn.version.type, Is.EqualTo(VersionBuildType.Debug)); + Assert.That(scn.version.v3, Is.EqualTo(0)); + Assert.That(scn.version.vv2, Is.EqualTo(2)); + Assert.That(scn.version.year, Is.EqualTo(2018)); + + Assert.That(scn.sceneItems.Length, Is.EqualTo(2)); + Assert.That(scn.sceneItems[0].index, Is.EqualTo(2)); + Assert.That(scn.sceneItems[0].type, Is.EqualTo(4)); + Assert.That(scn.sceneItems[0].name, Is.EqualTo("")); + Assert.That(scn.sceneItems[1].index, Is.EqualTo(3)); + Assert.That(scn.sceneItems[1].type, Is.EqualTo(4)); + Assert.That(scn.sceneItems[1].name, Is.EqualTo("")); } [Test] diff --git a/zzio.tests/zzio/script/TestRawInstruction.cs b/zzio.tests/zzio/script/TestRawInstruction.cs index 64101203..76fc6530 100644 --- a/zzio.tests/zzio/script/TestRawInstruction.cs +++ b/zzio.tests/zzio/script/TestRawInstruction.cs @@ -38,28 +38,28 @@ public void syntax() [Test] public void command() { - Assert.AreEqual("a", new RawInstruction("a").Command); - Assert.AreEqual("a", new RawInstruction("a.bcd").Command); - Assert.AreEqual("a", new RawInstruction("a.bcd.\"def\"").Command); - Assert.AreEqual("setModel", new RawInstruction("setModel.f000w000").Command); - Assert.AreEqual(".", new RawInstruction(" .").Command); - Assert.AreEqual(".", new RawInstruction(" ..def").Command); - Assert.AreEqual("\"", new RawInstruction("\"").Command); - Assert.AreEqual("\"", new RawInstruction("\".ghi").Command); + Assert.That(new RawInstruction("a").Command, Is.EqualTo("a")); + Assert.That(new RawInstruction("a.bcd").Command, Is.EqualTo("a")); + Assert.That(new RawInstruction("a.bcd.\"def\"").Command, Is.EqualTo("a")); + Assert.That(new RawInstruction("setModel.f000w000").Command, Is.EqualTo("setModel")); + Assert.That(new RawInstruction(" .").Command, Is.EqualTo(".")); + Assert.That(new RawInstruction(" ..def").Command, Is.EqualTo(".")); + Assert.That(new RawInstruction("\"").Command, Is.EqualTo("\"")); + Assert.That(new RawInstruction("\".ghi").Command, Is.EqualTo("\"")); } [Test] public void arguments() { - Assert.AreEqual(0, new RawInstruction("a").Arguments.Length); + Assert.That(new RawInstruction("a").Arguments.Length, Is.EqualTo(0)); var args1 = new RawInstruction("a.abc").Arguments; - Assert.AreEqual(1, args1.Length); - Assert.AreEqual("abc", args1[0]); + Assert.That(args1.Length, Is.EqualTo(1)); + Assert.That(args1[0], Is.EqualTo("abc")); var args2 = new RawInstruction("a.\"def\\\"\\\\\\n\".abc").Arguments; - Assert.AreEqual(2, args2.Length); - Assert.AreEqual("def\"\\\n", args2[0]); - Assert.AreEqual("abc", args2[1]); + Assert.That(args2.Length, Is.EqualTo(2)); + Assert.That(args2[0], Is.EqualTo("def\"\\\n")); + Assert.That(args2[1], Is.EqualTo("abc")); } } diff --git a/zzio.tests/zzio/utils/TestBinaryIOExtension.cs b/zzio.tests/zzio/utils/TestBinaryIOExtension.cs index b59eb155..4cf116c2 100644 --- a/zzio.tests/zzio/utils/TestBinaryIOExtension.cs +++ b/zzio.tests/zzio/utils/TestBinaryIOExtension.cs @@ -29,7 +29,7 @@ public void ReadZString() { MemoryStream stream = new(expectedZString, false); using BinaryReader reader = new(stream); - Assert.AreEqual("Hello World!", reader.ReadZString()); + Assert.That(reader.ReadZString(), Is.EqualTo("Hello World!")); } [Test] @@ -38,7 +38,7 @@ public void WriteZString() MemoryStream stream = new(); using BinaryWriter writer = new(stream); writer.WriteZString("Hello World!"); - Assert.AreEqual(expectedZString, stream.ToArray()); + Assert.That(stream.ToArray(), Is.EqualTo(expectedZString)); } [Test] @@ -46,7 +46,7 @@ public void ReadSizedString() { MemoryStream stream = new(testCString, false); using BinaryReader reader = new(stream); - Assert.AreEqual("TestOh no", reader.ReadSizedString((int)stream.Length)); + Assert.That(reader.ReadSizedString((int)stream.Length), Is.EqualTo("TestOh no")); } [Test] @@ -54,8 +54,8 @@ public void ReadSizedCString() { MemoryStream stream = new(testCString, false); using BinaryReader reader = new(stream); - Assert.AreEqual("Test", reader.ReadSizedCString((int)stream.Length)); - Assert.AreEqual(stream.Position, stream.Length); + Assert.That(reader.ReadSizedCString((int)stream.Length), Is.EqualTo("Test")); + Assert.That(stream.Length, Is.EqualTo(stream.Position)); } [Test] @@ -64,11 +64,11 @@ public void WriteSizedString() MemoryStream stream = new(); BinaryWriter writer = new(stream); writer.WriteSizedCString("cstring", 8); - Assert.AreEqual(expectedCString, stream.ToArray()); + Assert.That(stream.ToArray(), Is.EqualTo(expectedCString)); stream = new MemoryStream(); writer = new BinaryWriter(stream); writer.WriteSizedCString("cstrings are the best", 8); - Assert.AreEqual(expectedCString, stream.ToArray()); + Assert.That(stream.ToArray(), Is.EqualTo(expectedCString)); } } diff --git a/zzio.tests/zzio/utils/TestEnumUtils.cs b/zzio.tests/zzio/utils/TestEnumUtils.cs index 0511f7fe..5a785b4d 100644 --- a/zzio.tests/zzio/utils/TestEnumUtils.cs +++ b/zzio.tests/zzio/utils/TestEnumUtils.cs @@ -25,19 +25,19 @@ private enum TestFlags [Test] public void intToEnum() { - Assert.AreEqual(TestEnum.A, EnumUtils.intToEnum(0)); - Assert.AreEqual(TestEnum.B, EnumUtils.intToEnum(100)); - Assert.AreEqual(TestEnum.Unknown, EnumUtils.intToEnum(200)); - Assert.AreEqual(TestEnum.Unknown, EnumUtils.intToEnum(-1)); + Assert.That(EnumUtils.intToEnum(0), Is.EqualTo(TestEnum.A)); + Assert.That(EnumUtils.intToEnum(100), Is.EqualTo(TestEnum.B)); + Assert.That(EnumUtils.intToEnum(200), Is.EqualTo(TestEnum.Unknown)); + Assert.That(EnumUtils.intToEnum(-1), Is.EqualTo(TestEnum.Unknown)); } [Test] public void intToFlags() { - Assert.AreEqual("0", EnumUtils.intToFlags(0).ToString()); - Assert.AreEqual("A", EnumUtils.intToFlags(1).ToString()); - Assert.AreEqual("A, B, C", EnumUtils.intToFlags(1 + 2 + 32).ToString()); - Assert.AreEqual("A, B", EnumUtils.intToFlags(1 + 2 + 4).ToString()); - Assert.AreEqual("0", EnumUtils.intToFlags(4 + 16).ToString()); + Assert.That(EnumUtils.intToFlags(0).ToString(), Is.EqualTo("0")); + Assert.That(EnumUtils.intToFlags(1).ToString(), Is.EqualTo("A")); + Assert.That(EnumUtils.intToFlags(1 + 2 + 32).ToString(), Is.EqualTo("A, B, C")); + Assert.That(EnumUtils.intToFlags(1 + 2 + 4).ToString(), Is.EqualTo("A, B")); + Assert.That(EnumUtils.intToFlags(4 + 16).ToString(), Is.EqualTo("0")); } } diff --git a/zzio.tests/zzio/utils/TestGatekeeperStream.cs b/zzio.tests/zzio/utils/TestGatekeeperStream.cs index fab406bc..54d6de3b 100644 --- a/zzio.tests/zzio/utils/TestGatekeeperStream.cs +++ b/zzio.tests/zzio/utils/TestGatekeeperStream.cs @@ -15,13 +15,13 @@ private void assertStreamClosed(bool expected, Stream stream) try { stream.Write(buffer, 0, 1); - Assert.AreEqual(1, stream.Read(buffer, 0, 1)); + Assert.That(stream.Read(buffer, 0, 1), Is.EqualTo(1)); } catch (Exception) { exceptionWasThrown = true; } - Assert.AreEqual(expected, exceptionWasThrown); + Assert.That(exceptionWasThrown, Is.EqualTo(expected)); } [Test] diff --git a/zzio.tests/zzio/utils/TestPath.cs b/zzio.tests/zzio/utils/TestPath.cs index 3edd409a..6fa507be 100644 --- a/zzio.tests/zzio/utils/TestPath.cs +++ b/zzio.tests/zzio/utils/TestPath.cs @@ -17,25 +17,25 @@ public void equals() { #pragma warning disable CS1718 FilePath path = new("a/b/c/d"); - Assert.AreEqual(true, path == new FilePath(path)); - Assert.AreEqual(true, path == "a/b/c/d"); - Assert.AreEqual(false, path.Equals("a/c/e/d")); - Assert.AreEqual(true, path == "A/B/c/d"); - Assert.AreEqual(false, path != "a/b/c/d"); - Assert.AreEqual(true, path != "a/c/e/d"); + Assert.That(path == new FilePath(path), Is.EqualTo(true)); + Assert.That(path == "a/b/c/d", Is.EqualTo(true)); + Assert.That(path.Equals("a/c/e/d"), Is.EqualTo(false)); + Assert.That(path == "A/B/c/d", Is.EqualTo(true)); + Assert.That(path != "a/b/c/d", Is.EqualTo(false)); + Assert.That(path != "a/c/e/d", Is.EqualTo(true)); - Assert.AreEqual(true, path.Equals("A/b/C/d", false)); - Assert.AreEqual(false, path.Equals("a/b/C/D", true)); + Assert.That(path.Equals("A/b/C/d", false), Is.EqualTo(true)); + Assert.That(path.Equals("a/b/C/D", true), Is.EqualTo(false)); - Assert.AreEqual(true, path.Equals("a/../a/b/.//c///d\\e/..")); - Assert.AreEqual(false, path.Equals("a/b/c/d/../e/")); + Assert.That(path.Equals("a/../a/b/.//c///d\\e/.."), Is.EqualTo(true)); + Assert.That(path.Equals("a/b/c/d/../e/"), Is.EqualTo(false)); FilePath? nullPath = null; - Assert.AreEqual(false, nullPath == "a/b"); - Assert.AreEqual(true, nullPath != "a/b"); - Assert.AreEqual(true, nullPath == nullPath); - Assert.AreEqual(false, new FilePath("a/b") == nullPath); - Assert.AreEqual(true, new FilePath("a/b") != nullPath); + Assert.That(nullPath == "a/b", Is.EqualTo(false)); + Assert.That(nullPath != "a/b", Is.EqualTo(true)); + Assert.That(nullPath == nullPath, Is.EqualTo(true)); + Assert.That(new FilePath("a/b") == nullPath, Is.EqualTo(false)); + Assert.That(new FilePath("a/b") != nullPath, Is.EqualTo(true)); #pragma warning restore CS1718 } @@ -43,23 +43,22 @@ public void equals() [Test] public void root() { - Assert.AreEqual("c:", new FilePath("c:/a/b").Root); - Assert.AreEqual("/", new FilePath("/d/e/f/").Root); - Assert.AreEqual("def:/", new FilePath("def:").Root); - Assert.AreEqual("/", new FilePath("/").Root); - Assert.AreEqual("pak:/", new FilePath("pak:/").Root); - - Assert.AreEqual( - Env(Environment.CurrentDirectory.Substring(0, 1) + ":\\", "/"), + Assert.That(new FilePath("c:/a/b").Root, Is.EqualTo("c:")); + Assert.That(new FilePath("/d/e/f/").Root, Is.EqualTo("/")); + Assert.That(new FilePath("def:").Root, Is.EqualTo("def:/")); + Assert.That(new FilePath("/").Root, Is.EqualTo("/")); + Assert.That(new FilePath("pak:/").Root, Is.EqualTo("pak:/")); + + Assert.That( new FilePath("./a\\b/c").Root - ); +, Is.EqualTo(Env(Environment.CurrentDirectory.Substring(0, 1) + ":\\", "/"))); } [Test] public void combine() { - Assert.AreEqual("a/b/c/d/", new FilePath("a/b").Combine(new FilePath("c/d/"))); - Assert.AreEqual("../b/c", new FilePath("a").Combine(new FilePath("../../b/c"))); + Assert.That(new FilePath("a/b").Combine(new FilePath("c/d/")), Is.EqualTo("a/b/c/d/")); + Assert.That(new FilePath("a").Combine(new FilePath("../../b/c")), Is.EqualTo("../b/c")); Assert.That(() => new FilePath("a/b").Combine("/c"), Throws.Exception); Assert.That(() => new FilePath("a/b").Combine("hello:\\"), Throws.Exception); @@ -68,64 +67,64 @@ public void combine() [Test] public void absolute() { - Assert.AreEqual("c:/a/b/", new FilePath("c:/a/b/c/../").Absolute.ToPOSIXString()); - Assert.AreEqual("/b/c/d", new FilePath("/b/./././/c/d").Absolute.ToPOSIXString()); + Assert.That(new FilePath("c:/a/b/c/../").Absolute.ToPOSIXString(), Is.EqualTo("c:/a/b/")); + Assert.That(new FilePath("/b/./././/c/d").Absolute.ToPOSIXString(), Is.EqualTo("/b/c/d")); string cur = Environment.CurrentDirectory; if (!cur.EndsWith(FilePath.Separator)) cur += FilePath.Separator; - Assert.AreEqual(cur + "a", new FilePath("a").Absolute); - Assert.AreEqual(cur + "a", new FilePath("./b/..\\a").Absolute); + Assert.That(new FilePath("a").Absolute, Is.EqualTo(cur + "a")); + Assert.That(new FilePath("./b/..\\a").Absolute, Is.EqualTo(cur + "a")); } [Test] public void parts() { - Assert.AreEqual(new string[] { "a", "b", "C" }, new FilePath("a/b\\C/").Parts); - Assert.AreEqual(new string[] { "c:", "d" }, new FilePath("c:\\d").Parts); - Assert.AreEqual(new string[] { "e", "f" }, new FilePath("/e/f").Parts); + Assert.That(new FilePath("a/b\\C/").Parts, Is.EqualTo(new string[] { "a", "b", "C" })); + Assert.That(new FilePath("c:\\d").Parts, Is.EqualTo(new string[] { "c:", "d" })); + Assert.That(new FilePath("/e/f").Parts, Is.EqualTo(new string[] { "e", "f" })); } [Test] public void staysinbound() { - Assert.True(new FilePath("a/b/c").StaysInbound); - Assert.True(new FilePath("a/b/../").StaysInbound); - Assert.True(new FilePath("a/../").StaysInbound); - Assert.True(new FilePath("c:/d/../").StaysInbound); - Assert.True(new FilePath("/d/..").StaysInbound); - Assert.False(new FilePath("a/../../").StaysInbound); - Assert.False(new FilePath("..").StaysInbound); - Assert.False(new FilePath("c:/..").StaysInbound); - Assert.False(new FilePath("/../").StaysInbound); + Assert.That(new FilePath("a/b/c").StaysInbound, Is.True); + Assert.That(new FilePath("a/b/../").StaysInbound, Is.True); + Assert.That(new FilePath("a/../").StaysInbound, Is.True); + Assert.That(new FilePath("c:/d/../").StaysInbound, Is.True); + Assert.That(new FilePath("/d/..").StaysInbound, Is.True); + Assert.That(new FilePath("a/../../").StaysInbound, Is.False); + Assert.That(new FilePath("..").StaysInbound, Is.False); + Assert.That(new FilePath("c:/..").StaysInbound, Is.False); + Assert.That(new FilePath("/../").StaysInbound, Is.False); } [Test] public void parent() { FilePath? path = new("a/b/c"); - Assert.AreEqual("a/b/", (path = path?.Parent)); - Assert.AreEqual("a/", (path = path?.Parent)); - Assert.AreEqual("./", (path = path?.Parent)); - Assert.AreEqual("../", (path = path?.Parent)); - Assert.AreEqual("../../", (path = path?.Parent)); + Assert.That((path = path?.Parent), Is.EqualTo("a/b/")); + Assert.That((path = path?.Parent), Is.EqualTo("a/")); + Assert.That((path = path?.Parent), Is.EqualTo("./")); + Assert.That((path = path?.Parent), Is.EqualTo("../")); + Assert.That((path = path?.Parent), Is.EqualTo("../../")); - Assert.AreEqual("a/", new FilePath("a/b/../c/.//").Parent); + Assert.That(new FilePath("a/b/../c/.//").Parent, Is.EqualTo("a/")); - Assert.AreEqual("c:", new FilePath("c:/a").Parent); - Assert.AreEqual(null, new FilePath("c:/a/").Parent?.Parent); + Assert.That(new FilePath("c:/a").Parent, Is.EqualTo("c:")); + Assert.That(new FilePath("c:/a/").Parent?.Parent, Is.EqualTo(null)); - Assert.AreEqual("/d", new FilePath("/d/e").Parent); - Assert.AreEqual(null, new FilePath("/d/e").Parent?.Parent); + Assert.That(new FilePath("/d/e").Parent, Is.EqualTo("/d")); + Assert.That(new FilePath("/d/e").Parent?.Parent, Is.EqualTo(null)); } [Test] public void relativeto() { - Assert.AreEqual("c/d", new FilePath("a/b/c/d").RelativeTo("a/b")); - Assert.AreEqual("../../c/d/", new FilePath("a/b/c/d/").RelativeTo("a/b/e/f")); - Assert.AreEqual("../../", new FilePath("a/b").RelativeTo("a/b/c/d")); - Assert.AreEqual("", new FilePath("").RelativeTo("")); + Assert.That(new FilePath("a/b/c/d").RelativeTo("a/b"), Is.EqualTo("c/d")); + Assert.That(new FilePath("a/b/c/d/").RelativeTo("a/b/e/f"), Is.EqualTo("../../c/d/")); + Assert.That(new FilePath("a/b").RelativeTo("a/b/c/d"), Is.EqualTo("../../")); + Assert.That(new FilePath("").RelativeTo(""), Is.EqualTo("")); Assert.That(() => new FilePath("/a/b/c").RelativeTo("c:/d/e"), Throws.Exception); Assert.That(() => new FilePath("c:/d/e").RelativeTo("d:/e/f"), Throws.Exception); @@ -135,39 +134,39 @@ public void relativeto() [Test] public void tostring() { - Assert.AreEqual("c:\\a\\b\\", new FilePath("c:/a\\b/").ToWin32String()); - Assert.AreEqual("a\\..\\b\\c", new FilePath("a/../b\\c").ToWin32String()); + Assert.That(new FilePath("c:/a\\b/").ToWin32String(), Is.EqualTo("c:\\a\\b\\")); + Assert.That(new FilePath("a/../b\\c").ToWin32String(), Is.EqualTo("a\\..\\b\\c")); - Assert.AreEqual("/a/b/c/", new FilePath("\\a\\b\\c/").ToPOSIXString()); - Assert.AreEqual("c/d/e", new FilePath("c\\d/e").ToPOSIXString()); + Assert.That(new FilePath("\\a\\b\\c/").ToPOSIXString(), Is.EqualTo("/a/b/c/")); + Assert.That(new FilePath("c\\d/e").ToPOSIXString(), Is.EqualTo("c/d/e")); - Assert.AreEqual(Env("a\\b\\c", "a/b/c"), new FilePath("a\\b/c").ToString()); + Assert.That(new FilePath("a\\b/c").ToString(), Is.EqualTo(Env("a\\b\\c", "a/b/c"))); } [Test] public void gethashcode() { - Assert.AreEqual(new FilePath("").GetHashCode(), new FilePath("").GetHashCode()); - Assert.AreEqual(new FilePath("/a/b/c").GetHashCode(), new FilePath("/a/b/c").GetHashCode()); - Assert.AreNotEqual(new FilePath("c:/d/e").GetHashCode(), new FilePath("d\\b/c").GetHashCode()); - Assert.AreEqual(new FilePath("").GetHashCode(), new FilePath(".").GetHashCode()); - Assert.AreEqual(new FilePath("a/").GetHashCode(), new FilePath("a").GetHashCode()); - Assert.AreEqual(new FilePath("a").GetHashCode(), new FilePath("a/b/./c/../././../").GetHashCode()); + Assert.That(new FilePath("").GetHashCode(), Is.EqualTo(new FilePath("").GetHashCode())); + Assert.That(new FilePath("/a/b/c").GetHashCode(), Is.EqualTo(new FilePath("/a/b/c").GetHashCode())); + Assert.That(new FilePath("d\\b/c").GetHashCode(), Is.Not.EqualTo(new FilePath("c:/d/e").GetHashCode())); + Assert.That(new FilePath(".").GetHashCode(), Is.EqualTo(new FilePath("").GetHashCode())); + Assert.That(new FilePath("a").GetHashCode(), Is.EqualTo(new FilePath("a/").GetHashCode())); + Assert.That(new FilePath("a/b/./c/../././../").GetHashCode(), Is.EqualTo(new FilePath("a").GetHashCode())); } [Test] public void extension() { - Assert.IsNull(new FilePath("").Extension); - Assert.IsNull(new FilePath("/").Extension); - Assert.IsNull(new FilePath("resources/").Extension); - Assert.IsNull(new FilePath("a/b.cdef/g").Extension); - Assert.IsNull(new FilePath("a/b.").Extension); - - Assert.AreEqual("txt", new FilePath("a.txt").Extension); - Assert.AreEqual("txt", new FilePath("c:/b.cedf/asd/a.txt").Extension); - Assert.AreEqual("txt", new FilePath("c:/b.cedf/asd/a.qwe.rtz.yxc.txt").Extension); - Assert.AreEqual("t", new FilePath("c:/b.cedf/asd/a.qwe.rtz.yxc.t").Extension); - Assert.AreEqual("abcdefghijkl", new FilePath("c:/b.cedf/asd/a.qwe.rtz.yxc.abcdefghijkl").Extension); + Assert.That(new FilePath("").Extension, Is.Null); + Assert.That(new FilePath("/").Extension, Is.Null); + Assert.That(new FilePath("resources/").Extension, Is.Null); + Assert.That(new FilePath("a/b.cdef/g").Extension, Is.Null); + Assert.That(new FilePath("a/b.").Extension, Is.Null); + + Assert.That(new FilePath("a.txt").Extension, Is.EqualTo("txt")); + Assert.That(new FilePath("c:/b.cedf/asd/a.txt").Extension, Is.EqualTo("txt")); + Assert.That(new FilePath("c:/b.cedf/asd/a.qwe.rtz.yxc.txt").Extension, Is.EqualTo("txt")); + Assert.That(new FilePath("c:/b.cedf/asd/a.qwe.rtz.yxc.t").Extension, Is.EqualTo("t")); + Assert.That(new FilePath("c:/b.cedf/asd/a.qwe.rtz.yxc.abcdefghijkl").Extension, Is.EqualTo("abcdefghijkl")); } } diff --git a/zzio.tests/zzio/utils/TestRangeStream.cs b/zzio.tests/zzio/utils/TestRangeStream.cs index 7042d34e..b19ede37 100644 --- a/zzio.tests/zzio/utils/TestRangeStream.cs +++ b/zzio.tests/zzio/utils/TestRangeStream.cs @@ -24,15 +24,15 @@ public void read() byte[] part1 = new byte[3]; int part1Len = rangeStream.Read(part1, 0, 3); - Assert.AreEqual(3, part1Len); - Assert.AreEqual(0x01, part1[0]); - Assert.AreEqual(0x02, part1[1]); - Assert.AreEqual(0x03, part1[2]); + Assert.That(part1Len, Is.EqualTo(3)); + Assert.That(part1[0], Is.EqualTo(0x01)); + Assert.That(part1[1], Is.EqualTo(0x02)); + Assert.That(part1[2], Is.EqualTo(0x03)); byte[] part2 = new byte[4]; int part2Len = rangeStream.Read(part2, 1, 3); - Assert.AreEqual(1, part2Len); - Assert.AreEqual(0x04, part2[1]); + Assert.That(part2Len, Is.EqualTo(1)); + Assert.That(part2[1], Is.EqualTo(0x04)); } [Test] @@ -50,7 +50,7 @@ public void write() expected[testDataOffset + 3] = 0x40; rangeStream.Write(expected, testDataOffset, testDataLength); - Assert.AreEqual(expected, actual); + Assert.That(actual, Is.EqualTo(expected)); } [Test] @@ -60,14 +60,14 @@ public void seek() memStream.Seek(testDataOffset, SeekOrigin.Current); RangeStream rangeStream = new(memStream, testDataLength); - Assert.AreEqual(testData[testDataOffset + 0], rangeStream.ReadByte()); + Assert.That(rangeStream.ReadByte(), Is.EqualTo(testData[testDataOffset + 0])); rangeStream.Position += 2; - Assert.AreEqual(testData[testDataOffset + 3], rangeStream.ReadByte()); - Assert.AreEqual(0, rangeStream.Seek(0, SeekOrigin.Begin)); - Assert.AreEqual(testData[testDataOffset + 0], rangeStream.ReadByte()); - Assert.AreEqual(2, rangeStream.Seek(1, SeekOrigin.Current)); - Assert.AreEqual(testData[testDataOffset + 2], rangeStream.ReadByte()); - Assert.AreEqual(1, rangeStream.Seek(-3, SeekOrigin.End)); - Assert.AreEqual(testData[testDataOffset + 1], rangeStream.ReadByte()); + Assert.That(rangeStream.ReadByte(), Is.EqualTo(testData[testDataOffset + 3])); + Assert.That(rangeStream.Seek(0, SeekOrigin.Begin), Is.EqualTo(0)); + Assert.That(rangeStream.ReadByte(), Is.EqualTo(testData[testDataOffset + 0])); + Assert.That(rangeStream.Seek(1, SeekOrigin.Current), Is.EqualTo(2)); + Assert.That(rangeStream.ReadByte(), Is.EqualTo(testData[testDataOffset + 2])); + Assert.That(rangeStream.Seek(-3, SeekOrigin.End), Is.EqualTo(1)); + Assert.That(rangeStream.ReadByte(), Is.EqualTo(testData[testDataOffset + 1])); } } diff --git a/zzio.tests/zzio/utils/TestStringUtils.cs b/zzio.tests/zzio/utils/TestStringUtils.cs index 312f4be2..bcb00eb1 100644 --- a/zzio.tests/zzio/utils/TestStringUtils.cs +++ b/zzio.tests/zzio/utils/TestStringUtils.cs @@ -8,18 +8,18 @@ public class TestStringUtils [Test] public void escape() { - Assert.AreEqual("abcdef", StringUtils.Escape("abcdef")); - Assert.AreEqual("abc\\ndef", StringUtils.Escape("abc\ndef")); - Assert.AreEqual("abc\\xF6def", StringUtils.Escape("abcödef")); - Assert.AreEqual("a\\x16\\n\\r\\\\\\'\\\"", StringUtils.Escape("a\x16\n\r\\\'\"")); + Assert.That(StringUtils.Escape("abcdef"), Is.EqualTo("abcdef")); + Assert.That(StringUtils.Escape("abc\ndef"), Is.EqualTo("abc\\ndef")); + Assert.That(StringUtils.Escape("abcödef"), Is.EqualTo("abc\\xF6def")); + Assert.That(StringUtils.Escape("a\x16\n\r\\\'\""), Is.EqualTo("a\\x16\\n\\r\\\\\\'\\\"")); } [Test] public void unescape() { - Assert.AreEqual("abcdef", StringUtils.Unescape("abcdef")); - Assert.AreEqual("abc\ndef", StringUtils.Unescape("abc\\ndef")); - Assert.AreEqual("abcödef", StringUtils.Unescape("abc\\xF6def")); - Assert.AreEqual("a\x23\n\r\\\'\"", StringUtils.Unescape("a\\x23\\n\\r\\\\\\'\\\"")); + Assert.That(StringUtils.Unescape("abcdef"), Is.EqualTo("abcdef")); + Assert.That(StringUtils.Unescape("abc\\ndef"), Is.EqualTo("abc\ndef")); + Assert.That(StringUtils.Unescape("abc\\xF6def"), Is.EqualTo("abcödef")); + Assert.That(StringUtils.Unescape("a\\x23\\n\\r\\\\\\'\\\""), Is.EqualTo("a\x23\n\r\\\'\"")); } } diff --git a/zzio.tests/zzio/vfs/TestCommonResourcePool.cs b/zzio.tests/zzio/vfs/TestCommonResourcePool.cs index 6a9c9fed..2aec72c7 100644 --- a/zzio.tests/zzio/vfs/TestCommonResourcePool.cs +++ b/zzio.tests/zzio/vfs/TestCommonResourcePool.cs @@ -24,19 +24,19 @@ void visit(IResource res) [Test, Combinatorial] public void rootIsDirectory([ValueSource(nameof(testPools))] IResourcePool pool) { - Assert.AreEqual(ResourceType.Directory, pool.Root.Type); + Assert.That(pool.Root.Type, Is.EqualTo(ResourceType.Directory)); } [Test, Combinatorial] public void rootHasNoParent([ValueSource(nameof(testPools))] IResourcePool pool) { - Assert.IsNull(pool.Root.Parent); + Assert.That(pool.Root.Parent, Is.Null); } [Test, Combinatorial] public void rootHasEmptyPath([ValueSource(nameof(testPools))] IResourcePool pool) { - Assert.AreEqual("", pool.Root.Path.ToString()); + Assert.That(pool.Root.Path.ToString(), Is.EqualTo("")); } [Test, Combinatorial] @@ -55,16 +55,16 @@ public void enumeratorVsSplit([ValueSource(nameof(testPools))] IResourcePool poo public void resourcesTypesInSplit([ValueSource(nameof(testPools))] IResourcePool pool) => VisitResources(pool, res => { foreach (var file in res.Files) - Assert.AreEqual(ResourceType.File, file.Type); + Assert.That(file.Type, Is.EqualTo(ResourceType.File)); foreach (var dir in res.Directories) - Assert.AreEqual(ResourceType.Directory, dir.Type); + Assert.That(dir.Type, Is.EqualTo(ResourceType.Directory)); }); [Test, Combinatorial] public void parentIsSetCorrectly([ValueSource(nameof(testPools))] IResourcePool pool) => VisitResources(pool, res => { foreach (var child in res) - Assert.AreEqual(res, child.Parent); + Assert.That(child.Parent, Is.EqualTo(res)); }); [Test, Combinatorial] @@ -74,10 +74,10 @@ public void openContent([ValueSource(nameof(testPools))] IResourcePool pool) => if (res.Type == ResourceType.File) { Assert.IsNotNull(stream); - Assert.IsTrue(stream!.CanRead); + Assert.That(stream!.CanRead); } else - Assert.IsNull(stream); + Assert.That(stream, Is.Null); }); [Test, Combinatorial] diff --git a/zzio.tests/zzio/vfs/TestEndpointResourcePool.cs b/zzio.tests/zzio/vfs/TestEndpointResourcePool.cs index 52afbe61..50106c87 100644 --- a/zzio.tests/zzio/vfs/TestEndpointResourcePool.cs +++ b/zzio.tests/zzio/vfs/TestEndpointResourcePool.cs @@ -25,7 +25,7 @@ void visit(IResource res) [Test, Combinatorial] public void endpointPoolIsSetCorrectly([ValueSource(nameof(testPools))] IResourcePool pool) => VisitResources(pool, res => { - Assert.AreSame(pool, res.Pool); + Assert.That(res.Pool, Is.SameAs(pool)); }); [Test, Combinatorial] diff --git a/zzio.tests/zzio/vfs/TestIResourceExtensions.cs b/zzio.tests/zzio/vfs/TestIResourceExtensions.cs index 028ed2b1..26ee08d2 100644 --- a/zzio.tests/zzio/vfs/TestIResourceExtensions.cs +++ b/zzio.tests/zzio/vfs/TestIResourceExtensions.cs @@ -14,7 +14,7 @@ public void findAndOpen() MyAssert.Equals("common from b", pool.FindAndOpen("COMMON/CONTENT.txt")); MyAssert.Equals("from b", pool.FindAndOpen("content.txt")); - Assert.IsNull(pool.FindAndOpen("common/c.txt")); - Assert.IsNull(pool.FindAndOpen("hello.txt")); + Assert.That(pool.FindAndOpen("common/c.txt"), Is.Null); + Assert.That(pool.FindAndOpen("hello.txt"), Is.Null); } } diff --git a/zzre.core.tests/TestExtendedTagContainer.cs b/zzre.core.tests/TestExtendedTagContainer.cs index cb058139..ed6081e1 100644 --- a/zzre.core.tests/TestExtendedTagContainer.cs +++ b/zzre.core.tests/TestExtendedTagContainer.cs @@ -29,23 +29,23 @@ public void Setup() [Test] public void HasAllTags() { - Assert.IsTrue(container.HasTag()); - Assert.IsTrue(container.HasTag()); - Assert.IsTrue(container.HasTag()); + Assert.That(container.HasTag()); + Assert.That(container.HasTag()); + Assert.That(container.HasTag()); } [Test] public void HasOverwrittenTagFromParent() { - Assert.IsTrue(container.HasTag()); - Assert.AreSame(container.GetTag(), container.GetTag()); + Assert.That(container.HasTag()); + Assert.That(container.GetTag(), Is.SameAs(container.GetTag())); } [Test] public void GetTagsTakesFromBoth() { var tags = container.GetTags(); - Assert.AreEqual(2, tags.Count()); + Assert.That(tags.Count(), Is.EqualTo(2)); var tagTypes = tags.Select(t => t.GetType()); Assert.That(tagTypes, Is.EquivalentTo(new Type[] { typeof(SubTag1Of1), typeof(SubTag2Of1) })); } @@ -54,14 +54,14 @@ public void GetTagsTakesFromBoth() public void AddTagDoesNotModifyParent() { container.AddTag(new Tag4()); - Assert.IsTrue(container.HasTag()); - Assert.IsFalse(parentContainer.HasTag()); + Assert.That(container.HasTag()); + Assert.That(parentContainer.HasTag(), Is.False); } [Test] public void RemoveTagDoesNotModifyParent() { - Assert.IsFalse(container.RemoveTag()); - Assert.IsTrue(parentContainer.HasTag()); + Assert.That(container.RemoveTag(), Is.False); + Assert.That(parentContainer.HasTag()); } } diff --git a/zzre.core.tests/TestFallbackTagContainer.cs b/zzre.core.tests/TestFallbackTagContainer.cs index fff204c7..3cc661a2 100644 --- a/zzre.core.tests/TestFallbackTagContainer.cs +++ b/zzre.core.tests/TestFallbackTagContainer.cs @@ -33,23 +33,23 @@ public void Setup() [Test] public void HasAllTags() { - Assert.IsTrue(container.HasTag()); - Assert.IsTrue(container.HasTag()); - Assert.IsTrue(container.HasTag()); + Assert.That(container.HasTag()); + Assert.That(container.HasTag()); + Assert.That(container.HasTag()); } [Test] public void HasOverwrittenTagFromParent() { - Assert.IsTrue(container.HasTag()); - Assert.AreSame(container.GetTag(), container.GetTag()); + Assert.That(container.HasTag()); + Assert.That(container.GetTag(), Is.SameAs(container.GetTag())); } [Test] public void GetTagsTakesFromBoth() { var tags = container.GetTags(); - Assert.AreEqual(2, tags.Count()); + Assert.That(tags.Count(), Is.EqualTo(2)); var tagTypes = tags.Select(t => t.GetType()); Assert.That(tagTypes, Is.EquivalentTo(new Type[] { typeof(SubTag1Of1), typeof(SubTag2Of1) })); } diff --git a/zzre.core.tests/TestLocation.cs b/zzre.core.tests/TestLocation.cs index d8aa0d7b..80128881 100644 --- a/zzre.core.tests/TestLocation.cs +++ b/zzre.core.tests/TestLocation.cs @@ -55,9 +55,9 @@ public void ParentToLocal() location.ParentToLocal = location.ParentToLocal; var actPoint = Vector3.Transform(origPoint, location.LocalToWorld); - Assert.AreEqual(expPoint.X, actPoint.X, EPS); - Assert.AreEqual(expPoint.Y, actPoint.Y, EPS); - Assert.AreEqual(expPoint.Z, actPoint.Z, EPS); + Assert.That(actPoint.X, Is.EqualTo(expPoint.X).Within(EPS)); + Assert.That(actPoint.Y, Is.EqualTo(expPoint.Y).Within(EPS)); + Assert.That(actPoint.Z, Is.EqualTo(expPoint.Z).Within(EPS)); } [Test] @@ -69,9 +69,9 @@ public void LocalToWorldToLocal() var newPoint = Vector3.Transform(prevPoint, location.LocalToWorld); newPoint = Vector3.Transform(newPoint, location.WorldToLocal); - Assert.AreEqual(prevPoint.X, newPoint.X, EPS); - Assert.AreEqual(prevPoint.Y, newPoint.Y, EPS); - Assert.AreEqual(prevPoint.Z, newPoint.Z, EPS); + Assert.That(newPoint.X, Is.EqualTo(prevPoint.X).Within(EPS)); + Assert.That(newPoint.Y, Is.EqualTo(prevPoint.Y).Within(EPS)); + Assert.That(newPoint.Z, Is.EqualTo(prevPoint.Z).Within(EPS)); } [Test] @@ -92,9 +92,9 @@ public void RebuiltHierachy() var expPoint = Vector3.Transform(origPoint, final.LocalToWorld); var actPoint = Vector3.Transform(origPoint, part3.LocalToWorld); - Assert.AreEqual(expPoint.X, actPoint.X, EPS * 10); - Assert.AreEqual(expPoint.Y, actPoint.Y, EPS * 10); - Assert.AreEqual(expPoint.Z, actPoint.Z, EPS * 10); + Assert.That(actPoint.X, Is.EqualTo(expPoint.X).Within(EPS * 10)); + Assert.That(actPoint.Y, Is.EqualTo(expPoint.Y).Within(EPS * 10)); + Assert.That(actPoint.Z, Is.EqualTo(expPoint.Z).Within(EPS * 10)); } [Test] @@ -107,9 +107,9 @@ public void SettingWorldToLocal() location.LocalToWorld = location.LocalToWorld; var actPoint = Vector3.Transform(origPoint, location.LocalToWorld); - Assert.AreEqual(expPoint.X, actPoint.X, EPS * 10); - Assert.AreEqual(expPoint.Y, actPoint.Y, EPS * 10); - Assert.AreEqual(expPoint.Z, actPoint.Z, EPS * 10); + Assert.That(actPoint.X, Is.EqualTo(expPoint.X).Within(EPS * 10)); + Assert.That(actPoint.Y, Is.EqualTo(expPoint.Y).Within(EPS * 10)); + Assert.That(actPoint.Z, Is.EqualTo(expPoint.Z).Within(EPS * 10)); } [Test] @@ -122,8 +122,8 @@ public void SettingLocalToWorld() location.WorldToLocal = location.WorldToLocal; var actPoint = Vector3.Transform(origPoint, location.LocalToWorld); - Assert.AreEqual(expPoint.X, actPoint.X, EPS * 10); - Assert.AreEqual(expPoint.Y, actPoint.Y, EPS * 10); - Assert.AreEqual(expPoint.Z, actPoint.Z, EPS * 10); + Assert.That(actPoint.X, Is.EqualTo(expPoint.X).Within(EPS * 10)); + Assert.That(actPoint.Y, Is.EqualTo(expPoint.Y).Within(EPS * 10)); + Assert.That(actPoint.Z, Is.EqualTo(expPoint.Z).Within(EPS * 10)); } } diff --git a/zzre.core.tests/TestRangeCollection.cs b/zzre.core.tests/TestRangeCollection.cs index 41251564..6bd70886 100644 --- a/zzre.core.tests/TestRangeCollection.cs +++ b/zzre.core.tests/TestRangeCollection.cs @@ -10,12 +10,12 @@ public class TestRangeCollection public void AddSimple() { var coll = new RangeCollection(); - Assert.AreEqual(Array.Empty(), coll); + Assert.That(coll, Is.EqualTo(Array.Empty())); coll.Add(0..1); coll.Add(6..9); - Assert.AreEqual(new[] { 0..1, 6..9 }, coll); - Assert.AreEqual(2, coll.Count); - Assert.AreEqual(0..9, coll.Total); + Assert.That(coll, Is.EqualTo(new[] { 0..1, 6..9 })); + Assert.That(coll.Count, Is.EqualTo(2)); + Assert.That(coll.Total, Is.EqualTo(0..9)); } [Test] @@ -26,7 +26,7 @@ public void AddMerge() 0..3, 3..7 }; - Assert.AreEqual(new[] { 0..7 }, coll); + Assert.That(coll, Is.EqualTo(new[] { 0..7 })); } [Test] @@ -37,7 +37,7 @@ public void AddMergeOverlapping() 5..10, 3..7 }; - Assert.AreEqual(new[] { 3..10 }, coll); + Assert.That(coll, Is.EqualTo(new[] { 3..10 })); } [Test] @@ -49,7 +49,7 @@ public void AddMergeExactFit() 7..10, 3..7 }; - Assert.AreEqual(new[] { 0..10 }, coll); + Assert.That(coll, Is.EqualTo(new[] { 0..10 })); } [Test] @@ -63,7 +63,7 @@ public void AddMergeComplex() 2..17 }; - Assert.AreEqual(new[] { 0..17 }, coll); + Assert.That(coll, Is.EqualTo(new[] { 0..17 })); } [Test] @@ -71,23 +71,23 @@ public void AddBestFit() { // Finds hole in the middle var coll = new RangeCollection { 0..3, 7..10 }; - Assert.AreEqual(3..5, coll.AddBestFit(2)); - Assert.AreEqual(new[] { 0..5, 7..10 }, coll); + Assert.That(coll.AddBestFit(2), Is.EqualTo(3..5)); + Assert.That(coll, Is.EqualTo(new[] { 0..5, 7..10 })); // Finds hole at the start coll = new RangeCollection { 7..10 }; - Assert.AreEqual(0..3, coll.AddBestFit(3)); - Assert.AreEqual(new[] { 0..3, 7..10 }, coll); + Assert.That(coll.AddBestFit(3), Is.EqualTo(0..3)); + Assert.That(coll, Is.EqualTo(new[] { 0..3, 7..10 })); // Ignores holes that are too small coll = new RangeCollection { 2..5, 7..10, 15..20 }; - Assert.AreEqual(10..14, coll.AddBestFit(4)); - Assert.AreEqual(new[] { 2..5, 7..14, 15..20 }, coll); + Assert.That(coll.AddBestFit(4), Is.EqualTo(10..14)); + Assert.That(coll, Is.EqualTo(new[] { 2..5, 7..14, 15..20 })); // Preferes better fitting holes coll = new RangeCollection { 5..10, 13..15 }; - Assert.AreEqual(10..12, coll.AddBestFit(2)); - Assert.AreEqual(new[] { 5..12, 13..15 }, coll); + Assert.That(coll.AddBestFit(2), Is.EqualTo(10..12)); + Assert.That(coll, Is.EqualTo(new[] { 5..12, 13..15 })); // Returns null on empty and too small coll = new RangeCollection(5); @@ -97,7 +97,7 @@ public void AddBestFit() // Returns null on too small coll = new RangeCollection(10) { 3..8 }; Assert.IsNull(coll.AddBestFit(9)); - Assert.AreEqual(new[] { 3..8 }, coll); + Assert.That(coll, Is.EqualTo(new[] { 3..8 })); } [Test] @@ -120,6 +120,6 @@ public void RemoveComplex() }; Assert.True(coll.Remove(2..18)); - Assert.AreEqual(new[] { 0..2, 18..20 }, coll); + Assert.That(coll, Is.EqualTo(new[] { 0..2, 18..20 })); } } diff --git a/zzre.core.tests/TestTagContainer.cs b/zzre.core.tests/TestTagContainer.cs index c87157a7..72cb713d 100644 --- a/zzre.core.tests/TestTagContainer.cs +++ b/zzre.core.tests/TestTagContainer.cs @@ -33,20 +33,20 @@ public void GetTagThrows() [Test] public void CanAddAndRemoveNewTag() { - Assert.IsFalse(container.HasTag()); - Assert.IsFalse(container.RemoveTag()); + Assert.That(container.HasTag(), Is.False); + Assert.That(container.RemoveTag(), Is.False); container.AddTag(new Tag1()); - Assert.IsTrue(container.HasTag()); - Assert.IsTrue(container.RemoveTag()); - Assert.IsFalse(container.HasTag()); - Assert.IsFalse(container.RemoveTag()); + Assert.That(container.HasTag()); + Assert.That(container.RemoveTag()); + Assert.That(container.HasTag(), Is.False); + Assert.That(container.RemoveTag(), Is.False); } [Test] public void CanFindSubTag() { container.AddTag(new SubTag1Of1()); - Assert.IsTrue(container.HasTag()); + Assert.That(container.HasTag()); } [Test] @@ -56,22 +56,22 @@ public void CanAddAndRemoveTwoSubTags() var subTag2 = new SubTag2Of1(); container.AddTag(subTag1); container.AddTag(subTag2); - Assert.IsTrue(container.HasTag()); - Assert.IsTrue(container.HasTag()); - Assert.IsTrue(container.HasTag()); + Assert.That(container.HasTag()); + Assert.That(container.HasTag()); + Assert.That(container.HasTag()); var gotForTag1 = container.GetTag(); - Assert.IsTrue(gotForTag1 == subTag1 || gotForTag1 == subTag2); + Assert.That(gotForTag1 == subTag1 || gotForTag1 == subTag2); var gotAllForTag1 = container.GetTags(); Assert.That(gotAllForTag1, Is.EquivalentTo(new Tag1[] { subTag1, subTag2 })); container.RemoveTag(); - Assert.IsTrue(container.HasTag()); - Assert.IsFalse(container.HasTag()); - Assert.IsTrue(container.HasTag()); + Assert.That(container.HasTag()); + Assert.That(container.HasTag(), Is.False); + Assert.That(container.HasTag()); container.RemoveTag(); - Assert.IsFalse(container.HasTag()); - Assert.IsFalse(container.HasTag()); + Assert.That(container.HasTag(), Is.False); + Assert.That(container.HasTag(), Is.False); } } diff --git a/zzre.core.tests/math/TestIntersectionsBox.cs b/zzre.core.tests/math/TestIntersectionsBox.cs index 65cf0677..c9d97b9b 100644 --- a/zzre.core.tests/math/TestIntersectionsBox.cs +++ b/zzre.core.tests/math/TestIntersectionsBox.cs @@ -19,9 +19,9 @@ public void TestOBBvsPoint() LocalRotation = Quaternion.CreateFromAxisAngle(Vector3.UnitX, 90f * MathF.PI / 180f) }; - Assert.IsFalse(box.Intersects(point)); - Assert.IsFalse(box.Intersects(new Location(), point)); - Assert.IsTrue(box.Intersects(loc, point)); + Assert.That(box.Intersects(point), Is.False); + Assert.That(box.Intersects(new Location(), point), Is.False); + Assert.That(box.Intersects(loc, point)); } [Test] @@ -29,9 +29,9 @@ public void TestAABBClosestPointvsPoint() { var box = new Box(Vector3.Zero, new Vector3(1.0f, 2.0f, 3.0f) * 2f); - Assert.AreEqual(new Vector3(-1.0f, -2.0f, -3.0f), box.ClosestPoint(Vector3.One * -100)); - Assert.AreEqual(new Vector3(1.0f, 2.0f, 3.0f), box.ClosestPoint(Vector3.One * 100)); - Assert.AreEqual(new Vector3(1.0f, -2.0f, 3.0f), box.ClosestPoint(new Vector3(1, -1, 1) * 100)); + Assert.That(box.ClosestPoint(Vector3.One * -100), Is.EqualTo(new Vector3(-1.0f, -2.0f, -3.0f))); + Assert.That(box.ClosestPoint(Vector3.One * 100), Is.EqualTo(new Vector3(1.0f, 2.0f, 3.0f))); + Assert.That(box.ClosestPoint(new Vector3(1, -1, 1) * 100), Is.EqualTo(new Vector3(1.0f, -2.0f, 3.0f))); } [Test] @@ -44,9 +44,9 @@ public void TestOBBClosestPointvsPoint() LocalRotation = Quaternion.CreateFromAxisAngle(Vector3.UnitX, 90f * MathF.PI / 180f) }; - Assert.AreEqual(0.0f, Vector3.Distance(new Vector3(-1.0f, -22.0f, -3.0f), box.ClosestPoint(loc, Vector3.One * -100)), EPS); - Assert.AreEqual(0.0f, Vector3.Distance(new Vector3(1.0f, -18.0f, 3.0f), box.ClosestPoint(loc, Vector3.One * 100)), EPS); - Assert.AreEqual(0.0f, Vector3.Distance(new Vector3(1.0f, -22.0f, 0.0f), box.ClosestPoint(loc, new Vector3(1, -1, 0) * 100)), EPS); + Assert.That(Vector3.Distance(new Vector3(-1.0f, -22.0f, -3.0f), box.ClosestPoint(loc, Vector3.One * -100)), Is.EqualTo(0.0f).Within(EPS)); + Assert.That(Vector3.Distance(new Vector3(1.0f, -18.0f, 3.0f), box.ClosestPoint(loc, Vector3.One * 100)), Is.EqualTo(0.0f).Within(EPS)); + Assert.That(Vector3.Distance(new Vector3(1.0f, -22.0f, 0.0f), box.ClosestPoint(loc, new Vector3(1, -1, 0) * 100)), Is.EqualTo(0.0f).Within(EPS)); } }