Skip to content

Commit

Permalink
test: Upgrade test deps
Browse files Browse the repository at this point in the history
- Autofixture 4.17 -> 4.18.1
- coverlet 3.1.2 -> 6.0.0
- FluentAssertions 6.7.0 -> 6.12.0
- MSN.Test.Sdk 17.2.0 -> 17.9.0
- NSubstitue 5 -> 5.1
- FlagD Provider 0.1.5 -> 0.1.8
- Xunit 2.4.1 -> 2.6.6

Signed-off-by: Benjamin Evenson <[email protected]>
  • Loading branch information
benjiro committed Feb 8, 2024
1 parent cc6c404 commit 1ebabae
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 40 deletions.
12 changes: 6 additions & 6 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
</ItemGroup>

<ItemGroup Label="test">
<PackageVersion Include="AutoFixture" Version="4.17.0" />
<PackageVersion Include="AutoFixture" Version="4.18.1" />
<PackageVersion Include="BenchmarkDotNet" Version="0.13.1" />
<PackageVersion Include="coverlet.collector" Version="3.1.2" />
<PackageVersion Include="coverlet.msbuild" Version="3.1.2" />
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="GitHubActionsTestLogger" Version="2.3.3" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageVersion Include="NSubstitute" Version="5.1.0" />
<PackageVersion Include="OpenFeature.Contrib.Providers.Flagd" Version="0.1.8" />
<PackageVersion Include="SpecFlow" Version="3.9.74" />
<PackageVersion Include="SpecFlow.Tools.MsBuild.Generation" Version="3.9.74" />
<PackageVersion Include="SpecFlow.xUnit" Version="3.9.74" />
<PackageVersion Include="xunit" Version="[2.4.1, 3.0)" />
<PackageVersion Include="xunit.runner.visualstudio" Version="[2.4.3, 3.0)" />
<PackageVersion Include="xunit" Version="2.6.6" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.6" />
</ItemGroup>

<ItemGroup Condition="'$(OS)' == 'Unix'">
Expand Down
54 changes: 28 additions & 26 deletions test/OpenFeature.Tests/OpenFeatureTests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading.Tasks;
using FluentAssertions;
Expand All @@ -9,6 +10,7 @@

namespace OpenFeature.Tests
{
[SuppressMessage("Reliability", "CA2007:Consider calling ConfigureAwait on the awaited task")]
public class OpenFeatureTests : ClearOpenFeatureInstanceFixture
{
[Fact]
Expand All @@ -28,14 +30,14 @@ public async Task OpenFeature_Should_Initialize_Provider()
var providerMockDefault = Substitute.For<FeatureProvider>();
providerMockDefault.GetStatus().Returns(ProviderStatus.NotReady);

await Api.Instance.SetProviderAsync(providerMockDefault).ConfigureAwait(false);
await providerMockDefault.Received(1).Initialize(Api.Instance.GetContext()).ConfigureAwait(false);
await Api.Instance.SetProviderAsync(providerMockDefault);
await providerMockDefault.Received(1).Initialize(Api.Instance.GetContext());

var providerMockNamed = Substitute.For<FeatureProvider>();
providerMockNamed.GetStatus().Returns(ProviderStatus.NotReady);

await Api.Instance.SetProviderAsync("the-name", providerMockNamed).ConfigureAwait(false);
await providerMockNamed.Received(1).Initialize(Api.Instance.GetContext()).ConfigureAwait(false);
await Api.Instance.SetProviderAsync("the-name", providerMockNamed);
await providerMockNamed.Received(1).Initialize(Api.Instance.GetContext());
}

[Fact]
Expand All @@ -46,28 +48,28 @@ public async Task OpenFeature_Should_Shutdown_Unused_Provider()
var providerA = Substitute.For<FeatureProvider>();
providerA.GetStatus().Returns(ProviderStatus.NotReady);

await Api.Instance.SetProviderAsync(providerA).ConfigureAwait(false);
await providerA.Received(1).Initialize(Api.Instance.GetContext()).ConfigureAwait(false);
await Api.Instance.SetProviderAsync(providerA);
await providerA.Received(1).Initialize(Api.Instance.GetContext());

var providerB = Substitute.For<FeatureProvider>();
providerB.GetStatus().Returns(ProviderStatus.NotReady);

await Api.Instance.SetProviderAsync(providerB).ConfigureAwait(false);
await providerB.Received(1).Initialize(Api.Instance.GetContext()).ConfigureAwait(false);
await providerA.Received(1).Shutdown().ConfigureAwait(false);
await Api.Instance.SetProviderAsync(providerB);
await providerB.Received(1).Initialize(Api.Instance.GetContext());
await providerA.Received(1).Shutdown();

var providerC = Substitute.For<FeatureProvider>();
providerC.GetStatus().Returns(ProviderStatus.NotReady);

await Api.Instance.SetProviderAsync("named", providerC).ConfigureAwait(false);
await providerC.Received(1).Initialize(Api.Instance.GetContext()).ConfigureAwait(false);
await Api.Instance.SetProviderAsync("named", providerC);
await providerC.Received(1).Initialize(Api.Instance.GetContext());

var providerD = Substitute.For<FeatureProvider>();
providerD.GetStatus().Returns(ProviderStatus.NotReady);

await Api.Instance.SetProviderAsync("named", providerD).ConfigureAwait(false);
await providerD.Received(1).Initialize(Api.Instance.GetContext()).ConfigureAwait(false);
await providerC.Received(1).Shutdown().ConfigureAwait(false);
await Api.Instance.SetProviderAsync("named", providerD);
await providerD.Received(1).Initialize(Api.Instance.GetContext());
await providerC.Received(1).Shutdown();
}

