Skip to content
Draft
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
6 changes: 3 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
<PackageVersion Include="NSubstitute" Version="5.3.0" />
<PackageVersion Include="OpenTelemetry" Version="1.14.0" />
<PackageVersion Include="OpenTelemetry.Exporter.InMemory" Version="1.14.0" />
<PackageVersion Include="Reqnroll.xUnit" Version="3.3.0" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="Reqnroll.xunit.v3" Version="3.3.0" />
<PackageVersion Include="xunit.v3.mtp-v2" Version="3.2.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
Expand Down
3 changes: 3 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"rollForward": "latestFeature",
"version": "10.0.100",
"allowPrerelease": false
},
"test": {
"runner": "Microsoft.Testing.Platform"
}
}
5 changes: 3 additions & 2 deletions test/OpenFeature.E2ETests/OpenFeature.E2ETests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<RootNamespace>OpenFeature.E2ETests</RootNamespace>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
Expand All @@ -14,10 +15,10 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Reqnroll.xUnit" />
<PackageReference Include="Reqnroll.xUnit.v3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NSubstitute" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3.mtp-v2" />
<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/Steps/ExcludedTagsStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public class ExcludedTagsStep
[BeforeScenario]
public static void BeforeScenario()
{
Skip.If(true, "Tag is not supported");
Assert.SkipWhen(true, "Tag is not supported");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public async Task EnsureInitializedAsync_SetsProvider()
// Act
using var serviceProvider = services.BuildServiceProvider();
var lifecycleManager = new FeatureLifecycleManager(api, serviceProvider, NullLogger<FeatureLifecycleManager>.Instance);
await lifecycleManager.EnsureInitializedAsync();
await lifecycleManager.EnsureInitializedAsync(TestContext.Current.CancellationToken);

// Assert
var actualProvider = api.GetProvider();
Expand All @@ -53,7 +53,7 @@ public async Task EnsureInitializedAsync_SetsMultipleProvider()
// Act
using var serviceProvider = services.BuildServiceProvider();
var lifecycleManager = new FeatureLifecycleManager(api, serviceProvider, NullLogger<FeatureLifecycleManager>.Instance);
await lifecycleManager.EnsureInitializedAsync();
await lifecycleManager.EnsureInitializedAsync(TestContext.Current.CancellationToken);

// Assert
Assert.Equal(provider1, api.GetProvider("provider1"));
Expand All @@ -80,7 +80,7 @@ public async Task EnsureInitializedAsync_AddsHooks()
// Act
using var serviceProvider = services.BuildServiceProvider();
var lifecycleManager = new FeatureLifecycleManager(api, serviceProvider, NullLogger<FeatureLifecycleManager>.Instance);
await lifecycleManager.EnsureInitializedAsync();
await lifecycleManager.EnsureInitializedAsync(TestContext.Current.CancellationToken);

// Assert
var actualHooks = api.GetHooks();
Expand Down Expand Up @@ -108,7 +108,7 @@ public async Task EnsureInitializedAsync_AddHandlers()
// Act
using var serviceProvider = services.BuildServiceProvider();
var lifecycleManager = new FeatureLifecycleManager(api, serviceProvider, NullLogger<FeatureLifecycleManager>.Instance);
await lifecycleManager.EnsureInitializedAsync();
await lifecycleManager.EnsureInitializedAsync(TestContext.Current.CancellationToken);

// Assert
Assert.True(hookExecuted);
Expand All @@ -122,13 +122,13 @@ public async Task ShutdownAsync_ResetsApi()
var provider = new NoOpFeatureProvider();

var api = Api.Instance;
await api.SetProviderAsync(provider);
await api.SetProviderAsync(provider, TestContext.Current.CancellationToken);
api.AddHooks(new NoOpHook());

// Act
using var serviceProvider = services.BuildServiceProvider();
var lifecycleManager = new FeatureLifecycleManager(api, serviceProvider, NullLogger<FeatureLifecycleManager>.Instance);
await lifecycleManager.ShutdownAsync();
await lifecycleManager.ShutdownAsync(TestContext.Current.CancellationToken);

// Assert
var actualProvider = api.GetProvider();
Expand All @@ -154,7 +154,7 @@ public async Task EnsureInitializedAsync_LogStartingInitialization()
// Act
using var serviceProvider = services.BuildServiceProvider();
var lifecycleManager = new FeatureLifecycleManager(api, serviceProvider, logger);
await lifecycleManager.EnsureInitializedAsync();
await lifecycleManager.EnsureInitializedAsync(TestContext.Current.CancellationToken);

// Assert
var log = logger.LatestRecord;
Expand All @@ -181,7 +181,7 @@ public async Task ShutdownAsync_LogShuttingDown()
// Act
using var serviceProvider = services.BuildServiceProvider();
var lifecycleManager = new FeatureLifecycleManager(api, serviceProvider, logger);
await lifecycleManager.ShutdownAsync();
await lifecycleManager.ShutdownAsync(TestContext.Current.CancellationToken);

// Assert
var log = logger.LatestRecord;
Expand All @@ -190,13 +190,13 @@ public async Task ShutdownAsync_LogShuttingDown()
Assert.Equal(LogLevel.Information, log.Level);
}

