diff --git a/Robust.UnitTesting/Client/UserInterface/ControlTest.cs b/Robust.UnitTesting/Client/UserInterface/ControlTest.cs index bb63bf0a5d..448a3749c4 100644 --- a/Robust.UnitTesting/Client/UserInterface/ControlTest.cs +++ b/Robust.UnitTesting/Client/UserInterface/ControlTest.cs @@ -96,7 +96,7 @@ namespace Robust.UnitTesting.Client.UserInterface control.SetValue(_refTypeAttachedProperty, "honk"); - Assert.AreEqual(control.GetValue(_refTypeAttachedProperty), "honk"); + Assert.That(control.GetValue(_refTypeAttachedProperty), Is.EqualTo("honk")); } [Test] @@ -137,11 +137,11 @@ namespace Robust.UnitTesting.Client.UserInterface { var control = new Control(); - Assert.AreEqual(5, control.GetValue(_genericProperty)); + Assert.That(control.GetValue(_genericProperty), Is.EqualTo(5)); control.SetValue(_genericProperty, 11); - Assert.AreEqual(11, control.GetValue(_genericProperty)); + Assert.That(control.GetValue(_genericProperty), Is.EqualTo(11)); Assert.That(() => control.SetValue(_genericProperty, 10), Throws.ArgumentException); } diff --git a/Robust.UnitTesting/Robust.UnitTesting.csproj b/Robust.UnitTesting/Robust.UnitTesting.csproj index 67f2ec4150..3cccb11eed 100644 --- a/Robust.UnitTesting/Robust.UnitTesting.csproj +++ b/Robust.UnitTesting/Robust.UnitTesting.csproj @@ -21,6 +21,7 @@ + diff --git a/Robust.UnitTesting/Server/GameObjects/Components/Transform_Test.cs b/Robust.UnitTesting/Server/GameObjects/Components/Transform_Test.cs index 2be658f63e..5eb9770704 100644 --- a/Robust.UnitTesting/Server/GameObjects/Components/Transform_Test.cs +++ b/Robust.UnitTesting/Server/GameObjects/Components/Transform_Test.cs @@ -455,9 +455,9 @@ namespace Robust.UnitTesting.Server.GameObjects.Components EntityManager.FinishEntityInitialization(child1); EntityManager.FinishEntityInitialization(parent); - Assert.AreEqual(new MapId(123), child2.Transform.MapID); - Assert.AreEqual(new MapId(123), child1.Transform.MapID); - Assert.AreEqual(new MapId(123), parent.Transform.MapID); + Assert.That(child2.Transform.MapID, Is.EqualTo(new MapId(123))); + Assert.That(child1.Transform.MapID, Is.EqualTo(new MapId(123))); + Assert.That(parent.Transform.MapID, Is.EqualTo(new MapId(123))); } } } diff --git a/Robust.UnitTesting/Server/GameObjects/ServerEntityNetworkManagerTest.cs b/Robust.UnitTesting/Server/GameObjects/ServerEntityNetworkManagerTest.cs index 3cbc4cac10..677e77158c 100644 --- a/Robust.UnitTesting/Server/GameObjects/ServerEntityNetworkManagerTest.cs +++ b/Robust.UnitTesting/Server/GameObjects/ServerEntityNetworkManagerTest.cs @@ -33,12 +33,12 @@ namespace Robust.UnitTesting.Server.GameObjects pq.Add(msgE); pq.Add(msgF); - Assert.AreEqual(pq.Take(), msgF); - Assert.AreEqual(pq.Take(), msgE); - Assert.AreEqual(pq.Take(), msgA); - Assert.AreEqual(pq.Take(), msgC); - Assert.AreEqual(pq.Take(), msgB); - Assert.AreEqual(pq.Take(), msgD); + Assert.That(pq.Take(), Is.EqualTo(msgF)); + Assert.That(pq.Take(), Is.EqualTo(msgE)); + Assert.That(pq.Take(), Is.EqualTo(msgA)); + Assert.That(pq.Take(), Is.EqualTo(msgC)); + Assert.That(pq.Take(), Is.EqualTo(msgB)); + Assert.That(pq.Take(), Is.EqualTo(msgD)); } } } diff --git a/Robust.UnitTesting/Shared/GameObjects/EntitySystemManagerOrderTest.cs b/Robust.UnitTesting/Shared/GameObjects/EntitySystemManagerOrderTest.cs index 016f803371..ecd823d875 100644 --- a/Robust.UnitTesting/Shared/GameObjects/EntitySystemManagerOrderTest.cs +++ b/Robust.UnitTesting/Shared/GameObjects/EntitySystemManagerOrderTest.cs @@ -99,12 +99,12 @@ namespace Robust.UnitTesting.Shared.GameObjects systems.Update(1); - Assert.AreEqual(counter.X, 4); + Assert.That(counter.X, Is.EqualTo(4)); - Assert.AreEqual(systems.GetEntitySystem().LastUpdate, 0); - Assert.AreEqual(systems.GetEntitySystem().LastUpdate, 3); - Assert.AreEqual(systems.GetEntitySystem().LastUpdate, 2); - Assert.AreEqual(systems.GetEntitySystem().LastUpdate, 1); + Assert.That(systems.GetEntitySystem().LastUpdate, Is.EqualTo(0)); + Assert.That(systems.GetEntitySystem().LastUpdate, Is.EqualTo(3)); + Assert.That(systems.GetEntitySystem().LastUpdate, Is.EqualTo(2)); + Assert.That(systems.GetEntitySystem().LastUpdate, Is.EqualTo(1)); } [TearDown] diff --git a/Robust.UnitTesting/Shared/GameObjects/EntitySystemManager_Tests.cs b/Robust.UnitTesting/Shared/GameObjects/EntitySystemManager_Tests.cs index 6b95323926..fdf45daf74 100644 --- a/Robust.UnitTesting/Shared/GameObjects/EntitySystemManager_Tests.cs +++ b/Robust.UnitTesting/Shared/GameObjects/EntitySystemManager_Tests.cs @@ -43,21 +43,21 @@ namespace Robust.UnitTesting.Shared.GameObjects esm.Initialize(); // getting type by the exact type should work fine - Assert.AreEqual(esm.GetEntitySystem().GetType(), typeof(ESystemB)); + Assert.That(esm.GetEntitySystem(), Is.TypeOf()); // getting type by an abstract supertype should work fine // because there are no other subtypes of that supertype it would conflict with // it should return the only concrete subtype - Assert.AreEqual(esm.GetEntitySystem().GetType(), typeof(ESystemB)); + Assert.That(esm.GetEntitySystem(), Is.TypeOf()); // getting ESystemA type by its exact type should work fine, // even though EsystemC is a subtype - it should return an instance of ESystemA var esysA = esm.GetEntitySystem(); - Assert.AreEqual(esysA.GetType(), typeof(ESystemA)); - Assert.AreNotEqual(esysA.GetType(), typeof(ESystemC)); + Assert.That(esysA, Is.TypeOf()); + Assert.That(esysA, Is.Not.TypeOf()); var esysC = esm.GetEntitySystem(); - Assert.AreEqual(esysC.GetType(), typeof(ESystemC)); + Assert.That(esysC, Is.TypeOf()); // this should not work - it's abstract and there are multiple // concrete subtypes diff --git a/Robust.UnitTesting/Shared/Localization/Macros/EnglishMacros_test.cs b/Robust.UnitTesting/Shared/Localization/Macros/EnglishMacros_test.cs index 92c15082c1..7ace98ee00 100644 --- a/Robust.UnitTesting/Shared/Localization/Macros/EnglishMacros_test.cs +++ b/Robust.UnitTesting/Shared/Localization/Macros/EnglishMacros_test.cs @@ -36,60 +36,60 @@ namespace Robust.UnitTesting.Shared.Localization.Macros public void TestThey() { ITextMacro sut = new They(); - Assert.AreEqual("She", sut.CapitalizedFormat(female)); - Assert.AreEqual("he", sut.Format(male)); - Assert.AreEqual("they", sut.Format(epicene)); - Assert.AreEqual("it", sut.Format(neuter)); + Assert.That(sut.CapitalizedFormat(female), Is.EqualTo("She")); + Assert.That(sut.Format(male), Is.EqualTo("he")); + Assert.That(sut.Format(epicene), Is.EqualTo("they")); + Assert.That(sut.Format(neuter), Is.EqualTo("it")); } [Test] public void TestTheir() { var sut = new Their(); - Assert.AreEqual("her", sut.Format(female)); - Assert.AreEqual("his", sut.Format(male)); - Assert.AreEqual("their", sut.Format(epicene)); - Assert.AreEqual("its", sut.Format(neuter)); + Assert.That(sut.Format(female), Is.EqualTo("her")); + Assert.That(sut.Format(male), Is.EqualTo("his")); + Assert.That(sut.Format(epicene), Is.EqualTo("their")); + Assert.That(sut.Format(neuter), Is.EqualTo("its")); } [Test] public void TestTheirs() { var sut = new Theirs(); - Assert.AreEqual("hers", sut.Format(female)); - Assert.AreEqual("his", sut.Format(male)); - Assert.AreEqual("theirs", sut.Format(epicene)); - Assert.AreEqual("its", sut.Format(neuter)); + Assert.That(sut.Format(female), Is.EqualTo("hers")); + Assert.That(sut.Format(male), Is.EqualTo("his")); + Assert.That(sut.Format(epicene), Is.EqualTo("theirs")); + Assert.That(sut.Format(neuter), Is.EqualTo("its")); } [Test] public void TestThem() { var sut = new Them(); - Assert.AreEqual("her", sut.Format(female)); - Assert.AreEqual("him", sut.Format(male)); - Assert.AreEqual("them", sut.Format(epicene)); - Assert.AreEqual("it", sut.Format(neuter)); + Assert.That(sut.Format(female), Is.EqualTo("her")); + Assert.That(sut.Format(male), Is.EqualTo("him")); + Assert.That(sut.Format(epicene), Is.EqualTo("them")); + Assert.That(sut.Format(neuter), Is.EqualTo("it")); } [Test] public void TestThemself() { var sut = new Themself(); - Assert.AreEqual("herself", sut.Format(female)); - Assert.AreEqual("himself", sut.Format(male)); - Assert.AreEqual("themself", sut.Format(epicene)); - Assert.AreEqual("itself", sut.Format(neuter)); + Assert.That(sut.Format(female), Is.EqualTo("herself")); + Assert.That(sut.Format(male), Is.EqualTo("himself")); + Assert.That(sut.Format(epicene), Is.EqualTo("themself")); + Assert.That(sut.Format(neuter), Is.EqualTo("itself")); } [Test] public void TestTheyre() { ITextMacro sut = new Theyre(); - Assert.AreEqual("She's", sut.CapitalizedFormat(female)); - Assert.AreEqual("he's", sut.Format(male)); - Assert.AreEqual("they're", sut.Format(epicene)); - Assert.AreEqual("it's", sut.Format(neuter)); + Assert.That(sut.CapitalizedFormat(female), Is.EqualTo("She's")); + Assert.That(sut.Format(male), Is.EqualTo("he's")); + Assert.That(sut.Format(epicene), Is.EqualTo("they're")); + Assert.That(sut.Format(neuter), Is.EqualTo("it's")); } [Test] @@ -97,9 +97,9 @@ namespace Robust.UnitTesting.Shared.Localization.Macros { var cpu = new Subject("CPU", Gender.Neuter, false); ITextMacro sut = new TheName(); - Assert.AreEqual("The CPU", sut.CapitalizedFormat(cpu)); - Assert.AreEqual("the CPU", sut.Format(cpu)); - Assert.AreEqual(male.Name, sut.Format(male)); + Assert.That(sut.CapitalizedFormat(cpu), Is.EqualTo("The CPU")); + Assert.That(sut.Format(cpu), Is.EqualTo("the CPU")); + Assert.That(sut.Format(male), Is.EqualTo(male.Name)); } } } diff --git a/Robust.UnitTesting/Shared/Localization/Macros/MacroFormatProvider_tests.cs b/Robust.UnitTesting/Shared/Localization/Macros/MacroFormatProvider_tests.cs index 4b1f39b82a..169b88c037 100644 --- a/Robust.UnitTesting/Shared/Localization/Macros/MacroFormatProvider_tests.cs +++ b/Robust.UnitTesting/Shared/Localization/Macros/MacroFormatProvider_tests.cs @@ -59,67 +59,67 @@ namespace Robust.UnitTesting.Shared.Localization.Macros private void AssertFormatNormally(string format, params object[] args) { - Assert.AreEqual(string.Format(format, args), string.Format(sut, format, args)); + Assert.That(string.Format(sut, format, args), Is.EqualTo(string.Format(format, args))); } [Test] public void TestInsertThey() { - Assert.AreEqual("She protects", string.Format(sut, "{0:They} protects", female)); - Assert.AreEqual("He attacks", string.Format(sut, "{0:They} attacks", male)); - Assert.AreEqual("It plasmaflood", string.Format(sut, "{0:They} plasmaflood", neuter)); - Assert.AreEqual("But most importantly, they do grammar right", string.Format(sut, "But most importantly, {0:they} do grammar right", epicene)); + Assert.That(string.Format(sut, "{0:They} protects", female), Is.EqualTo("She protects")); + Assert.That(string.Format(sut, "{0:They} attacks", male), Is.EqualTo("He attacks")); + Assert.That(string.Format(sut, "{0:They} plasmaflood", neuter), Is.EqualTo("It plasmaflood")); + Assert.That(string.Format(sut, "But most importantly, {0:they} do grammar right", epicene), Is.EqualTo("But most importantly, they do grammar right")); } [Test] public void TestInsertTheir() { - Assert.AreEqual("Her toolbox", string.Format(sut, "{0:Their} toolbox", female)); - Assert.AreEqual("His toolbox", string.Format(sut, "{0:Their} toolbox", male)); - Assert.AreEqual("Its toolbox", string.Format(sut, "{0:Their} toolbox", neuter)); - Assert.AreEqual("Grab their toolbox", string.Format(sut, "Grab {0:their} toolbox", epicene)); + Assert.That(string.Format(sut, "{0:Their} toolbox", female), Is.EqualTo("Her toolbox")); + Assert.That(string.Format(sut, "{0:Their} toolbox", male), Is.EqualTo("His toolbox")); + Assert.That(string.Format(sut, "{0:Their} toolbox", neuter), Is.EqualTo("Its toolbox")); + Assert.That(string.Format(sut, "Grab {0:their} toolbox", epicene), Is.EqualTo("Grab their toolbox")); } [Test] public void TestInsertTheirs() { - Assert.AreEqual("Hers toolboxs", string.Format(sut, "{0:Theirs} toolboxs", female)); - Assert.AreEqual("His toolboxs", string.Format(sut, "{0:Theirs} toolboxs", male)); - Assert.AreEqual("Its toolboxs", string.Format(sut, "{0:Theirs} toolboxs", neuter)); - Assert.AreEqual("Grab theirs toolboxs", string.Format(sut, "Grab {0:theirs} toolboxs", epicene)); + Assert.That(string.Format(sut, "{0:Theirs} toolboxs", female), Is.EqualTo("Hers toolboxs")); + Assert.That(string.Format(sut, "{0:Theirs} toolboxs", male), Is.EqualTo("His toolboxs")); + Assert.That(string.Format(sut, "{0:Theirs} toolboxs", neuter), Is.EqualTo("Its toolboxs")); + Assert.That(string.Format(sut, "Grab {0:theirs} toolboxs", epicene), Is.EqualTo("Grab theirs toolboxs")); } [Test] public void TestInsertThem() { - Assert.AreEqual("Robust her", string.Format(sut, "Robust {0:them}", female)); - Assert.AreEqual("Robust him", string.Format(sut, "Robust {0:them}", male)); - Assert.AreEqual("Robust it", string.Format(sut, "Robust {0:them}", neuter)); - Assert.AreEqual("Robust them", string.Format(sut, "Robust {0:them}", epicene)); + Assert.That(string.Format(sut, "Robust {0:them}", female), Is.EqualTo("Robust her")); + Assert.That(string.Format(sut, "Robust {0:them}", male), Is.EqualTo("Robust him")); + Assert.That(string.Format(sut, "Robust {0:them}", neuter), Is.EqualTo("Robust it")); + Assert.That(string.Format(sut, "Robust {0:them}", epicene), Is.EqualTo("Robust them")); } [Test] public void TestInsertThemself() { - Assert.AreEqual("Robust herself", string.Format(sut, "Robust {0:themself}", female)); - Assert.AreEqual("Robust himself", string.Format(sut, "Robust {0:themself}", male)); - Assert.AreEqual("Robust itself", string.Format(sut, "Robust {0:themself}", neuter)); - Assert.AreEqual("Robust themself", string.Format(sut, "Robust {0:themself}", epicene)); + Assert.That(string.Format(sut, "Robust {0:themself}", female), Is.EqualTo("Robust herself")); + Assert.That(string.Format(sut, "Robust {0:themself}", male), Is.EqualTo("Robust himself")); + Assert.That(string.Format(sut, "Robust {0:themself}", neuter), Is.EqualTo("Robust itself")); + Assert.That(string.Format(sut, "Robust {0:themself}", epicene), Is.EqualTo("Robust themself")); } [Test] public void TestInsertTheyre() { - Assert.AreEqual("She's robust", string.Format(sut, "{0:Theyre} robust", female)); - Assert.AreEqual("He's robust", string.Format(sut, "{0:Theyre} robust", male)); - Assert.AreEqual("It's robust", string.Format(sut, "{0:Theyre} robust", neuter)); - Assert.AreEqual("They're robust", string.Format(sut, "{0:Theyre} robust", epicene)); + Assert.That(string.Format(sut, "{0:Theyre} robust", female), Is.EqualTo("She's robust")); + Assert.That(string.Format(sut, "{0:Theyre} robust", male), Is.EqualTo("He's robust")); + Assert.That(string.Format(sut, "{0:Theyre} robust", neuter), Is.EqualTo("It's robust")); + Assert.That(string.Format(sut, "{0:Theyre} robust", epicene), Is.EqualTo("They're robust")); } [Test] public void TestUseToString() { - Assert.AreEqual("Bob uses his toolbox", string.Format(sut, "{0} uses {0:their} toolbox", male)); + Assert.That(string.Format(sut, "{0} uses {0:their} toolbox", male), Is.EqualTo("Bob uses his toolbox")); } } } diff --git a/Robust.UnitTesting/Shared/Maths/Color_Test.cs b/Robust.UnitTesting/Shared/Maths/Color_Test.cs index a03cb4107c..7c2eeaa0d4 100644 --- a/Robust.UnitTesting/Shared/Maths/Color_Test.cs +++ b/Robust.UnitTesting/Shared/Maths/Color_Test.cs @@ -127,7 +127,10 @@ namespace Robust.UnitTesting.Shared.Maths Color? nullColor = null; UIBox2 notColor = new UIBox2(rf, gf, bf, af); +#pragma warning disable NUnit2009 + // This tests that .Equals actually works so ignoring the warning is fine. Assert.That(controlColor, Is.EqualTo(controlColor)); +#pragma warning restore NUnit2009 Assert.That(controlColor, Is.Not.EqualTo(colorDiffRed)); Assert.That(controlColor, Is.Not.EqualTo(colorDiffGreen)); Assert.That(controlColor, Is.Not.EqualTo(colorDiffBlue)); diff --git a/Robust.UnitTesting/Shared/Physics/CollidesOnMask_Tests.cs b/Robust.UnitTesting/Shared/Physics/CollidesOnMask_Tests.cs index b4127a8300..b113dac783 100644 --- a/Robust.UnitTesting/Shared/Physics/CollidesOnMask_Tests.cs +++ b/Robust.UnitTesting/Shared/Physics/CollidesOnMask_Tests.cs @@ -54,7 +54,7 @@ namespace Robust.UnitTesting.Shared.Physics //Act Act(); //Assert - Assert.AreEqual(expected, Result); + Assert.That(Result, Is.EqualTo(expected)); } } } diff --git a/Robust.UnitTesting/Shared/Physics/DynamicTree_Test.cs b/Robust.UnitTesting/Shared/Physics/DynamicTree_Test.cs index a64ea3b8c4..5516fba3b9 100644 --- a/Robust.UnitTesting/Shared/Physics/DynamicTree_Test.cs +++ b/Robust.UnitTesting/Shared/Physics/DynamicTree_Test.cs @@ -65,7 +65,7 @@ namespace Robust.UnitTesting.Shared.Physics var initCap = dt.Capacity; - Assert.AreEqual(16, initCap); + Assert.That(initCap, Is.EqualTo(16)); Assert.Multiple(() => { @@ -285,11 +285,11 @@ namespace Robust.UnitTesting.Shared.Physics Assert.Multiple(() => { - Assert.AreEqual(containers.Length, results.Length, "Length"); + Assert.That(results.Length, Is.EqualTo(containers.Length), "Length"); var l = Math.Min(containers.Length, results.Length); for (var i = 0; i < l; ++i) { - Assert.AreEqual(containers[i], results[i]); + Assert.That(results[i], Is.EqualTo(containers[i])); } }); } diff --git a/Robust.UnitTesting/Shared/Prototypes/PrototypeManager_Test.cs b/Robust.UnitTesting/Shared/Prototypes/PrototypeManager_Test.cs index f05769147f..b6a4248681 100644 --- a/Robust.UnitTesting/Shared/Prototypes/PrototypeManager_Test.cs +++ b/Robust.UnitTesting/Shared/Prototypes/PrototypeManager_Test.cs @@ -95,7 +95,7 @@ namespace Robust.UnitTesting.Shared.Prototypes { var prototype = manager.Index("PlaceInheritTester"); - Assert.AreEqual(prototype.PlacementMode, "SnapgridCenter"); + Assert.That(prototype.PlacementMode, Is.EqualTo("SnapgridCenter")); } private enum YamlTestEnum diff --git a/Robust.UnitTesting/Shared/Utility/CommandParsing_Test.cs b/Robust.UnitTesting/Shared/Utility/CommandParsing_Test.cs index 3f1ef9e837..afa4ef95f1 100644 --- a/Robust.UnitTesting/Shared/Utility/CommandParsing_Test.cs +++ b/Robust.UnitTesting/Shared/Utility/CommandParsing_Test.cs @@ -32,7 +32,7 @@ namespace Robust.UnitTesting.Shared.Utility { var escaped = CommandParsing.Escape(source); - Assert.That(escaped, Is.EqualTo(escaped)); + Assert.That(escaped, Is.EqualTo(expected)); } } }