[Fact]
Expand All @@ -80,13 +82,13 @@ public async Task OpenFeature_Should_Support_Shutdown()
var providerB = Substitute.For<FeatureProvider>();
providerB.GetStatus().Returns(ProviderStatus.NotReady);

await Api.Instance.SetProviderAsync(providerA).ConfigureAwait(false);
await Api.Instance.SetProviderAsync("named", providerB).ConfigureAwait(false);
await Api.Instance.SetProviderAsync(providerA);
await Api.Instance.SetProviderAsync("named", providerB);

await Api.Instance.Shutdown().ConfigureAwait(false);
await Api.Instance.Shutdown();

await providerA.Received(1).Shutdown().ConfigureAwait(false);
await providerB.Received(1).Shutdown().ConfigureAwait(false);
await providerA.Received(1).Shutdown();
await providerB.Received(1).Shutdown();
}

[Fact]
Expand All @@ -95,8 +97,8 @@ public async Task OpenFeature_Should_Not_Change_Named_Providers_When_Setting_Def
{
var openFeature = Api.Instance;

await openFeature.SetProviderAsync(new NoOpFeatureProvider()).ConfigureAwait(false);
await openFeature.SetProviderAsync(TestProvider.DefaultName, new TestProvider()).ConfigureAwait(false);
await openFeature.SetProviderAsync(new NoOpFeatureProvider());
await openFeature.SetProviderAsync(TestProvider.DefaultName, new TestProvider());

var defaultClient = openFeature.GetProviderMetadata();
var namedClient = openFeature.GetProviderMetadata(TestProvider.DefaultName);
Expand All @@ -111,7 +113,7 @@ public async Task OpenFeature_Should_Set_Default_Provide_When_No_Name_Provided()
{
var openFeature = Api.Instance;

await openFeature.SetProviderAsync(new TestProvider()).ConfigureAwait(false);
await openFeature.SetProviderAsync(new TestProvider());

var defaultClient = openFeature.GetProviderMetadata();

Expand Down Expand Up @@ -178,9 +180,9 @@ public void OpenFeature_Should_Add_Hooks()

[Fact]
[Specification("1.1.5", "The API MUST provide a function for retrieving the metadata field of the configured `provider`.")]
public void OpenFeature_Should_Get_Metadata()
public async Task OpenFeature_Should_Get_Metadata()
{
Api.Instance.SetProviderAsync(new NoOpFeatureProvider()).Wait();
await Api.Instance.SetProviderAsync(new NoOpFeatureProvider());
var openFeature = Api.Instance;
var metadata = openFeature.GetProviderMetadata();

Expand Down Expand Up @@ -239,8 +241,8 @@ public async Task OpenFeature_Should_Allow_Multiple_Client_Mapping()
client1.GetMetadata().Name.Should().Be("client1");
client2.GetMetadata().Name.Should().Be("client2");

client1.GetBooleanValue("test", false).Result.Should().BeTrue();
client2.GetBooleanValue("test", false).Result.Should().BeFalse();
(await client1.GetBooleanValue("test", false)).Should().BeTrue();
(await client2.GetBooleanValue("test", false)).Should().BeFalse();
}
}
}
4 changes: 2 additions & 2 deletions test/OpenFeature.Tests/StructureTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void Values_Should_Return_Values()

var structure = Structure.Builder()
.Set(KEY, VAL).Build();
Assert.Equal(1, structure.Values.Count);
Assert.Single(structure.Values);
}

[Fact]
Expand All @@ -100,7 +100,7 @@ public void Keys_Should_Return_Keys()

var structure = Structure.Builder()
.Set(KEY, VAL).Build();
Assert.Equal(1, structure.Keys.Count);
Assert.Single(structure.Keys);
Assert.Equal(0, structure.Keys.IndexOf(KEY));
}

Expand Down
9 changes: 4 additions & 5 deletions test/OpenFeature.Tests/TestUtilsTest.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using OpenFeature.Model;
using System.Diagnostics.CodeAnalysis;
using Xunit;

namespace OpenFeature.Tests
{
[SuppressMessage("Reliability", "CA2007:Consider calling ConfigureAwait on the awaited task")]
public class TestUtilsTest
{
[Fact]
public async void Should_Fail_If_Assertion_Fails()
{
await Assert.ThrowsAnyAsync<Exception>(() => Utils.AssertUntilAsync(_ => Assert.True(1.Equals(2)), 100, 10)).ConfigureAwait(false);
await Assert.ThrowsAnyAsync<Exception>(() => Utils.AssertUntilAsync(_ => Assert.True(1.Equals(2)), 100, 10));
}

[Fact]
public async void Should_Pass_If_Assertion_Fails()
{
await Utils.AssertUntilAsync(_ => Assert.True(1.Equals(1))).ConfigureAwait(false);
await Utils.AssertUntilAsync(_ => Assert.True(1.Equals(1)));
}
}
}
2 changes: 1 addition & 1 deletion test/OpenFeature.Tests/ValueTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void Int_Object_Arg_Should_Contain_Object()
}
catch (Exception)
{
Assert.True(false, "Expected no exception.");
Assert.Fail("Expected no exception.");
}
}

Expand Down

0 comments on commit 1ebabae

Please sign in to comment.