Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update dependency xunit to v3 #331

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project>

<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>

<ItemGroup Label="src">
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.1" />
Expand All @@ -15,7 +15,7 @@
<PackageVersion Include="System.Threading.Channels" Version="6.0.0" />
<PackageVersion Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>

<ItemGroup Label="test">
<PackageVersion Include="AutoFixture" Version="4.18.1" />
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
Expand All @@ -28,13 +28,13 @@
<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.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="xunit.v3" Version="1.0.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="8.0.11" />
</ItemGroup>

<ItemGroup Condition="'$(OS)' == 'Unix'">
<PackageVersion Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ public class FeatureLifecycleManagerTests
{
private readonly FeatureLifecycleManager _systemUnderTest;
private readonly IServiceProvider _mockServiceProvider;
private readonly CancellationToken _testCancellationToken;

public FeatureLifecycleManagerTests()
{
this._testCancellationToken = TestContext.Current.CancellationToken;
Api.Instance.SetContext(null);
Api.Instance.ClearHooks();

Expand All @@ -41,7 +43,7 @@ public async Task EnsureInitializedAsync_ShouldLogAndSetProvider_WhenProviderExi
_mockServiceProvider.GetService(typeof(FeatureProvider)).Returns(featureProvider);

// Act
await _systemUnderTest.EnsureInitializedAsync().ConfigureAwait(true);
await _systemUnderTest.EnsureInitializedAsync(_testCancellationToken).ConfigureAwait(true);

// Assert
Api.Instance.GetProvider().Should().BeSameAs(featureProvider);
Expand All @@ -54,7 +56,7 @@ public async Task EnsureInitializedAsync_ShouldThrowException_WhenProviderDoesNo
_mockServiceProvider.GetService(typeof(FeatureProvider)).Returns(null as FeatureProvider);

// Act
var act = () => _systemUnderTest.EnsureInitializedAsync().AsTask();
var act = () => _systemUnderTest.EnsureInitializedAsync(_testCancellationToken).AsTask();

// Assert
var exception = await Assert.ThrowsAsync<InvalidOperationException>(act).ConfigureAwait(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NSubstitute" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
2 changes: 1 addition & 1 deletion test/OpenFeature.E2ETests/OpenFeature.E2ETests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<PackageReference Include="SpecFlow.xUnit" />
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ namespace OpenFeature.IntegrationTests;

public class FeatureFlagIntegrationTest
{
public FeatureFlagIntegrationTest()
{
this._testCancellationToken = TestContext.Current.CancellationToken;
}

private readonly CancellationToken _testCancellationToken;

// TestUserId is "off", other users are "on"
private const string FeatureA = "feature-a";
private const string TestUserId = "123";
Expand Down Expand Up @@ -50,8 +57,8 @@ public async Task VerifyFeatureFlagBehaviorAcrossServiceLifetimesAsync(string us
var requestUri = $"/features/{userId}/flags/{FeatureA}";

// Act
var response = await client.GetAsync(requestUri).ConfigureAwait(true);
var responseContent = await response.Content.ReadFromJsonAsync<FeatureFlagResponse<bool>>().ConfigureAwait(true); ;
var response = await client.GetAsync(requestUri, _testCancellationToken).ConfigureAwait(true);
var responseContent = await response.Content.ReadFromJsonAsync<FeatureFlagResponse<bool>>(cancellationToken: _testCancellationToken).ConfigureAwait(true); ;

// Assert
response.IsSuccessStatusCode.Should().BeTrue("Expected HTTP status code 200 OK.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageReference Include="coverlet.collector" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="FluentAssertions" />
<PackageReference Include="NSubstitute" />
Expand Down
10 changes: 7 additions & 3 deletions test/OpenFeature.Tests/ClearOpenFeatureInstanceFixture.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
using System.Threading.Tasks;
using System.Threading;
using Xunit;

namespace OpenFeature.Tests;

public class ClearOpenFeatureInstanceFixture : IAsyncLifetime
{
public Task InitializeAsync()
protected CancellationToken TestCancellationToken;

public ValueTask InitializeAsync()
{
this.TestCancellationToken = TestContext.Current.CancellationToken;
Api.ResetApi();

return Task.CompletedTask;
return ValueTask.CompletedTask;
}

// Make sure the singleton is cleared between tests
public async Task DisposeAsync()
public async ValueTask DisposeAsync()
{
await Api.Instance.ShutdownAsync().ConfigureAwait(false);
}
Expand Down
45 changes: 19 additions & 26 deletions test/OpenFeature.Tests/FeatureProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,27 @@ public async Task Provider_Must_Resolve_Flag_Values()

var boolResolutionDetails = new ResolutionDetails<bool>(flagName, defaultBoolValue, ErrorType.None,
NoOpProvider.ReasonNoOp, NoOpProvider.Variant);
(await provider.ResolveBooleanValueAsync(flagName, defaultBoolValue)).Should()
(await provider.ResolveBooleanValueAsync(flagName, defaultBoolValue, cancellationToken: this.TestCancellationToken)).Should()
.BeEquivalentTo(boolResolutionDetails);

var integerResolutionDetails = new ResolutionDetails<int>(flagName, defaultIntegerValue, ErrorType.None,
NoOpProvider.ReasonNoOp, NoOpProvider.Variant);
(await provider.ResolveIntegerValueAsync(flagName, defaultIntegerValue)).Should()
(await provider.ResolveIntegerValueAsync(flagName, defaultIntegerValue, cancellationToken: this.TestCancellationToken)).Should()
.BeEquivalentTo(integerResolutionDetails);

var doubleResolutionDetails = new ResolutionDetails<double>(flagName, defaultDoubleValue, ErrorType.None,
NoOpProvider.ReasonNoOp, NoOpProvider.Variant);
(await provider.ResolveDoubleValueAsync(flagName, defaultDoubleValue)).Should()
(await provider.ResolveDoubleValueAsync(flagName, defaultDoubleValue, cancellationToken: this.TestCancellationToken)).Should()
.BeEquivalentTo(doubleResolutionDetails);

var stringResolutionDetails = new ResolutionDetails<string>(flagName, defaultStringValue, ErrorType.None,
NoOpProvider.ReasonNoOp, NoOpProvider.Variant);
(await provider.ResolveStringValueAsync(flagName, defaultStringValue)).Should()
(await provider.ResolveStringValueAsync(flagName, defaultStringValue, cancellationToken: this.TestCancellationToken)).Should()
.BeEquivalentTo(stringResolutionDetails);

var structureResolutionDetails = new ResolutionDetails<Value>(flagName, defaultStructureValue,
ErrorType.None, NoOpProvider.ReasonNoOp, NoOpProvider.Variant);
(await provider.ResolveStructureValueAsync(flagName, defaultStructureValue)).Should()
(await provider.ResolveStructureValueAsync(flagName, defaultStructureValue, cancellationToken: this.TestCancellationToken)).Should()
.BeEquivalentTo(structureResolutionDetails);
}

Expand All @@ -84,59 +84,52 @@ public async Task Provider_Must_ErrorType()
var providerMock = Substitute.For<FeatureProvider>();
const string testMessage = "An error message";

providerMock.ResolveBooleanValueAsync(flagName, defaultBoolValue, Arg.Any<EvaluationContext>())
.Returns(new ResolutionDetails<bool>(flagName, defaultBoolValue, ErrorType.General,
providerMock.ResolveBooleanValueAsync(flagName, defaultBoolValue, Arg.Any<EvaluationContext>(), this.TestCancellationToken).Returns(new ResolutionDetails<bool>(flagName, defaultBoolValue, ErrorType.General,
NoOpProvider.ReasonNoOp, NoOpProvider.Variant, testMessage));

providerMock.ResolveIntegerValueAsync(flagName, defaultIntegerValue, Arg.Any<EvaluationContext>())
.Returns(new ResolutionDetails<int>(flagName, defaultIntegerValue, ErrorType.ParseError,
providerMock.ResolveIntegerValueAsync(flagName, defaultIntegerValue, Arg.Any<EvaluationContext>(), this.TestCancellationToken).Returns(new ResolutionDetails<int>(flagName, defaultIntegerValue, ErrorType.ParseError,
NoOpProvider.ReasonNoOp, NoOpProvider.Variant, testMessage));

providerMock.ResolveDoubleValueAsync(flagName, defaultDoubleValue, Arg.Any<EvaluationContext>())
.Returns(new ResolutionDetails<double>(flagName, defaultDoubleValue, ErrorType.InvalidContext,
providerMock.ResolveDoubleValueAsync(flagName, defaultDoubleValue, Arg.Any<EvaluationContext>(), this.TestCancellationToken).Returns(new ResolutionDetails<double>(flagName, defaultDoubleValue, ErrorType.InvalidContext,
NoOpProvider.ReasonNoOp, NoOpProvider.Variant, testMessage));

providerMock.ResolveStringValueAsync(flagName, defaultStringValue, Arg.Any<EvaluationContext>())
.Returns(new ResolutionDetails<string>(flagName, defaultStringValue, ErrorType.TypeMismatch,
providerMock.ResolveStringValueAsync(flagName, defaultStringValue, Arg.Any<EvaluationContext>(), this.TestCancellationToken).Returns(new ResolutionDetails<string>(flagName, defaultStringValue, ErrorType.TypeMismatch,
NoOpProvider.ReasonNoOp, NoOpProvider.Variant, testMessage));

providerMock.ResolveStructureValueAsync(flagName, defaultStructureValue, Arg.Any<EvaluationContext>())
.Returns(new ResolutionDetails<Value>(flagName, defaultStructureValue, ErrorType.FlagNotFound,
providerMock.ResolveStructureValueAsync(flagName, defaultStructureValue, Arg.Any<EvaluationContext>(), this.TestCancellationToken).Returns(new ResolutionDetails<Value>(flagName, defaultStructureValue, ErrorType.FlagNotFound,
NoOpProvider.ReasonNoOp, NoOpProvider.Variant, testMessage));

providerMock.ResolveStructureValueAsync(flagName2, defaultStructureValue, Arg.Any<EvaluationContext>())
.Returns(new ResolutionDetails<Value>(flagName2, defaultStructureValue, ErrorType.ProviderNotReady,
providerMock.ResolveStructureValueAsync(flagName2, defaultStructureValue, Arg.Any<EvaluationContext>(), this.TestCancellationToken).Returns(new ResolutionDetails<Value>(flagName2, defaultStructureValue, ErrorType.ProviderNotReady,
NoOpProvider.ReasonNoOp, NoOpProvider.Variant, testMessage));

providerMock.ResolveBooleanValueAsync(flagName2, defaultBoolValue, Arg.Any<EvaluationContext>())
.Returns(new ResolutionDetails<bool>(flagName2, defaultBoolValue, ErrorType.TargetingKeyMissing,
providerMock.ResolveBooleanValueAsync(flagName2, defaultBoolValue, Arg.Any<EvaluationContext>(), this.TestCancellationToken).Returns(new ResolutionDetails<bool>(flagName2, defaultBoolValue, ErrorType.TargetingKeyMissing,
NoOpProvider.ReasonNoOp, NoOpProvider.Variant));

var boolRes = await providerMock.ResolveBooleanValueAsync(flagName, defaultBoolValue);
var boolRes = await providerMock.ResolveBooleanValueAsync(flagName, defaultBoolValue, cancellationToken: this.TestCancellationToken);
boolRes.ErrorType.Should().Be(ErrorType.General);
boolRes.ErrorMessage.Should().Be(testMessage);

var intRes = await providerMock.ResolveIntegerValueAsync(flagName, defaultIntegerValue);
var intRes = await providerMock.ResolveIntegerValueAsync(flagName, defaultIntegerValue, cancellationToken: this.TestCancellationToken);
intRes.ErrorType.Should().Be(ErrorType.ParseError);
intRes.ErrorMessage.Should().Be(testMessage);

var doubleRes = await providerMock.ResolveDoubleValueAsync(flagName, defaultDoubleValue);
var doubleRes = await providerMock.ResolveDoubleValueAsync(flagName, defaultDoubleValue, cancellationToken: this.TestCancellationToken);
doubleRes.ErrorType.Should().Be(ErrorType.InvalidContext);
doubleRes.ErrorMessage.Should().Be(testMessage);

var stringRes = await providerMock.ResolveStringValueAsync(flagName, defaultStringValue);
var stringRes = await providerMock.ResolveStringValueAsync(flagName, defaultStringValue, cancellationToken: this.TestCancellationToken);
stringRes.ErrorType.Should().Be(ErrorType.TypeMismatch);
stringRes.ErrorMessage.Should().Be(testMessage);

var structRes1 = await providerMock.ResolveStructureValueAsync(flagName, defaultStructureValue);
var structRes1 = await providerMock.ResolveStructureValueAsync(flagName, defaultStructureValue, cancellationToken: this.TestCancellationToken);
structRes1.ErrorType.Should().Be(ErrorType.FlagNotFound);
structRes1.ErrorMessage.Should().Be(testMessage);

var structRes2 = await providerMock.ResolveStructureValueAsync(flagName2, defaultStructureValue);
var structRes2 = await providerMock.ResolveStructureValueAsync(flagName2, defaultStructureValue, cancellationToken: this.TestCancellationToken);
structRes2.ErrorType.Should().Be(ErrorType.ProviderNotReady);
structRes2.ErrorMessage.Should().Be(testMessage);

var boolRes2 = await providerMock.ResolveBooleanValueAsync(flagName2, defaultBoolValue);
var boolRes2 = await providerMock.ResolveBooleanValueAsync(flagName2, defaultBoolValue, cancellationToken: this.TestCancellationToken);
boolRes2.ErrorType.Should().Be(ErrorType.TargetingKeyMissing);
boolRes2.ErrorMessage.Should().BeNull();
}
Expand Down
2 changes: 1 addition & 1 deletion test/OpenFeature.Tests/OpenFeature.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NSubstitute" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
Loading
Loading