Skip to content

Commit

Permalink
Upgrade to support .NET 9 and remove support for .NET 6 & 7
Browse files Browse the repository at this point in the history
Signed-off-by: Pekurny, Martin <[email protected]>
  • Loading branch information
mpekurny committed Nov 24, 2024
1 parent 1efbe80 commit a0b7298
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 119 deletions.
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -25,26 +23,26 @@ 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]
public void ShouldCreateAttributeWithOneTag()
{
var filterTag = "foo";
var filteredHookAttribute = new TestHookAttribute(filterTag);
Assert.IsTrue(filteredHookAttribute.FilterTags.Contains(filterTag));
Assert.That(filteredHookAttribute.FilterTags, Does.Contain(filterTag));
}
}
}
12 changes: 6 additions & 6 deletions Gauge.CSharp.Lib.UnitTests/DataStoreFactoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -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);
}
}
20 changes: 10 additions & 10 deletions Gauge.CSharp.Lib.UnitTests/DataStoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -45,14 +45,14 @@ public void ShouldGetStrongTypedValue()
_dataStore.Add("banana", new Fruit { Name = "Banana" });
var fruit = _dataStore.Get<Fruit>("banana");

Assert.IsInstanceOf<Fruit>(fruit);
Assert.AreEqual("Banana", fruit.Name);
Assert.That(fruit, Is.InstanceOf<Fruit>());
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
Expand All @@ -68,16 +68,16 @@ 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]
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]
Expand All @@ -95,7 +95,7 @@ public void ShouldReturnNullWhenAskingForInvalidKeyWithStrongType()

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

Assert.IsNull(fruit);
Assert.That(fruit, Is.Null);
}

[Test]
Expand All @@ -112,6 +112,6 @@ public void ShouldUpdateDataForGivenKey()

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

Assert.AreEqual(value, "rumpelstiltskin");
Assert.That(value, Is.EqualTo("rumpelstiltskin"));
}
}
21 changes: 12 additions & 9 deletions Gauge.CSharp.Lib.UnitTests/DefaultClassInstanceManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -45,7 +45,7 @@ public async Task InvokeMethod_ShouldCreateInstanceAndInvokeMethod_WhenInstanceI

await instanceManager.InvokeMethod(methodInfo, 1);

Assert.IsTrue(MethodInvokeTests.InvokeMethod1Called);
Assert.That(MethodInvokeTests.InvokeMethod1Called);
}

[Test]
Expand All @@ -60,7 +60,7 @@ public async Task InvokeMethod_ShouldSetDataStores_WhenDataStoresAreInitialized(

await instanceManager.InvokeMethod(methodInfo, 1);

Assert.IsTrue(MethodInvokeTests.InvokeMethod2Called);
Assert.That(MethodInvokeTests.InvokeMethod2Called);
}

[Test]
Expand All @@ -72,7 +72,7 @@ public async Task InvokeMethod_ShouldNotFail_WhenMethodInvokedIsNotAsync()

await instanceManager.InvokeMethod(methodInfo, 1);

Assert.IsTrue(MethodInvokeTests.InvokeMethod3Called);
Assert.That(MethodInvokeTests.InvokeMethod3Called);
}
}

Expand All @@ -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;
}

Expand Down
14 changes: 9 additions & 5 deletions Gauge.CSharp.Lib.UnitTests/Gauge.CSharp.Lib.UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit.Analyzers" Version="4.4.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit a0b7298

Please sign in to comment.