diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e9b89a8..f02368c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: Build with dotnet on windows if: matrix.os == 'windows-latest' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 51bcb85..78a78a0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v4 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: build package run: ./build.sh package diff --git a/Gauge.CSharp.Lib.UnitTests/Attribute/FilteredHookAttributeTests.cs b/Gauge.CSharp.Lib.UnitTests/Attribute/FilteredHookAttributeTests.cs index c082a8d..4220869 100644 --- a/Gauge.CSharp.Lib.UnitTests/Attribute/FilteredHookAttributeTests.cs +++ b/Gauge.CSharp.Lib.UnitTests/Attribute/FilteredHookAttributeTests.cs @@ -1,6 +1,4 @@ -using System.Linq; -using Gauge.CSharp.Lib.Attribute; -using NUnit.Framework; +using Gauge.CSharp.Lib.Attribute; namespace Gauge.CSharp.Lib.UnitTests.Attribute { @@ -25,18 +23,18 @@ public TestHookAttribute(params string[] filterTags) : base(filterTags) [Test] public void ShouldCreateAttributeWithMultipleTags() { - var filterTags = new[] {"foo", "bar"}; + var filterTags = new[] { "foo", "bar" }; var filteredHookAttribute = new TestHookAttribute(filterTags); foreach (var filterTag in filterTags) - Assert.IsTrue(filteredHookAttribute.FilterTags.Contains(filterTag)); + Assert.That(filteredHookAttribute.FilterTags, Does.Contain(filterTag)); } [Test] public void ShouldCreateAttributeWithNoParameters() { var filteredHookAttribute = new TestHookAttribute(); - Assert.IsNotNull(filteredHookAttribute); + Assert.That(filteredHookAttribute, Is.Not.Null); } [Test] @@ -44,7 +42,7 @@ public void ShouldCreateAttributeWithOneTag() { var filterTag = "foo"; var filteredHookAttribute = new TestHookAttribute(filterTag); - Assert.IsTrue(filteredHookAttribute.FilterTags.Contains(filterTag)); + Assert.That(filteredHookAttribute.FilterTags, Does.Contain(filterTag)); } } } \ No newline at end of file diff --git a/Gauge.CSharp.Lib.UnitTests/DataStoreFactoryTests.cs b/Gauge.CSharp.Lib.UnitTests/DataStoreFactoryTests.cs index 976eb7f..63eef78 100644 --- a/Gauge.CSharp.Lib.UnitTests/DataStoreFactoryTests.cs +++ b/Gauge.CSharp.Lib.UnitTests/DataStoreFactoryTests.cs @@ -18,7 +18,7 @@ public void Setup() public void AddDataStore_ShouldSetTheSuiteDataStore_WhenCalledForSuiteDataStoreType() { DataStoreFactory.AddDataStore(1, DataStoreType.Suite); - Assert.IsNotNull(DataStoreFactory.SuiteDataStore); + Assert.That(DataStoreFactory.SuiteDataStore, Is.Not.Null); } [Test] @@ -27,21 +27,21 @@ public void AddDataStore_ShouldNotOverwriteTheSuiteDataStore_WhenCalledForSuiteD DataStoreFactory.AddDataStore(1, DataStoreType.Suite); var dataStore = DataStoreFactory.SuiteDataStore; DataStoreFactory.AddDataStore(1, DataStoreType.Suite); - Assert.AreSame(dataStore, DataStoreFactory.SuiteDataStore); + Assert.That(dataStore, Is.SameAs(DataStoreFactory.SuiteDataStore)); } [Test] public void AddDataStore_ShouldSetTheSpecDataStore_WhenCalledForSpecDataStoreType() { DataStoreFactory.AddDataStore(1, DataStoreType.Spec); - Assert.IsNotNull(DataStoreFactory.GetDataStoresByStream(1)[DataStoreType.Spec]); + Assert.That(DataStoreFactory.GetDataStoresByStream(1)[DataStoreType.Spec], Is.Not.Null); } [Test] public void AddDataStore_ShouldSetTheScenaroDataStore_WhenCalledForScenarioDataStoreType() { DataStoreFactory.AddDataStore(1, DataStoreType.Scenario); - Assert.IsNotNull(DataStoreFactory.GetDataStoresByStream(1)[DataStoreType.Scenario]); + Assert.That(DataStoreFactory.GetDataStoresByStream(1)[DataStoreType.Scenario], Is.Not.Null); } [Test] @@ -52,8 +52,8 @@ public void AddDataStore_ShouldKeepSeparateDataStores_WhenCalledForDifferentStre var dict1 = DataStoreFactory.GetDataStoresByStream(1)[DataStoreType.Scenario]; var dict2 = DataStoreFactory.GetDataStoresByStream(2)[DataStoreType.Scenario]; - Assert.AreNotSame(dict1, dict2); + Assert.That(dict1, Is.Not.SameAs(dict2)); dict1.Add("mykey", new object()); - Assert.IsNull(dict2.Get("mykey")); + Assert.That(dict2.Get("mykey"), Is.Null); } } \ No newline at end of file diff --git a/Gauge.CSharp.Lib.UnitTests/DataStoreTests.cs b/Gauge.CSharp.Lib.UnitTests/DataStoreTests.cs index 81ddb4c..adc8937 100644 --- a/Gauge.CSharp.Lib.UnitTests/DataStoreTests.cs +++ b/Gauge.CSharp.Lib.UnitTests/DataStoreTests.cs @@ -27,7 +27,7 @@ public void ShouldClearDataStore() _dataStore.Add("fruit", "apple"); _dataStore.Clear(); - Assert.AreEqual(_dataStore.Count, 0); + Assert.That(_dataStore.Count, Is.EqualTo(0)); } [Test] @@ -36,7 +36,7 @@ public void ShouldGetNullWhenKeyDoesNotExist() _dataStore.Add("fruit", "banana"); var fruit = _dataStore.Get("banana"); - Assert.IsNull(fruit); + Assert.That(fruit, Is.Null); } [Test] @@ -45,14 +45,14 @@ public void ShouldGetStrongTypedValue() _dataStore.Add("banana", new Fruit { Name = "Banana" }); var fruit = _dataStore.Get("banana"); - Assert.IsInstanceOf(fruit); - Assert.AreEqual("Banana", fruit.Name); + Assert.That(fruit, Is.InstanceOf()); + Assert.That(fruit.Name, Is.EqualTo("Banana")); } [Test] public void ShouldInitializeDataStore() { - Assert.AreEqual(_dataStore.Count, 0); + Assert.That(_dataStore.Count, Is.EqualTo(0)); } public class Sample @@ -68,7 +68,7 @@ public void ShouldInsertComplexTypeIntoDataStore() _dataStore.Add("bar", new Sample { Name = "Hello", Country = "India" }); var value = _dataStore.Get("bar") as Sample; - Assert.AreEqual(value.Name, "Hello"); + Assert.That(value.Name, Is.EqualTo("Hello")); } [Test] @@ -76,8 +76,8 @@ public void ShouldInsertValueIntoDataStore() { _dataStore.Add("foo", 23); - Assert.AreEqual(_dataStore.Count, 1); - Assert.AreEqual(_dataStore.Get("foo"), 23); + Assert.That(_dataStore.Count, Is.EqualTo(1)); + Assert.That(_dataStore.Get("foo"), Is.EqualTo(23)); } [Test] @@ -95,7 +95,7 @@ public void ShouldReturnNullWhenAskingForInvalidKeyWithStrongType() var fruit = _dataStore.Get("random"); - Assert.IsNull(fruit); + Assert.That(fruit, Is.Null); } [Test] @@ -112,6 +112,6 @@ public void ShouldUpdateDataForGivenKey() var value = _dataStore.Get("foo"); - Assert.AreEqual(value, "rumpelstiltskin"); + Assert.That(value, Is.EqualTo("rumpelstiltskin")); } } \ No newline at end of file diff --git a/Gauge.CSharp.Lib.UnitTests/DefaultClassInstanceManagerTests.cs b/Gauge.CSharp.Lib.UnitTests/DefaultClassInstanceManagerTests.cs index 9df31c3..cbab723 100644 --- a/Gauge.CSharp.Lib.UnitTests/DefaultClassInstanceManagerTests.cs +++ b/Gauge.CSharp.Lib.UnitTests/DefaultClassInstanceManagerTests.cs @@ -21,8 +21,8 @@ public void ShouldGetInstanceForType() var type = typeof(object); var instance = new DefaultClassInstanceManager().Get(type); - Assert.NotNull(instance); - Assert.AreEqual(instance.GetType(), type); + Assert.That(instance, Is.Not.Null); + Assert.That(instance.GetType(), Is.EqualTo(type)); } [Test] @@ -33,7 +33,7 @@ public void ShouldGetMemoizedInstanceForType() var instance = instanceManager.Get(type); var anotherInstance = instanceManager.Get(type); - Assert.AreSame(instance, anotherInstance); + Assert.That(instance, Is.SameAs(anotherInstance)); } [Test] @@ -45,7 +45,7 @@ public async Task InvokeMethod_ShouldCreateInstanceAndInvokeMethod_WhenInstanceI await instanceManager.InvokeMethod(methodInfo, 1); - Assert.IsTrue(MethodInvokeTests.InvokeMethod1Called); + Assert.That(MethodInvokeTests.InvokeMethod1Called); } [Test] @@ -60,7 +60,7 @@ public async Task InvokeMethod_ShouldSetDataStores_WhenDataStoresAreInitialized( await instanceManager.InvokeMethod(methodInfo, 1); - Assert.IsTrue(MethodInvokeTests.InvokeMethod2Called); + Assert.That(MethodInvokeTests.InvokeMethod2Called); } [Test] @@ -72,7 +72,7 @@ public async Task InvokeMethod_ShouldNotFail_WhenMethodInvokedIsNotAsync() await instanceManager.InvokeMethod(methodInfo, 1); - Assert.IsTrue(MethodInvokeTests.InvokeMethod3Called); + Assert.That(MethodInvokeTests.InvokeMethod3Called); } } @@ -91,9 +91,12 @@ public Task InvokeMethod1() public Task InvokeMethod2() { InvokeMethod2Called = true; - Assert.IsNotNull(SuiteDataStore.Store.Value); - Assert.IsNotNull(SpecDataStore.Store.Value); - Assert.IsNotNull(ScenarioDataStore.Store.Value); + Assert.Multiple(() => + { + Assert.That(SuiteDataStore.Store.Value, Is.Not.Null); + Assert.That(SpecDataStore.Store.Value, Is.Not.Null); + Assert.That(ScenarioDataStore.Store.Value, Is.Not.Null); + }); return Task.CompletedTask; } diff --git a/Gauge.CSharp.Lib.UnitTests/Gauge.CSharp.Lib.UnitTests.csproj b/Gauge.CSharp.Lib.UnitTests/Gauge.CSharp.Lib.UnitTests.csproj index f339633..2e78bb6 100644 --- a/Gauge.CSharp.Lib.UnitTests/Gauge.CSharp.Lib.UnitTests.csproj +++ b/Gauge.CSharp.Lib.UnitTests/Gauge.CSharp.Lib.UnitTests.csproj @@ -1,14 +1,18 @@ - + - net8.0 + net9.0 enable - - - + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/Gauge.CSharp.Lib.UnitTests/SuiteSpecAndScenarioDataStoreTests.cs b/Gauge.CSharp.Lib.UnitTests/SuiteSpecAndScenarioDataStoreTests.cs index 3fa4266..e9e0f65 100644 --- a/Gauge.CSharp.Lib.UnitTests/SuiteSpecAndScenarioDataStoreTests.cs +++ b/Gauge.CSharp.Lib.UnitTests/SuiteSpecAndScenarioDataStoreTests.cs @@ -30,7 +30,7 @@ private static void InitializeDataStore(Type type) public void ScenarioDataStoreTestAdd() { ScenarioDataStore.Add("myKey1", "myValue"); - Assert.AreEqual(ScenarioDataStore.Get("myKey1"), "myValue"); + Assert.That(ScenarioDataStore.Get("myKey1"), Is.EqualTo("myValue")); } [Test] @@ -38,8 +38,8 @@ public void ScenarioDataStoreTestAddObject() { var obj = new List() { "val1" }; ScenarioDataStore.Add("myKey2", obj); - Assert.AreEqual(ScenarioDataStore.Get("myKey2"), obj); - Assert.IsInstanceOf>(ScenarioDataStore.Get("myKey2")); + Assert.That(ScenarioDataStore.Get("myKey2"), Is.EqualTo(obj)); + Assert.That(ScenarioDataStore.Get("myKey2"), Is.InstanceOf>()); } [Test] @@ -47,14 +47,14 @@ public void ScenarioDataStoreTestAddTypedObject() { var obj = new List() { "val1" }; ScenarioDataStore.Add("myKey3", obj); - Assert.AreSame(ScenarioDataStore.Get>("myKey3"), obj); + Assert.That(ScenarioDataStore.Get>("myKey3"), Is.SameAs(obj)); } [Test] public void SpecDataStoreTestAdd() { SpecDataStore.Add("myKey3", "myValue"); - Assert.AreEqual(SpecDataStore.Get("myKey3"), "myValue"); + Assert.That(SpecDataStore.Get("myKey3"), Is.EqualTo("myValue")); } [Test] @@ -62,8 +62,8 @@ public void SpecDataStoreTestAddObject() { var obj = new List() { "val1" }; SpecDataStore.Add("myKey4", obj); - Assert.AreEqual(SpecDataStore.Get("myKey4"), obj); - Assert.IsInstanceOf>(SpecDataStore.Get("myKey4")); + Assert.That(SpecDataStore.Get("myKey4"), Is.EqualTo(obj)); + Assert.That(SpecDataStore.Get("myKey4"), Is.InstanceOf>()); } [Test] @@ -71,14 +71,14 @@ public void SpecDataStoreTestAddTypedObject() { var obj = new List() { "val1" }; SpecDataStore.Add("myKey3", obj); - Assert.AreSame(SpecDataStore.Get>("myKey3"), obj); + Assert.That(SpecDataStore.Get>("myKey3"), Is.SameAs(obj)); } [Test] public void SuiteDataStoreTestAdd() { SuiteDataStore.Add("myKey5", "myValue"); - Assert.AreEqual(SuiteDataStore.Get("myKey5"), "myValue"); + Assert.That(SuiteDataStore.Get("myKey5"), Is.EqualTo("myValue")); } [Test] @@ -86,8 +86,8 @@ public void SuiteDataStoreTestAddObject() { var obj = new List() { "val1" }; SuiteDataStore.Add("myKey6", obj); - Assert.AreEqual(SuiteDataStore.Get("myKey6"), obj); - Assert.IsInstanceOf>(SuiteDataStore.Get("myKey6")); + Assert.That(SuiteDataStore.Get("myKey6"), Is.EqualTo(obj)); + Assert.That(SuiteDataStore.Get("myKey6"), Is.InstanceOf>()); } [Test] @@ -95,7 +95,7 @@ public void SuiteDataStoreTestAddTypedObject() { var obj = new List() { "val1" }; SuiteDataStore.Add("myKey3", obj); - Assert.AreSame(SuiteDataStore.Get>("myKey3"), obj); + Assert.That(SuiteDataStore.Get>("myKey3"), Is.SameAs(obj)); } [Test] @@ -104,9 +104,12 @@ public void AllDataStoreTestAdd() ScenarioDataStore.Add("myKey7", "scenario"); SpecDataStore.Add("myKey7", "spec"); SuiteDataStore.Add("myKey7", "suite"); - Assert.AreEqual(ScenarioDataStore.Get("myKey7"), "scenario"); - Assert.AreEqual(SpecDataStore.Get("myKey7"), "spec"); - Assert.AreEqual(SuiteDataStore.Get("myKey7"), "suite"); + Assert.Multiple(() => + { + Assert.That(ScenarioDataStore.Get("myKey7"), Is.EqualTo("scenario")); + Assert.That(SpecDataStore.Get("myKey7"), Is.EqualTo("spec")); + Assert.That(SuiteDataStore.Get("myKey7"), Is.EqualTo("suite")); + }); } [Test] @@ -115,15 +118,21 @@ public void AllDataStoreTestClean() ScenarioDataStore.Add("myKey7", "scenario"); SpecDataStore.Add("myKey7", "spec"); SuiteDataStore.Add("myKey7", "suite"); - Assert.AreEqual(ScenarioDataStore.Get("myKey7"), "scenario"); - Assert.AreEqual(SpecDataStore.Get("myKey7"), "spec"); - Assert.AreEqual(SuiteDataStore.Get("myKey7"), "suite"); + Assert.Multiple(() => + { + Assert.That(ScenarioDataStore.Get("myKey7"), Is.EqualTo("scenario")); + Assert.That(SpecDataStore.Get("myKey7"), Is.EqualTo("spec")); + Assert.That(SuiteDataStore.Get("myKey7"), Is.EqualTo("suite")); + }); ScenarioDataStore.Clear(); SpecDataStore.Clear(); SuiteDataStore.Clear(); - Assert.IsNull(ScenarioDataStore.Get("myKey7")); - Assert.IsNull(SpecDataStore.Get("myKey7")); - Assert.IsNull(SuiteDataStore.Get("myKey7")); + Assert.Multiple(() => + { + Assert.That(ScenarioDataStore.Get("myKey7"), Is.Null); + Assert.That(SpecDataStore.Get("myKey7"), Is.Null); + Assert.That(SuiteDataStore.Get("myKey7"), Is.Null); + }); } [Test] @@ -133,14 +142,14 @@ public void AllDataStoreTestAddObject() var obj2 = new List() { "spec" }; var obj3 = new List() { "suite" }; ScenarioDataStore.Add("myKey8", obj1); - Assert.AreEqual(ScenarioDataStore.Get("myKey8"), obj1); - Assert.IsInstanceOf>(ScenarioDataStore.Get("myKey8")); + Assert.That(ScenarioDataStore.Get("myKey8"), Is.EqualTo(obj1)); + Assert.That(ScenarioDataStore.Get("myKey8"), Is.InstanceOf>()); SpecDataStore.Add("myKey8", obj2); - Assert.AreEqual(SpecDataStore.Get("myKey8"), obj2); - Assert.IsInstanceOf>(SpecDataStore.Get("myKey8")); + Assert.That(SpecDataStore.Get("myKey8"), Is.EqualTo(obj2)); + Assert.That(SpecDataStore.Get("myKey8"), Is.InstanceOf>()); SuiteDataStore.Add("myKey8", obj3); - Assert.AreEqual(SuiteDataStore.Get("myKey8"), obj3); - Assert.IsInstanceOf>(SuiteDataStore.Get("myKey8")); + Assert.That(SuiteDataStore.Get("myKey8"), Is.EqualTo(obj3)); + Assert.That(SuiteDataStore.Get("myKey8"), Is.InstanceOf>()); } [Test] @@ -149,17 +158,17 @@ public void ScenarioDataStoreParallelInvoke() Task.WaitAll(new Task[6] { Task.Run(() => ScenarioDataStore.Add("sckey1", "Scenario1")) - .ContinueWith((o) => Assert.AreEqual(ScenarioDataStore.Get("sckey1"), "Scenario1")), + .ContinueWith((o) => Assert.That(ScenarioDataStore.Get("sckey1"), Is.EqualTo("Scenario1"))), Task.Run(() => ScenarioDataStore.Add("sckey2", "Scenario2")) - .ContinueWith((o) => Assert.AreEqual(ScenarioDataStore.Get("sckey2"), "Scenario2")), + .ContinueWith((o) => Assert.That(ScenarioDataStore.Get("sckey2"), Is.EqualTo("Scenario2"))), Task.Run(() => ScenarioDataStore.Add("sckey3", "Scenario3")) - .ContinueWith((o) => Assert.AreEqual(ScenarioDataStore.Get("sckey3"), "Scenario3")), + .ContinueWith((o) => Assert.That(ScenarioDataStore.Get("sckey3"), Is.EqualTo("Scenario3"))), Task.Run(() => ScenarioDataStore.Add("sckey4", "Scenario4")) - .ContinueWith((o) => Assert.AreEqual(ScenarioDataStore.Get("sckey4"), "Scenario4")), + .ContinueWith((o) => Assert.That(ScenarioDataStore.Get("sckey4"), Is.EqualTo("Scenario4"))), Task.Run(() => ScenarioDataStore.Add("sckey5", "Scenario5")) - .ContinueWith((o) => Assert.AreEqual(ScenarioDataStore.Get("sckey5"), "Scenario5")), + .ContinueWith((o) => Assert.That(ScenarioDataStore.Get("sckey5"), Is.EqualTo("Scenario5"))), Task.Run(() => ScenarioDataStore.Add("sckey6", "Scenario6")) - .ContinueWith((o) => Assert.AreEqual(ScenarioDataStore.Get("sckey6"), "Scenario6")) + .ContinueWith((o) => Assert.That(ScenarioDataStore.Get("sckey6"), Is.EqualTo("Scenario6"))) }); } @@ -169,40 +178,40 @@ public void AllDataStoreParallelInvoke() Task.WaitAll(new Task[12] { Task.Run(() => ScenarioDataStore.Add("sckey7", "Scenario7")) - .ContinueWith((o) => Assert.AreEqual(ScenarioDataStore.Get("sckey7"), "Scenario7")), + .ContinueWith((o) => Assert.That(ScenarioDataStore.Get("sckey7"), Is.EqualTo("Scenario7"))), Task.Run(() => ScenarioDataStore.Add("sckey8", "Scenario8")) - .ContinueWith((o) => Assert.AreEqual(ScenarioDataStore.Get("sckey8"), "Scenario8")), + .ContinueWith((o) => Assert.That(ScenarioDataStore.Get("sckey8"), Is.EqualTo("Scenario8"))), Task.Run(() => ScenarioDataStore.Add("sckey9", "Scenario9")) - .ContinueWith((o) => Assert.AreEqual(ScenarioDataStore.Get("sckey9"), "Scenario9")), + .ContinueWith((o) => Assert.That(ScenarioDataStore.Get("sckey9"), Is.EqualTo("Scenario9"))), Task.Run(() => ScenarioDataStore.Add("sckey10", "Scenario10")) - .ContinueWith((o) => Assert.AreEqual(ScenarioDataStore.Get("sckey10"), "Scenario10")), + .ContinueWith((o) => Assert.That(ScenarioDataStore.Get("sckey10"), Is.EqualTo("Scenario10"))), Task.Run(() => SpecDataStore.Add("spec1", "Spec1")) - .ContinueWith((o) => Assert.AreEqual(SpecDataStore.Get("spec1"), "Spec1")), + .ContinueWith((o) => Assert.That(SpecDataStore.Get("spec1"), Is.EqualTo("Spec1"))), Task.Run(() => SpecDataStore.Add("spec2", "Spec2")) - .ContinueWith((o) => Assert.AreEqual(SpecDataStore.Get("spec2"), "Spec2")), + .ContinueWith((o) => Assert.That(SpecDataStore.Get("spec2"), Is.EqualTo("Spec2"))), Task.Run(() => SpecDataStore.Add("spec3", "Spec3")) - .ContinueWith((o) => Assert.AreEqual(SpecDataStore.Get("spec3"), "Spec3")), + .ContinueWith((o) => Assert.That(SpecDataStore.Get("spec3"), Is.EqualTo("Spec3"))), Task.Run(() => SpecDataStore.Add("spec4", "Spec4")) - .ContinueWith((o) => Assert.AreEqual(SpecDataStore.Get("spec4"), "Spec4")), + .ContinueWith((o) => Assert.That(SpecDataStore.Get("spec4"), Is.EqualTo("Spec4"))), Task.Run(() => SuiteDataStore.Add("suite1", "Suite1")) - .ContinueWith((o) => Assert.AreEqual(SuiteDataStore.Get("suite1"), "Suite1")), + .ContinueWith((o) => Assert.That(SuiteDataStore.Get("suite1"), Is.EqualTo("Suite1"))), Task.Run(() => SuiteDataStore.Add("suite2", "Suite2")) - .ContinueWith((o) => Assert.AreEqual(SuiteDataStore.Get("suite2"), "Suite2")), + .ContinueWith((o) => Assert.That(SuiteDataStore.Get("suite2"), Is.EqualTo("Suite2"))), Task.Run(() => SuiteDataStore.Add("suite3", "Suite3")) - .ContinueWith((o) => Assert.AreEqual(SuiteDataStore.Get("suite3"), "Suite3")), + .ContinueWith((o) => Assert.That(SuiteDataStore.Get("suite3"), Is.EqualTo("Suite3"))), Task.Run(() => SuiteDataStore.Add("suite4", "Suite4")) - .ContinueWith((o) => Assert.AreEqual(SuiteDataStore.Get("suite4"), "Suite4")) + .ContinueWith((o) => Assert.That(SuiteDataStore.Get("suite4"), Is.EqualTo("Suite4"))) }); } } \ No newline at end of file diff --git a/Gauge.CSharp.Lib.UnitTests/TableTests.cs b/Gauge.CSharp.Lib.UnitTests/TableTests.cs index e7bb353..13fac40 100644 --- a/Gauge.CSharp.Lib.UnitTests/TableTests.cs +++ b/Gauge.CSharp.Lib.UnitTests/TableTests.cs @@ -1,8 +1,4 @@ -using System.Collections.Generic; -using System.Linq; -using NUnit.Framework; - -namespace Gauge.CSharp.Lib.UnitTests +namespace Gauge.CSharp.Lib.UnitTests { [TestFixture] public class TableTests @@ -10,61 +6,64 @@ public class TableTests [Test] public void ShouldBeAbleToAccessRowValuesUsingColumnNames() { - var headers = new List {"foo", "bar"}; + var headers = new List { "foo", "bar" }; var table = new Table(headers); - table.AddRow(new List {"foo_val", "bar_val"}); - table.AddRow(new List {"foo_val1", "bar_val1"}); + table.AddRow(new List { "foo_val", "bar_val" }); + table.AddRow(new List { "foo_val1", "bar_val1" }); - Assert.AreEqual("foo_val", table.GetTableRows()[0].GetCell("foo")); - Assert.AreEqual("bar_val", table.GetTableRows()[0].GetCell("bar")); - Assert.AreEqual("foo_val1", table.GetTableRows()[1].GetCell("foo")); - Assert.AreEqual("bar_val1", table.GetTableRows()[1].GetCell("bar")); - Assert.AreEqual("", table.GetTableRows()[1].GetCell("bar1")); - Assert.AreEqual("TableRow: cells: [foo = foo_val, bar = bar_val] ", table.GetTableRows()[0].ToString()); + Assert.Multiple(() => + { + Assert.That(table.GetTableRows()[0].GetCell("foo"), Is.EqualTo("foo_val")); + Assert.That(table.GetTableRows()[0].GetCell("bar"), Is.EqualTo("bar_val")); + Assert.That(table.GetTableRows()[1].GetCell("foo"), Is.EqualTo("foo_val1")); + Assert.That(table.GetTableRows()[1].GetCell("bar"), Is.EqualTo("bar_val1")); + Assert.That(table.GetTableRows()[1].GetCell("bar1"), Is.EqualTo("")); + Assert.That(table.GetTableRows()[0].ToString(), Is.EqualTo("TableRow: cells: [foo = foo_val, bar = bar_val] ")); + }); } [Test] public void ShouldGetEmptyListColumnValuesForInvalidColumnName() { - var headers = new List {"foo", "bar"}; + var headers = new List { "foo", "bar" }; var table = new Table(headers); - table.AddRow(new List {"foo_val", "bar_val"}); - table.AddRow(new List {"foo_val1", "bar_val1"}); + table.AddRow(new List { "foo_val", "bar_val" }); + table.AddRow(new List { "foo_val1", "bar_val1" }); var columnValues = table.GetColumnValues("baz"); - Assert.IsEmpty(columnValues); + Assert.That(columnValues, Is.Empty); } [Test] public void ShouldGetTableAsMarkdownString() { - var headers = new List {"foo", "bar_with_big_header"}; + var headers = new List { "foo", "bar_with_big_header" }; var table = new Table(headers); - table.AddRow(new List {"foo_val", "bar_val"}); - table.AddRow(new List {"foo_val1", "bar_val1"}); + table.AddRow(new List { "foo_val", "bar_val" }); + table.AddRow(new List { "foo_val1", "bar_val1" }); const string expected = "|foo |bar_with_big_header|\n" + "|--------|-------------------|\n" + "|foo_val |bar_val |\n" + "|foo_val1|bar_val1 |"; - Assert.AreEqual(expected, table.ToString()); + Assert.That(table.ToString(), Is.EqualTo(expected)); } [Test] public void ShouldGetValuesForGivenColumnName() { - var headers = new List {"foo", "bar"}; + var headers = new List { "foo", "bar" }; var table = new Table(headers); - table.AddRow(new List {"foo_val", "bar_val"}); - table.AddRow(new List {"foo_val1", "bar_val1"}); + table.AddRow(new List { "foo_val", "bar_val" }); + table.AddRow(new List { "foo_val1", "bar_val1" }); var columnValues = table.GetColumnValues("foo").ToList(); - Assert.AreEqual(2, columnValues.Count); - Assert.True(columnValues.Contains("foo_val")); - Assert.True(columnValues.Contains("foo_val1")); + Assert.That(columnValues, Has.Count.EqualTo(2)); + Assert.That(columnValues, Does.Contain("foo_val")); + Assert.That(columnValues, Does.Contain("foo_val1")); } } } \ No newline at end of file diff --git a/Gauge.CSharp.Lib/Gauge.CSharp.Lib.csproj b/Gauge.CSharp.Lib/Gauge.CSharp.Lib.csproj index 336713a..f35517f 100644 --- a/Gauge.CSharp.Lib/Gauge.CSharp.Lib.csproj +++ b/Gauge.CSharp.Lib/Gauge.CSharp.Lib.csproj @@ -1,12 +1,12 @@ - net6.0;net7.0;net8.0 + net8.0;net9.0 CSharp bindings for Gauge. Write CSharp step implementation for Gauge specs. https://gauge.org enable - 0.11.3 - 0.11.3.0 - 0.11.3.0 + 0.12.0 + 0.12.0.0 + 0.12.0.0 getgauge ThoughtWorks Inc. Copyright © ThoughtWorks Inc. 2018 @@ -23,11 +23,8 @@ - - - - - + +