Skip to content

Commit 5da9178

Browse files
committed
Upgrade to support .NET 9 and remove support for .NET 6 & 7
1 parent 1efbe80 commit 5da9178

File tree

8 files changed

+129
-119
lines changed

8 files changed

+129
-119
lines changed

Gauge.CSharp.Lib.UnitTests/Attribute/FilteredHookAttributeTests.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System.Linq;
2-
using Gauge.CSharp.Lib.Attribute;
3-
using NUnit.Framework;
1+
using Gauge.CSharp.Lib.Attribute;
42

53
namespace Gauge.CSharp.Lib.UnitTests.Attribute
64
{
@@ -25,26 +23,26 @@ public TestHookAttribute(params string[] filterTags) : base(filterTags)
2523
[Test]
2624
public void ShouldCreateAttributeWithMultipleTags()
2725
{
28-
var filterTags = new[] {"foo", "bar"};
26+
var filterTags = new[] { "foo", "bar" };
2927
var filteredHookAttribute = new TestHookAttribute(filterTags);
3028

3129
foreach (var filterTag in filterTags)
32-
Assert.IsTrue(filteredHookAttribute.FilterTags.Contains(filterTag));
30+
Assert.That(filteredHookAttribute.FilterTags, Does.Contain(filterTag));
3331
}
3432

3533
[Test]
3634
public void ShouldCreateAttributeWithNoParameters()
3735
{
3836
var filteredHookAttribute = new TestHookAttribute();
39-
Assert.IsNotNull(filteredHookAttribute);
37+
Assert.That(filteredHookAttribute, Is.Not.Null);
4038
}
4139

4240
[Test]
4341
public void ShouldCreateAttributeWithOneTag()
4442
{
4543
var filterTag = "foo";
4644
var filteredHookAttribute = new TestHookAttribute(filterTag);
47-
Assert.IsTrue(filteredHookAttribute.FilterTags.Contains(filterTag));
45+
Assert.That(filteredHookAttribute.FilterTags, Does.Contain(filterTag));
4846
}
4947
}
5048
}

Gauge.CSharp.Lib.UnitTests/DataStoreFactoryTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public void Setup()
1818
public void AddDataStore_ShouldSetTheSuiteDataStore_WhenCalledForSuiteDataStoreType()
1919
{
2020
DataStoreFactory.AddDataStore(1, DataStoreType.Suite);
21-
Assert.IsNotNull(DataStoreFactory.SuiteDataStore);
21+
Assert.That(DataStoreFactory.SuiteDataStore, Is.Not.Null);
2222
}
2323

2424
[Test]
@@ -27,21 +27,21 @@ public void AddDataStore_ShouldNotOverwriteTheSuiteDataStore_WhenCalledForSuiteD
2727
DataStoreFactory.AddDataStore(1, DataStoreType.Suite);
2828
var dataStore = DataStoreFactory.SuiteDataStore;
2929
DataStoreFactory.AddDataStore(1, DataStoreType.Suite);
30-
Assert.AreSame(dataStore, DataStoreFactory.SuiteDataStore);
30+
Assert.That(dataStore, Is.SameAs(DataStoreFactory.SuiteDataStore));
3131
}
3232

3333
[Test]
3434
public void AddDataStore_ShouldSetTheSpecDataStore_WhenCalledForSpecDataStoreType()
3535
{
3636
DataStoreFactory.AddDataStore(1, DataStoreType.Spec);
37-
Assert.IsNotNull(DataStoreFactory.GetDataStoresByStream(1)[DataStoreType.Spec]);
37+
Assert.That(DataStoreFactory.GetDataStoresByStream(1)[DataStoreType.Spec], Is.Not.Null);
3838
}
3939

4040
[Test]
4141
public void AddDataStore_ShouldSetTheScenaroDataStore_WhenCalledForScenarioDataStoreType()
4242
{
4343
DataStoreFactory.AddDataStore(1, DataStoreType.Scenario);
44-
Assert.IsNotNull(DataStoreFactory.GetDataStoresByStream(1)[DataStoreType.Scenario]);
44+
Assert.That(DataStoreFactory.GetDataStoresByStream(1)[DataStoreType.Scenario], Is.Not.Null);
4545
}
4646

4747
[Test]
@@ -52,8 +52,8 @@ public void AddDataStore_ShouldKeepSeparateDataStores_WhenCalledForDifferentStre
5252
var dict1 = DataStoreFactory.GetDataStoresByStream(1)[DataStoreType.Scenario];
5353
var dict2 = DataStoreFactory.GetDataStoresByStream(2)[DataStoreType.Scenario];
5454

55-
Assert.AreNotSame(dict1, dict2);
55+
Assert.That(dict1, Is.Not.SameAs(dict2));
5656
dict1.Add("mykey", new object());
57-
Assert.IsNull(dict2.Get("mykey"));
57+
Assert.That(dict2.Get("mykey"), Is.Null);
5858
}
5959
}

Gauge.CSharp.Lib.UnitTests/DataStoreTests.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void ShouldClearDataStore()
2727
_dataStore.Add("fruit", "apple");
2828
_dataStore.Clear();
2929

30-
Assert.AreEqual(_dataStore.Count, 0);
30+
Assert.That(_dataStore.Count, Is.EqualTo(0));
3131
}
3232

3333
[Test]
@@ -36,7 +36,7 @@ public void ShouldGetNullWhenKeyDoesNotExist()
3636
_dataStore.Add("fruit", "banana");
3737
var fruit = _dataStore.Get("banana");
3838

39-
Assert.IsNull(fruit);
39+
Assert.That(fruit, Is.Null);
4040
}
4141

4242
[Test]
@@ -45,14 +45,14 @@ public void ShouldGetStrongTypedValue()
4545
_dataStore.Add("banana", new Fruit { Name = "Banana" });
4646
var fruit = _dataStore.Get<Fruit>("banana");
4747