public async Task InitializeAsync()
public async ValueTask InitializeAsync()
{
await Api.Instance.ShutdownAsync();
}

// Make sure the singleton is cleared between tests
public async Task DisposeAsync()
public async ValueTask DisposeAsync()
{
await Api.Instance.ShutdownAsync().ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<RootNamespace>OpenFeature.Hosting.Tests</RootNamespace>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
Expand All @@ -17,7 +18,7 @@
<PackageReference Include="Microsoft.Extensions.Diagnostics.Testing" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NSubstitute" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3.mtp-v2" />
<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 @@ -48,7 +48,7 @@ public async Task AddInMemoryProvider_WithFlags_AddsProvider()
Assert.NotNull(featureProvider);
Assert.IsType<InMemoryProvider>(featureProvider);

var result = await featureProvider.ResolveBooleanValueAsync("feature1", false);
var result = await featureProvider.ResolveBooleanValueAsync("feature1", false, cancellationToken: TestContext.Current.CancellationToken);
Assert.True(result.Value);
}

Expand Down Expand Up @@ -130,7 +130,7 @@ public async Task AddInMemoryProvider_WithDomainAndFlags_AddsProvider()
Assert.IsType<InMemoryProvider>(featureProvider);

var context = EvaluationContext.Builder().Set("group", "alpha").Build();
var result = await featureProvider.ResolveBooleanValueAsync("feature2", false, context);
var result = await featureProvider.ResolveBooleanValueAsync("feature2", false, context, TestContext.Current.CancellationToken);
Assert.True(result.Value);
}

Expand Down Expand Up @@ -178,7 +178,7 @@ public async Task AddInMemoryProvider_WithOptions_AddsProvider()
Assert.NotNull(featureProvider);
Assert.IsType<InMemoryProvider>(featureProvider);

var result = await featureProvider.ResolveBooleanValueAsync("new-feature", true);
var result = await featureProvider.ResolveBooleanValueAsync("new-feature", true, cancellationToken: TestContext.Current.CancellationToken);
Assert.False(result.Value);
}

Expand Down Expand Up @@ -208,7 +208,7 @@ public async Task AddInMemoryProvider_WithDomainAndOptions_AddsProvider()
Assert.NotNull(featureProvider);
Assert.IsType<InMemoryProvider>(featureProvider);

var result = await featureProvider.ResolveBooleanValueAsync("new-feature", true);
var result = await featureProvider.ResolveBooleanValueAsync("new-feature", true, cancellationToken: TestContext.Current.CancellationToken);
Assert.False(result.Value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,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, TestContext.Current.CancellationToken).ConfigureAwait(true);
var responseContent = await response.Content.ReadFromJsonAsync<FeatureFlagResponse<bool>>(cancellationToken: TestContext.Current.CancellationToken).ConfigureAwait(true);

// Assert
Assert.True(response.IsSuccessStatusCode, "Expected HTTP status code 200 OK.");
Expand Down Expand Up @@ -85,7 +85,7 @@ public async Task VerifyLoggingHookIsRegisteredAsync()
var requestUri = $"/features/{TestUserId}/flags/{FeatureA}";

// Act
var response = await client.GetAsync(requestUri).ConfigureAwait(true);
var response = await client.GetAsync(requestUri, TestContext.Current.CancellationToken).ConfigureAwait(true);
var logs = logger.Collector.GetSnapshot();

// Assert
Expand Down Expand Up @@ -120,7 +120,7 @@ public async Task VerifyHandlerIsRegisteredAsync()
var requestUri = $"/features/{TestUserId}/flags/{FeatureA}";

// Act
var response = await client.GetAsync(requestUri).ConfigureAwait(true);
var response = await client.GetAsync(requestUri, TestContext.Current.CancellationToken).ConfigureAwait(true);

// Assert
Assert.True(response.IsSuccessStatusCode, "Expected HTTP status code 200 OK.");
Expand Down Expand Up @@ -152,7 +152,7 @@ public async Task VerifyMultipleHandlersAreRegisteredAsync()
var requestUri = $"/features/{TestUserId}/flags/{FeatureA}";

// Act
var response = await client.GetAsync(requestUri).ConfigureAwait(true);
var response = await client.GetAsync(requestUri, TestContext.Current.CancellationToken).ConfigureAwait(true);

// Assert
Assert.True(response.IsSuccessStatusCode, "Expected HTTP status code 200 OK.");
Expand Down Expand Up @@ -191,7 +191,7 @@ public async Task VerifyHandlersAreRegisteredWithServiceProviderAsync()
var requestUri = $"/features/{TestUserId}/flags/{FeatureA}";

// Act
var response = await client.GetAsync(requestUri).ConfigureAwait(true);
var response = await client.GetAsync(requestUri, TestContext.Current.CancellationToken).ConfigureAwait(true);

// Assert
Assert.True(response.IsSuccessStatusCode, "Expected HTTP status code 200 OK.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
Expand All @@ -16,7 +17,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.Testing" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3.mtp-v2" />
<PackageReference Include="xunit.runner.visualstudio">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
Loading
Loading