48-
Assert.IsInstanceOf<Fruit>(fruit);
49-
Assert.AreEqual("Banana", fruit.Name);
48+
Assert.That(fruit, Is.InstanceOf<Fruit>());
49+
Assert.That(fruit.Name, Is.EqualTo("Banana"));
5050
}
5151

5252
[Test]
5353
public void ShouldInitializeDataStore()
5454
{
55-
Assert.AreEqual(_dataStore.Count, 0);
55+
Assert.That(_dataStore.Count, Is.EqualTo(0));
5656
}
5757

5858
public class Sample
@@ -68,16 +68,16 @@ public void ShouldInsertComplexTypeIntoDataStore()
6868
_dataStore.Add("bar", new Sample { Name = "Hello", Country = "India" });
6969
var value = _dataStore.Get("bar") as Sample;
7070

71-
Assert.AreEqual(value.Name, "Hello");
71+
Assert.That(value.Name, Is.EqualTo("Hello"));
7272
}
7373

7474
[Test]
7575
public void ShouldInsertValueIntoDataStore()
7676
{
7777
_dataStore.Add("foo", 23);
7878

79-
Assert.AreEqual(_dataStore.Count, 1);
80-
Assert.AreEqual(_dataStore.Get("foo"), 23);
79+
Assert.That(_dataStore.Count, Is.EqualTo(1));
80+
Assert.That(_dataStore.Get("foo"), Is.EqualTo(23));
8181
}
8282

8383
[Test]
@@ -95,7 +95,7 @@ public void ShouldReturnNullWhenAskingForInvalidKeyWithStrongType()
9595

9696
var fruit = _dataStore.Get<Fruit>("random");
9797

98-
Assert.IsNull(fruit);
98+
Assert.That(fruit, Is.Null);
9999
}
100100

101101
[Test]
@@ -112,6 +112,6 @@ public void ShouldUpdateDataForGivenKey()
112112

113113
var value = _dataStore.Get("foo");
114114

115-
Assert.AreEqual(value, "rumpelstiltskin");
115+
Assert.That(value, Is.EqualTo("rumpelstiltskin"));
116116
}
117117
}

Gauge.CSharp.Lib.UnitTests/DefaultClassInstanceManagerTests.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public void ShouldGetInstanceForType()
2121
var type = typeof(object);
2222
var instance = new DefaultClassInstanceManager().Get(type);
2323

24-
Assert.NotNull(instance);
25-
Assert.AreEqual(instance.GetType(), type);
24+
Assert.That(instance, Is.Not.Null);
25+
Assert.That(instance.GetType(), Is.EqualTo(type));
2626
}
2727

2828
[Test]
@@ -33,7 +33,7 @@ public void ShouldGetMemoizedInstanceForType()
3333
var instance = instanceManager.Get(type);
3434
var anotherInstance = instanceManager.Get(type);
3535

36-
Assert.AreSame(instance, anotherInstance);
36+
Assert.That(instance, Is.SameAs(anotherInstance));
3737
}
3838

3939
[Test]
@@ -45,7 +45,7 @@ public async Task InvokeMethod_ShouldCreateInstanceAndInvokeMethod_WhenInstanceI
4545

4646
await instanceManager.InvokeMethod(methodInfo, 1);
4747

48-
Assert.IsTrue(MethodInvokeTests.InvokeMethod1Called);
48+
Assert.That(MethodInvokeTests.InvokeMethod1Called);
4949
}
5050

5151
[Test]
@@ -60,7 +60,7 @@ public async Task InvokeMethod_ShouldSetDataStores_WhenDataStoresAreInitialized(
6060

6161
await instanceManager.InvokeMethod(methodInfo, 1);
6262

63-
Assert.IsTrue(MethodInvokeTests.InvokeMethod2Called);
63+
Assert.That(MethodInvokeTests.InvokeMethod2Called);
6464
}
6565

6666
[Test]
@@ -72,7 +72,7 @@ public async Task InvokeMethod_ShouldNotFail_WhenMethodInvokedIsNotAsync()
7272

7373
await instanceManager.InvokeMethod(methodInfo, 1);
7474

75-
Assert.IsTrue(MethodInvokeTests.InvokeMethod3Called);
75+
Assert.That(MethodInvokeTests.InvokeMethod3Called);
7676
}
7777
}
7878

@@ -91,9 +91,12 @@ public Task InvokeMethod1()
9191
public Task InvokeMethod2()
9292
{
9393
InvokeMethod2Called = true;
94-
Assert.IsNotNull(SuiteDataStore.Store.Value);
95-
Assert.IsNotNull(SpecDataStore.Store.Value);
96-
Assert.IsNotNull(ScenarioDataStore.Store.Value);
94+
Assert.Multiple(() =>
95+
{
96+
Assert.That(SuiteDataStore.Store.Value, Is.Not.Null);
97+
Assert.That(SpecDataStore.Store.Value, Is.Not.Null);
98+
Assert.That(ScenarioDataStore.Store.Value, Is.Not.Null);
99+
});
97100
return Task.CompletedTask;
98101
}
99102

Gauge.CSharp.Lib.UnitTests/Gauge.CSharp.Lib.UnitTests.csproj

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
10-
<PackageReference Include="NUnit" Version="3.13.3" />
11-
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
9+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
10+
<PackageReference Include="NUnit" Version="4.2.2" />
11+
<PackageReference Include="NUnit.Analyzers" Version="4.4.0">
12+
<PrivateAssets>all</PrivateAssets>
13+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
14+
</PackageReference>
15+
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
1216
</ItemGroup>
1317

1418
<ItemGroup>

0 commit comments

Comments
 (0)