diff --git a/Directory.Packages.props b/Directory.Packages.props
index 1dbc878a..41d7af66 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -1,9 +1,9 @@
-
+
true
-
+
@@ -15,7 +15,7 @@
-
+
@@ -28,13 +28,13 @@
-
-
+
+
-
+
-
+
diff --git a/test/OpenFeature.DependencyInjection.Tests/FeatureLifecycleManagerTests.cs b/test/OpenFeature.DependencyInjection.Tests/FeatureLifecycleManagerTests.cs
index b0176bc4..b2aeb105 100644
--- a/test/OpenFeature.DependencyInjection.Tests/FeatureLifecycleManagerTests.cs
+++ b/test/OpenFeature.DependencyInjection.Tests/FeatureLifecycleManagerTests.cs
@@ -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();
@@ -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);
@@ -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(act).ConfigureAwait(true);
diff --git a/test/OpenFeature.DependencyInjection.Tests/OpenFeature.DependencyInjection.Tests.csproj b/test/OpenFeature.DependencyInjection.Tests/OpenFeature.DependencyInjection.Tests.csproj
index 9937e1bc..8c27f710 100644
--- a/test/OpenFeature.DependencyInjection.Tests/OpenFeature.DependencyInjection.Tests.csproj
+++ b/test/OpenFeature.DependencyInjection.Tests/OpenFeature.DependencyInjection.Tests.csproj
@@ -23,7 +23,7 @@
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/test/OpenFeature.E2ETests/OpenFeature.E2ETests.csproj b/test/OpenFeature.E2ETests/OpenFeature.E2ETests.csproj
index d91b338e..14388e2a 100644
--- a/test/OpenFeature.E2ETests/OpenFeature.E2ETests.csproj
+++ b/test/OpenFeature.E2ETests/OpenFeature.E2ETests.csproj
@@ -21,7 +21,7 @@
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/test/OpenFeature.IntegrationTests/FeatureFlagIntegrationTest.cs b/test/OpenFeature.IntegrationTests/FeatureFlagIntegrationTest.cs
index 559bf4bb..4b07e97b 100644
--- a/test/OpenFeature.IntegrationTests/FeatureFlagIntegrationTest.cs
+++ b/test/OpenFeature.IntegrationTests/FeatureFlagIntegrationTest.cs
@@ -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";
@@ -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>().ConfigureAwait(true); ;
+ var response = await client.GetAsync(requestUri, _testCancellationToken).ConfigureAwait(true);
+ var responseContent = await response.Content.ReadFromJsonAsync>(cancellationToken: _testCancellationToken).ConfigureAwait(true); ;
// Assert
response.IsSuccessStatusCode.Should().BeTrue("Expected HTTP status code 200 OK.");
diff --git a/test/OpenFeature.IntegrationTests/OpenFeature.IntegrationTests.csproj b/test/OpenFeature.IntegrationTests/OpenFeature.IntegrationTests.csproj
index 8287b2ec..26beea4b 100644
--- a/test/OpenFeature.IntegrationTests/OpenFeature.IntegrationTests.csproj
+++ b/test/OpenFeature.IntegrationTests/OpenFeature.IntegrationTests.csproj
@@ -13,7 +13,7 @@
-
+
diff --git a/test/OpenFeature.Tests/ClearOpenFeatureInstanceFixture.cs b/test/OpenFeature.Tests/ClearOpenFeatureInstanceFixture.cs
index c3351801..09184cca 100644
--- a/test/OpenFeature.Tests/ClearOpenFeatureInstanceFixture.cs
+++ b/test/OpenFeature.Tests/ClearOpenFeatureInstanceFixture.cs
@@ -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);
}
diff --git a/test/OpenFeature.Tests/FeatureProviderTests.cs b/test/OpenFeature.Tests/FeatureProviderTests.cs
index 53a67443..dc116240 100644
--- a/test/OpenFeature.Tests/FeatureProviderTests.cs
+++ b/test/OpenFeature.Tests/FeatureProviderTests.cs
@@ -44,27 +44,27 @@ public async Task Provider_Must_Resolve_Flag_Values()
var boolResolutionDetails = new ResolutionDetails(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(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(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(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(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);
}
@@ -84,59 +84,52 @@ public async Task Provider_Must_ErrorType()
var providerMock = Substitute.For();
const string testMessage = "An error message";
- providerMock.ResolveBooleanValueAsync(flagName, defaultBoolValue, Arg.Any())
- .Returns(new ResolutionDetails(flagName, defaultBoolValue, ErrorType.General,
+ providerMock.ResolveBooleanValueAsync(flagName, defaultBoolValue, Arg.Any(), this.TestCancellationToken).Returns(new ResolutionDetails(flagName, defaultBoolValue, ErrorType.General,
NoOpProvider.ReasonNoOp, NoOpProvider.Variant, testMessage));
- providerMock.ResolveIntegerValueAsync(flagName, defaultIntegerValue, Arg.Any())
- .Returns(new ResolutionDetails(flagName, defaultIntegerValue, ErrorType.ParseError,
+ providerMock.ResolveIntegerValueAsync(flagName, defaultIntegerValue, Arg.Any(), this.TestCancellationToken).Returns(new ResolutionDetails(flagName, defaultIntegerValue, ErrorType.ParseError,
NoOpProvider.ReasonNoOp, NoOpProvider.Variant, testMessage));
- providerMock.ResolveDoubleValueAsync(flagName, defaultDoubleValue, Arg.Any())
- .Returns(new ResolutionDetails(flagName, defaultDoubleValue, ErrorType.InvalidContext,
+ providerMock.ResolveDoubleValueAsync(flagName, defaultDoubleValue, Arg.Any(), this.TestCancellationToken).Returns(new ResolutionDetails(flagName, defaultDoubleValue, ErrorType.InvalidContext,
NoOpProvider.ReasonNoOp, NoOpProvider.Variant, testMessage));
- providerMock.ResolveStringValueAsync(flagName, defaultStringValue, Arg.Any())
- .Returns(new ResolutionDetails(flagName, defaultStringValue, ErrorType.TypeMismatch,
+ providerMock.ResolveStringValueAsync(flagName, defaultStringValue, Arg.Any(), this.TestCancellationToken).Returns(new ResolutionDetails(flagName, defaultStringValue, ErrorType.TypeMismatch,
NoOpProvider.ReasonNoOp, NoOpProvider.Variant, testMessage));
- providerMock.ResolveStructureValueAsync(flagName, defaultStructureValue, Arg.Any())
- .Returns(new ResolutionDetails(flagName, defaultStructureValue, ErrorType.FlagNotFound,
+ providerMock.ResolveStructureValueAsync(flagName, defaultStructureValue, Arg.Any(), this.TestCancellationToken).Returns(new ResolutionDetails(flagName, defaultStructureValue, ErrorType.FlagNotFound,
NoOpProvider.ReasonNoOp, NoOpProvider.Variant, testMessage));
- providerMock.ResolveStructureValueAsync(flagName2, defaultStructureValue, Arg.Any())
- .Returns(new ResolutionDetails(flagName2, defaultStructureValue, ErrorType.ProviderNotReady,
+ providerMock.ResolveStructureValueAsync(flagName2, defaultStructureValue, Arg.Any(), this.TestCancellationToken).Returns(new ResolutionDetails(flagName2, defaultStructureValue, ErrorType.ProviderNotReady,
NoOpProvider.ReasonNoOp, NoOpProvider.Variant, testMessage));
- providerMock.ResolveBooleanValueAsync(flagName2, defaultBoolValue, Arg.Any())
- .Returns(new ResolutionDetails(flagName2, defaultBoolValue, ErrorType.TargetingKeyMissing,
+ providerMock.ResolveBooleanValueAsync(flagName2, defaultBoolValue, Arg.Any(), this.TestCancellationToken).Returns(new ResolutionDetails(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();
}
diff --git a/test/OpenFeature.Tests/OpenFeature.Tests.csproj b/test/OpenFeature.Tests/OpenFeature.Tests.csproj
index bfadbf9b..07fe14cc 100644
--- a/test/OpenFeature.Tests/OpenFeature.Tests.csproj
+++ b/test/OpenFeature.Tests/OpenFeature.Tests.csproj
@@ -19,7 +19,7 @@
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/test/OpenFeature.Tests/OpenFeatureClientTests.cs b/test/OpenFeature.Tests/OpenFeatureClientTests.cs
index 13d3fa93..3b9a23ac 100644
--- a/test/OpenFeature.Tests/OpenFeatureClientTests.cs
+++ b/test/OpenFeature.Tests/OpenFeatureClientTests.cs
@@ -81,25 +81,25 @@ public async Task OpenFeatureClient_Should_Allow_Flag_Evaluation()
await Api.Instance.SetProviderAsync(new NoOpFeatureProvider());
var client = Api.Instance.GetClient(domain, clientVersion);
- (await client.GetBooleanValueAsync(flagName, defaultBoolValue)).Should().Be(defaultBoolValue);
- (await client.GetBooleanValueAsync(flagName, defaultBoolValue, EvaluationContext.Empty)).Should().Be(defaultBoolValue);
- (await client.GetBooleanValueAsync(flagName, defaultBoolValue, EvaluationContext.Empty, emptyFlagOptions)).Should().Be(defaultBoolValue);
+ (await client.GetBooleanValueAsync(flagName, defaultBoolValue, cancellationToken: this.TestCancellationToken)).Should().Be(defaultBoolValue);
+ (await client.GetBooleanValueAsync(flagName, defaultBoolValue, EvaluationContext.Empty, cancellationToken: this.TestCancellationToken)).Should().Be(defaultBoolValue);
+ (await client.GetBooleanValueAsync(flagName, defaultBoolValue, EvaluationContext.Empty, emptyFlagOptions, this.TestCancellationToken)).Should().Be(defaultBoolValue);
- (await client.GetIntegerValueAsync(flagName, defaultIntegerValue)).Should().Be(defaultIntegerValue);
- (await client.GetIntegerValueAsync(flagName, defaultIntegerValue, EvaluationContext.Empty)).Should().Be(defaultIntegerValue);
- (await client.GetIntegerValueAsync(flagName, defaultIntegerValue, EvaluationContext.Empty, emptyFlagOptions)).Should().Be(defaultIntegerValue);
+ (await client.GetIntegerValueAsync(flagName, defaultIntegerValue, cancellationToken: this.TestCancellationToken)).Should().Be(defaultIntegerValue);
+ (await client.GetIntegerValueAsync(flagName, defaultIntegerValue, EvaluationContext.Empty, cancellationToken: this.TestCancellationToken)).Should().Be(defaultIntegerValue);
+ (await client.GetIntegerValueAsync(flagName, defaultIntegerValue, EvaluationContext.Empty, emptyFlagOptions, this.TestCancellationToken)).Should().Be(defaultIntegerValue);
- (await client.GetDoubleValueAsync(flagName, defaultDoubleValue)).Should().Be(defaultDoubleValue);
- (await client.GetDoubleValueAsync(flagName, defaultDoubleValue, EvaluationContext.Empty)).Should().Be(defaultDoubleValue);
- (await client.GetDoubleValueAsync(flagName, defaultDoubleValue, EvaluationContext.Empty, emptyFlagOptions)).Should().Be(defaultDoubleValue);
+ (await client.GetDoubleValueAsync(flagName, defaultDoubleValue, cancellationToken: this.TestCancellationToken)).Should().Be(defaultDoubleValue);
+ (await client.GetDoubleValueAsync(flagName, defaultDoubleValue, EvaluationContext.Empty, cancellationToken: this.TestCancellationToken)).Should().Be(defaultDoubleValue);
+ (await client.GetDoubleValueAsync(flagName, defaultDoubleValue, EvaluationContext.Empty, emptyFlagOptions, this.TestCancellationToken)).Should().Be(defaultDoubleValue);
- (await client.GetStringValueAsync(flagName, defaultStringValue)).Should().Be(defaultStringValue);
- (await client.GetStringValueAsync(flagName, defaultStringValue, EvaluationContext.Empty)).Should().Be(defaultStringValue);
- (await client.GetStringValueAsync(flagName, defaultStringValue, EvaluationContext.Empty, emptyFlagOptions)).Should().Be(defaultStringValue);
+ (await client.GetStringValueAsync(flagName, defaultStringValue, cancellationToken: this.TestCancellationToken)).Should().Be(defaultStringValue);
+ (await client.GetStringValueAsync(flagName, defaultStringValue, EvaluationContext.Empty, cancellationToken: this.TestCancellationToken)).Should().Be(defaultStringValue);
+ (await client.GetStringValueAsync(flagName, defaultStringValue, EvaluationContext.Empty, emptyFlagOptions, this.TestCancellationToken)).Should().Be(defaultStringValue);
- (await client.GetObjectValueAsync(flagName, defaultStructureValue)).Should().BeEquivalentTo(defaultStructureValue);
- (await client.GetObjectValueAsync(flagName, defaultStructureValue, EvaluationContext.Empty)).Should().BeEquivalentTo(defaultStructureValue);
- (await client.GetObjectValueAsync(flagName, defaultStructureValue, EvaluationContext.Empty, emptyFlagOptions)).Should().BeEquivalentTo(defaultStructureValue);
+ (await client.GetObjectValueAsync(flagName, defaultStructureValue, cancellationToken: this.TestCancellationToken)).Should().BeEquivalentTo(defaultStructureValue);
+ (await client.GetObjectValueAsync(flagName, defaultStructureValue, EvaluationContext.Empty, cancellationToken: this.TestCancellationToken)).Should().BeEquivalentTo(defaultStructureValue);
+ (await client.GetObjectValueAsync(flagName, defaultStructureValue, EvaluationContext.Empty, emptyFlagOptions, this.TestCancellationToken)).Should().BeEquivalentTo(defaultStructureValue);
}
[Fact]
@@ -128,29 +128,29 @@ public async Task OpenFeatureClient_Should_Allow_Details_Flag_Evaluation()
var client = Api.Instance.GetClient(domain, clientVersion);
var boolFlagEvaluationDetails = new FlagEvaluationDetails(flagName, defaultBoolValue, ErrorType.None, NoOpProvider.ReasonNoOp, NoOpProvider.Variant);
- (await client.GetBooleanDetailsAsync(flagName, defaultBoolValue)).Should().BeEquivalentTo(boolFlagEvaluationDetails);
- (await client.GetBooleanDetailsAsync(flagName, defaultBoolValue, EvaluationContext.Empty)).Should().BeEquivalentTo(boolFlagEvaluationDetails);
- (await client.GetBooleanDetailsAsync(flagName, defaultBoolValue, EvaluationContext.Empty, emptyFlagOptions)).Should().BeEquivalentTo(boolFlagEvaluationDetails);
+ (await client.GetBooleanDetailsAsync(flagName, defaultBoolValue, cancellationToken: this.TestCancellationToken)).Should().BeEquivalentTo(boolFlagEvaluationDetails);
+ (await client.GetBooleanDetailsAsync(flagName, defaultBoolValue, EvaluationContext.Empty, cancellationToken: this.TestCancellationToken)).Should().BeEquivalentTo(boolFlagEvaluationDetails);
+ (await client.GetBooleanDetailsAsync(flagName, defaultBoolValue, EvaluationContext.Empty, emptyFlagOptions, this.TestCancellationToken)).Should().BeEquivalentTo(boolFlagEvaluationDetails);
var integerFlagEvaluationDetails = new FlagEvaluationDetails(flagName, defaultIntegerValue, ErrorType.None, NoOpProvider.ReasonNoOp, NoOpProvider.Variant);
- (await client.GetIntegerDetailsAsync(flagName, defaultIntegerValue)).Should().BeEquivalentTo(integerFlagEvaluationDetails);
- (await client.GetIntegerDetailsAsync(flagName, defaultIntegerValue, EvaluationContext.Empty)).Should().BeEquivalentTo(integerFlagEvaluationDetails);
- (await client.GetIntegerDetailsAsync(flagName, defaultIntegerValue, EvaluationContext.Empty, emptyFlagOptions)).Should().BeEquivalentTo(integerFlagEvaluationDetails);
+ (await client.GetIntegerDetailsAsync(flagName, defaultIntegerValue, cancellationToken: this.TestCancellationToken)).Should().BeEquivalentTo(integerFlagEvaluationDetails);
+ (await client.GetIntegerDetailsAsync(flagName, defaultIntegerValue, EvaluationContext.Empty, cancellationToken: this.TestCancellationToken)).Should().BeEquivalentTo(integerFlagEvaluationDetails);
+ (await client.GetIntegerDetailsAsync(flagName, defaultIntegerValue, EvaluationContext.Empty, emptyFlagOptions, this.TestCancellationToken)).Should().BeEquivalentTo(integerFlagEvaluationDetails);
var doubleFlagEvaluationDetails = new FlagEvaluationDetails(flagName, defaultDoubleValue, ErrorType.None, NoOpProvider.ReasonNoOp, NoOpProvider.Variant);
- (await client.GetDoubleDetailsAsync(flagName, defaultDoubleValue)).Should().BeEquivalentTo(doubleFlagEvaluationDetails);
- (await client.GetDoubleDetailsAsync(flagName, defaultDoubleValue, EvaluationContext.Empty)).Should().BeEquivalentTo(doubleFlagEvaluationDetails);
- (await client.GetDoubleDetailsAsync(flagName, defaultDoubleValue, EvaluationContext.Empty, emptyFlagOptions)).Should().BeEquivalentTo(doubleFlagEvaluationDetails);
+ (await client.GetDoubleDetailsAsync(flagName, defaultDoubleValue, cancellationToken: this.TestCancellationToken)).Should().BeEquivalentTo(doubleFlagEvaluationDetails);
+ (await client.GetDoubleDetailsAsync(flagName, defaultDoubleValue, EvaluationContext.Empty, cancellationToken: this.TestCancellationToken)).Should().BeEquivalentTo(doubleFlagEvaluationDetails);
+ (await client.GetDoubleDetailsAsync(flagName, defaultDoubleValue, EvaluationContext.Empty, emptyFlagOptions, this.TestCancellationToken)).Should().BeEquivalentTo(doubleFlagEvaluationDetails);
var stringFlagEvaluationDetails = new FlagEvaluationDetails(flagName, defaultStringValue, ErrorType.None, NoOpProvider.ReasonNoOp, NoOpProvider.Variant);
- (await client.GetStringDetailsAsync(flagName, defaultStringValue)).Should().BeEquivalentTo(stringFlagEvaluationDetails);
- (await client.GetStringDetailsAsync(flagName, defaultStringValue, EvaluationContext.Empty)).Should().BeEquivalentTo(stringFlagEvaluationDetails);
- (await client.GetStringDetailsAsync(flagName, defaultStringValue, EvaluationContext.Empty, emptyFlagOptions)).Should().BeEquivalentTo(stringFlagEvaluationDetails);
+ (await client.GetStringDetailsAsync(flagName, defaultStringValue, cancellationToken: this.TestCancellationToken)).Should().BeEquivalentTo(stringFlagEvaluationDetails);
+ (await client.GetStringDetailsAsync(flagName, defaultStringValue, EvaluationContext.Empty, cancellationToken: this.TestCancellationToken)).Should().BeEquivalentTo(stringFlagEvaluationDetails);
+ (await client.GetStringDetailsAsync(flagName, defaultStringValue, EvaluationContext.Empty, emptyFlagOptions, this.TestCancellationToken)).Should().BeEquivalentTo(stringFlagEvaluationDetails);
var structureFlagEvaluationDetails = new FlagEvaluationDetails(flagName, defaultStructureValue, ErrorType.None, NoOpProvider.ReasonNoOp, NoOpProvider.Variant);
- (await client.GetObjectDetailsAsync(flagName, defaultStructureValue)).Should().BeEquivalentTo(structureFlagEvaluationDetails);
- (await client.GetObjectDetailsAsync(flagName, defaultStructureValue, EvaluationContext.Empty)).Should().BeEquivalentTo(structureFlagEvaluationDetails);
- (await client.GetObjectDetailsAsync(flagName, defaultStructureValue, EvaluationContext.Empty, emptyFlagOptions)).Should().BeEquivalentTo(structureFlagEvaluationDetails);
+ (await client.GetObjectDetailsAsync(flagName, defaultStructureValue, cancellationToken: this.TestCancellationToken)).Should().BeEquivalentTo(structureFlagEvaluationDetails);
+ (await client.GetObjectDetailsAsync(flagName, defaultStructureValue, EvaluationContext.Empty, cancellationToken: this.TestCancellationToken)).Should().BeEquivalentTo(structureFlagEvaluationDetails);
+ (await client.GetObjectDetailsAsync(flagName, defaultStructureValue, EvaluationContext.Empty, emptyFlagOptions, this.TestCancellationToken)).Should().BeEquivalentTo(structureFlagEvaluationDetails);
}
[Fact]
@@ -171,18 +171,18 @@ public async Task OpenFeatureClient_Should_Return_DefaultValue_When_Type_Mismatc
var mockedLogger = Substitute.For>();
// This will fail to case a String to TestStructure
- mockedFeatureProvider.ResolveStructureValueAsync(flagName, defaultValue, Arg.Any()).Throws();
+ mockedFeatureProvider.ResolveStructureValueAsync(flagName, defaultValue, Arg.Any(), this.TestCancellationToken).Throws();
mockedFeatureProvider.GetMetadata().Returns(new Metadata(fixture.Create()));
mockedFeatureProvider.GetProviderHooks().Returns(ImmutableList.Empty);
await Api.Instance.SetProviderAsync(mockedFeatureProvider);
var client = Api.Instance.GetClient(domain, clientVersion, mockedLogger);
- var evaluationDetails = await client.GetObjectDetailsAsync(flagName, defaultValue);
+ var evaluationDetails = await client.GetObjectDetailsAsync(flagName, defaultValue, cancellationToken: this.TestCancellationToken);
evaluationDetails.ErrorType.Should().Be(ErrorType.TypeMismatch);
evaluationDetails.ErrorMessage.Should().Be(new InvalidCastException().Message);
- _ = mockedFeatureProvider.Received(1).ResolveStructureValueAsync(flagName, defaultValue, Arg.Any());
+ _ = mockedFeatureProvider.Received(1).ResolveStructureValueAsync(flagName, defaultValue, Arg.Any(), this.TestCancellationToken);
mockedLogger.Received(1).IsEnabled(LogLevel.Error);
}
@@ -248,7 +248,7 @@ public async Task Must_Short_Circuit_Not_Ready()
Assert.Equal(ProviderStatus.NotReady, provider.Status);
_ = Api.Instance.SetProviderAsync(name, provider);
- var details = await client.GetStringDetailsAsync("some-flag", defaultStr);
+ var details = await client.GetStringDetailsAsync("some-flag", defaultStr, cancellationToken: this.TestCancellationToken);
Assert.Equal(defaultStr, details.Value);
Assert.Equal(ErrorType.ProviderNotReady, details.ErrorType);
Assert.Equal(Reason.Error, details.Reason);
@@ -267,7 +267,7 @@ public async Task Must_Short_Circuit_Fatal()
Assert.Equal(ProviderStatus.NotReady, provider.Status);
_ = Api.Instance.SetProviderAsync(name, provider);
- var details = await client.GetStringDetailsAsync("some-flag", defaultStr);
+ var details = await client.GetStringDetailsAsync("some-flag", defaultStr, cancellationToken: this.TestCancellationToken);
Assert.Equal(defaultStr, details.Value);
Assert.Equal(ErrorType.ProviderFatal, details.ErrorType);
Assert.Equal(Reason.Error, details.Reason);
@@ -283,16 +283,16 @@ public async Task Should_Resolve_BooleanValue()
var defaultValue = fixture.Create();
var featureProviderMock = Substitute.For();
- featureProviderMock.ResolveBooleanValueAsync(flagName, defaultValue, Arg.Any()).Returns(new ResolutionDetails(flagName, defaultValue));
+ featureProviderMock.ResolveBooleanValueAsync(flagName, defaultValue, Arg.Any(), this.TestCancellationToken).Returns(new ResolutionDetails(flagName, defaultValue));
featureProviderMock.GetMetadata().Returns(new Metadata(fixture.Create()));
featureProviderMock.GetProviderHooks().Returns(ImmutableList.Empty);
await Api.Instance.SetProviderAsync(featureProviderMock);
var client = Api.Instance.GetClient(domain, clientVersion);
- (await client.GetBooleanValueAsync(flagName, defaultValue)).Should().Be(defaultValue);
+ (await client.GetBooleanValueAsync(flagName, defaultValue, cancellationToken: this.TestCancellationToken)).Should().Be(defaultValue);
- _ = featureProviderMock.Received(1).ResolveBooleanValueAsync(flagName, defaultValue, Arg.Any());
+ _ = featureProviderMock.Received(1).ResolveBooleanValueAsync(flagName, defaultValue, Arg.Any(), this.TestCancellationToken);
}
[Fact]
@@ -305,16 +305,16 @@ public async Task Should_Resolve_StringValue()
var defaultValue = fixture.Create();
var featureProviderMock = Substitute.For();
- featureProviderMock.ResolveStringValueAsync(flagName, defaultValue, Arg.Any()).Returns(new ResolutionDetails(flagName, defaultValue));
+ featureProviderMock.ResolveStringValueAsync(flagName, defaultValue, Arg.Any(), this.TestCancellationToken).Returns(new ResolutionDetails(flagName, defaultValue));
featureProviderMock.GetMetadata().Returns(new Metadata(fixture.Create()));
featureProviderMock.GetProviderHooks().Returns(ImmutableList.Empty);
await Api.Instance.SetProviderAsync(featureProviderMock);
var client = Api.Instance.GetClient(domain, clientVersion);
- (await client.GetStringValueAsync(flagName, defaultValue)).Should().Be(defaultValue);
+ (await client.GetStringValueAsync(flagName, defaultValue, cancellationToken: this.TestCancellationToken)).Should().Be(defaultValue);
- _ = featureProviderMock.Received(1).ResolveStringValueAsync(flagName, defaultValue, Arg.Any());
+ _ = featureProviderMock.Received(1).ResolveStringValueAsync(flagName, defaultValue, Arg.Any(), this.TestCancellationToken);
}
[Fact]
@@ -327,16 +327,16 @@ public async Task Should_Resolve_IntegerValue()
var defaultValue = fixture.Create();
var featureProviderMock = Substitute.For();
- featureProviderMock.ResolveIntegerValueAsync(flagName, defaultValue, Arg.Any()).Returns(new ResolutionDetails(flagName, defaultValue));
+ featureProviderMock.ResolveIntegerValueAsync(flagName, defaultValue, Arg.Any(), this.TestCancellationToken).Returns(new ResolutionDetails(flagName, defaultValue));
featureProviderMock.GetMetadata().Returns(new Metadata(fixture.Create()));
featureProviderMock.GetProviderHooks().Returns(ImmutableList.Empty);
await Api.Instance.SetProviderAsync(featureProviderMock);
var client = Api.Instance.GetClient(domain, clientVersion);
- (await client.GetIntegerValueAsync(flagName, defaultValue)).Should().Be(defaultValue);
+ (await client.GetIntegerValueAsync(flagName, defaultValue, cancellationToken: this.TestCancellationToken)).Should().Be(defaultValue);
- _ = featureProviderMock.Received(1).ResolveIntegerValueAsync(flagName, defaultValue, Arg.Any());
+ _ = featureProviderMock.Received(1).ResolveIntegerValueAsync(flagName, defaultValue, Arg.Any(), this.TestCancellationToken);
}
[Fact]
@@ -349,16 +349,16 @@ public async Task Should_Resolve_DoubleValue()
var defaultValue = fixture.Create();
var featureProviderMock = Substitute.For();
- featureProviderMock.ResolveDoubleValueAsync(flagName, defaultValue, Arg.Any()).Returns(new ResolutionDetails(flagName, defaultValue));
+ featureProviderMock.ResolveDoubleValueAsync(flagName, defaultValue, Arg.Any(), this.TestCancellationToken).Returns(new ResolutionDetails(flagName, defaultValue));
featureProviderMock.GetMetadata().Returns(new Metadata(fixture.Create()));
featureProviderMock.GetProviderHooks().Returns(ImmutableList.Empty);
await Api.Instance.SetProviderAsync(featureProviderMock);
var client = Api.Instance.GetClient(domain, clientVersion);
- (await client.GetDoubleValueAsync(flagName, defaultValue)).Should().Be(defaultValue);
+ (await client.GetDoubleValueAsync(flagName, defaultValue, cancellationToken: this.TestCancellationToken)).Should().Be(defaultValue);
- _ = featureProviderMock.Received(1).ResolveDoubleValueAsync(flagName, defaultValue, Arg.Any());
+ _ = featureProviderMock.Received(1).ResolveDoubleValueAsync(flagName, defaultValue, Arg.Any(), this.TestCancellationToken);
}
[Fact]
@@ -371,16 +371,16 @@ public async Task Should_Resolve_StructureValue()
var defaultValue = fixture.Create();
var featureProviderMock = Substitute.For();
- featureProviderMock.ResolveStructureValueAsync(flagName, defaultValue, Arg.Any()).Returns(new ResolutionDetails(flagName, defaultValue));
+ featureProviderMock.ResolveStructureValueAsync(flagName, defaultValue, Arg.Any(), this.TestCancellationToken).Returns(new ResolutionDetails(flagName, defaultValue));
featureProviderMock.GetMetadata().Returns(new Metadata(fixture.Create()));
featureProviderMock.GetProviderHooks().Returns(ImmutableList.Empty);
await Api.Instance.SetProviderAsync(featureProviderMock);
var client = Api.Instance.GetClient(domain, clientVersion);
- (await client.GetObjectValueAsync(flagName, defaultValue)).Should().Be(defaultValue);
+ (await client.GetObjectValueAsync(flagName, defaultValue, cancellationToken: this.TestCancellationToken)).Should().Be(defaultValue);
- _ = featureProviderMock.Received(1).ResolveStructureValueAsync(flagName, defaultValue, Arg.Any());
+ _ = featureProviderMock.Received(1).ResolveStructureValueAsync(flagName, defaultValue, Arg.Any(), this.TestCancellationToken);
}
[Fact]
@@ -394,18 +394,18 @@ public async Task When_Error_Is_Returned_From_Provider_Should_Return_Error()
const string testMessage = "Couldn't parse flag data.";
var featureProviderMock = Substitute.For();
- featureProviderMock.ResolveStructureValueAsync(flagName, defaultValue, Arg.Any()).Returns(Task.FromResult(new ResolutionDetails(flagName, defaultValue, ErrorType.ParseError, "ERROR", null, testMessage)));
+ featureProviderMock.ResolveStructureValueAsync(flagName, defaultValue, Arg.Any(), this.TestCancellationToken).Returns(Task.FromResult(new ResolutionDetails(flagName, defaultValue, ErrorType.ParseError, "ERROR", null, testMessage)));
featureProviderMock.GetMetadata().Returns(new Metadata(fixture.Create()));
featureProviderMock.GetProviderHooks().Returns(ImmutableList.Empty);
await Api.Instance.SetProviderAsync(featureProviderMock);
var client = Api.Instance.GetClient(domain, clientVersion);
- var response = await client.GetObjectDetailsAsync(flagName, defaultValue);
+ var response = await client.GetObjectDetailsAsync(flagName, defaultValue, cancellationToken: this.TestCancellationToken);
response.ErrorType.Should().Be(ErrorType.ParseError);
response.Reason.Should().Be(Reason.Error);
response.ErrorMessage.Should().Be(testMessage);
- _ = featureProviderMock.Received(1).ResolveStructureValueAsync(flagName, defaultValue, Arg.Any());
+ _ = featureProviderMock.Received(1).ResolveStructureValueAsync(flagName, defaultValue, Arg.Any(), this.TestCancellationToken);
}
[Fact]
@@ -419,18 +419,18 @@ public async Task When_Exception_Occurs_During_Evaluation_Should_Return_Error()
const string testMessage = "Couldn't parse flag data.";
var featureProviderMock = Substitute.For();
- featureProviderMock.ResolveStructureValueAsync(flagName, defaultValue, Arg.Any()).Throws(new FeatureProviderException(ErrorType.ParseError, testMessage));
+ featureProviderMock.ResolveStructureValueAsync(flagName, defaultValue, Arg.Any(), this.TestCancellationToken).Throws(new FeatureProviderException(ErrorType.ParseError, testMessage));
featureProviderMock.GetMetadata().Returns(new Metadata(fixture.Create()));
featureProviderMock.GetProviderHooks().Returns(ImmutableList.Empty);
await Api.Instance.SetProviderAsync(featureProviderMock);
var client = Api.Instance.GetClient(domain, clientVersion);
- var response = await client.GetObjectDetailsAsync(flagName, defaultValue);
+ var response = await client.GetObjectDetailsAsync(flagName, defaultValue, cancellationToken: this.TestCancellationToken);
response.ErrorType.Should().Be(ErrorType.ParseError);
response.Reason.Should().Be(Reason.Error);
response.ErrorMessage.Should().Be(testMessage);
- _ = featureProviderMock.Received(1).ResolveStructureValueAsync(flagName, defaultValue, Arg.Any());
+ _ = featureProviderMock.Received(1).ResolveStructureValueAsync(flagName, defaultValue, Arg.Any(), this.TestCancellationToken);
}
[Fact]
@@ -444,8 +444,7 @@ public async Task When_Error_Is_Returned_From_Provider_Should_Not_Run_After_Hook
const string testMessage = "Couldn't parse flag data.";
var featureProviderMock = Substitute.For();
- featureProviderMock.ResolveStructureValueAsync(flagName, defaultValue, Arg.Any())
- .Returns(Task.FromResult(new ResolutionDetails(flagName, defaultValue, ErrorType.ParseError,
+ featureProviderMock.ResolveStructureValueAsync(flagName, defaultValue, Arg.Any(), this.TestCancellationToken).Returns(Task.FromResult(new ResolutionDetails(flagName, defaultValue, ErrorType.ParseError,
"ERROR", null, testMessage)));
featureProviderMock.GetMetadata().Returns(new Metadata(fixture.Create()));
featureProviderMock.GetProviderHooks().Returns(ImmutableList.Empty);
@@ -454,13 +453,13 @@ public async Task When_Error_Is_Returned_From_Provider_Should_Not_Run_After_Hook
var client = Api.Instance.GetClient(domain, clientVersion);
var testHook = new TestHook();
client.AddHooks(testHook);
- var response = await client.GetObjectDetailsAsync(flagName, defaultValue);
+ var response = await client.GetObjectDetailsAsync(flagName, defaultValue, cancellationToken: this.TestCancellationToken);
response.ErrorType.Should().Be(ErrorType.ParseError);
response.Reason.Should().Be(Reason.Error);
response.ErrorMessage.Should().Be(testMessage);
_ = featureProviderMock.Received(1)
- .ResolveStructureValueAsync(flagName, defaultValue, Arg.Any());
+ .ResolveStructureValueAsync(flagName, defaultValue, Arg.Any(), this.TestCancellationToken);
Assert.Equal(1, testHook.BeforeCallCount);
Assert.Equal(0, testHook.AfterCallCount);
@@ -487,7 +486,7 @@ public async Task Cancellation_Token_Added_Is_Passed_To_Provider()
var token = args.ArgAt(3);
while (!token.IsCancellationRequested)
{
- await Task.Delay(10); // artificially delay until cancelled
+ await Task.Delay(10, token); // artificially delay until cancelled
}
return new ResolutionDetails(flagName, defaultString, ErrorType.None, cancelledReason);
diff --git a/test/OpenFeature.Tests/OpenFeatureEventTests.cs b/test/OpenFeature.Tests/OpenFeatureEventTests.cs
index a4b0d111..97c5a1f2 100644
--- a/test/OpenFeature.Tests/OpenFeatureEventTests.cs
+++ b/test/OpenFeature.Tests/OpenFeatureEventTests.cs
@@ -78,9 +78,9 @@ public async Task API_Level_Event_Handlers_Should_Be_Registered()
var testProvider = new TestProvider();
await Api.Instance.SetProviderAsync(testProvider);
- await testProvider.SendEventAsync(ProviderEventTypes.ProviderConfigurationChanged);
- await testProvider.SendEventAsync(ProviderEventTypes.ProviderError);
- await testProvider.SendEventAsync(ProviderEventTypes.ProviderStale);
+ await testProvider.SendEventAsync(ProviderEventTypes.ProviderConfigurationChanged, this.TestCancellationToken);
+ await testProvider.SendEventAsync(ProviderEventTypes.ProviderError, this.TestCancellationToken);
+ await testProvider.SendEventAsync(ProviderEventTypes.ProviderStale, this.TestCancellationToken);
await Utils.AssertUntilAsync(_ => eventHandler
.Received()
@@ -226,12 +226,12 @@ public async Task API_Level_Event_Handlers_Should_Be_Exchangeable()
var testProvider = new TestProvider();
await Api.Instance.SetProviderAsync(testProvider);
- await testProvider.SendEventAsync(ProviderEventTypes.ProviderConfigurationChanged);
+ await testProvider.SendEventAsync(ProviderEventTypes.ProviderConfigurationChanged, this.TestCancellationToken);
var newTestProvider = new TestProvider();
await Api.Instance.SetProviderAsync(newTestProvider);
- await newTestProvider.SendEventAsync(ProviderEventTypes.ProviderConfigurationChanged);
+ await newTestProvider.SendEventAsync(ProviderEventTypes.ProviderConfigurationChanged, this.TestCancellationToken);
await Utils.AssertUntilAsync(
_ => eventHandler.Received(2).Invoke(Arg.Is(payload => payload.ProviderName == testProvider.GetMetadata().Name && payload.Type == ProviderEventTypes.ProviderReady))
@@ -405,7 +405,7 @@ public async Task Client_Level_Event_Handlers_Should_Be_Receive_Events_From_Name
client.AddHandler(ProviderEventTypes.ProviderConfigurationChanged, clientEventHandler);
- await defaultProvider.SendEventAsync(ProviderEventTypes.ProviderConfigurationChanged);
+ await defaultProvider.SendEventAsync(ProviderEventTypes.ProviderConfigurationChanged, this.TestCancellationToken);
// verify that the client received the event from the default provider as there is no named provider registered yet
await Utils.AssertUntilAsync(
@@ -417,8 +417,8 @@ await Utils.AssertUntilAsync(
await Api.Instance.SetProviderAsync(client.GetMetadata().Name!, clientProvider);
// now, send another event for the default handler
- await defaultProvider.SendEventAsync(ProviderEventTypes.ProviderConfigurationChanged);
- await clientProvider.SendEventAsync(ProviderEventTypes.ProviderConfigurationChanged);
+ await defaultProvider.SendEventAsync(ProviderEventTypes.ProviderConfigurationChanged, this.TestCancellationToken);
+ await clientProvider.SendEventAsync(ProviderEventTypes.ProviderConfigurationChanged, this.TestCancellationToken);
// now the client should have received only the event from the named provider
await Utils.AssertUntilAsync(
@@ -481,7 +481,7 @@ await Utils.AssertUntilAsync(
myClient.RemoveHandler(ProviderEventTypes.ProviderReady, eventHandler);
// send another event from the provider - this one should not be received
- await testProvider.SendEventAsync(ProviderEventTypes.ProviderReady);
+ await testProvider.SendEventAsync(ProviderEventTypes.ProviderReady, this.TestCancellationToken);
// wait a bit and make sure we only have received the first event, but nothing after removing the event handler
await Utils.AssertUntilAsync(
@@ -513,7 +513,7 @@ public async Task Provider_Events_Should_Update_ProviderStatus(ProviderEventType
{
var provider = new TestProvider();
await Api.Instance.SetProviderAsync("5.3.5", provider);
- _ = provider.SendEventAsync(type);
+ _ = provider.SendEventAsync(type, this.TestCancellationToken);
await Utils.AssertUntilAsync(_ => Assert.True(provider.Status == status));
}
}
diff --git a/test/OpenFeature.Tests/OpenFeatureHookTests.cs b/test/OpenFeature.Tests/OpenFeatureHookTests.cs
index cc8b08a1..3883370e 100644
--- a/test/OpenFeature.Tests/OpenFeatureHookTests.cs
+++ b/test/OpenFeature.Tests/OpenFeatureHookTests.cs
@@ -37,18 +37,18 @@ public async Task Hooks_Should_Be_Called_In_Order()
var providerHook = Substitute.For();
// Sequence
- apiHook.BeforeAsync(Arg.Any>(), Arg.Any>()).Returns(EvaluationContext.Empty);
- clientHook.BeforeAsync(Arg.Any>(), Arg.Any>()).Returns(EvaluationContext.Empty);
- invocationHook.BeforeAsync(Arg.Any>(), Arg.Any>()).Returns(EvaluationContext.Empty);
- providerHook.BeforeAsync(Arg.Any>(), Arg.Any>()).Returns(EvaluationContext.Empty);
- providerHook.AfterAsync(Arg.Any>(), Arg.Any>(), Arg.Any>()).Returns(new ValueTask());
- invocationHook.AfterAsync(Arg.Any>(), Arg.Any>(), Arg.Any>()).Returns(new ValueTask());
- clientHook.AfterAsync(Arg.Any>(), Arg.Any>(), Arg.Any>()).Returns(new ValueTask());
- apiHook.AfterAsync(Arg.Any>(), Arg.Any>(), Arg.Any>()).Returns(new ValueTask());
- providerHook.FinallyAsync(Arg.Any>(), Arg.Any>()).Returns(new ValueTask());
- invocationHook.FinallyAsync(Arg.Any>(), Arg.Any>()).Returns(new ValueTask());
- clientHook.FinallyAsync(Arg.Any>(), Arg.Any>()).Returns(new ValueTask());
- apiHook.FinallyAsync(Arg.Any>(), Arg.Any>()).Returns(new ValueTask());
+ apiHook.BeforeAsync(Arg.Any>(), Arg.Any>(), this.TestCancellationToken).Returns(EvaluationContext.Empty);
+ clientHook.BeforeAsync(Arg.Any>(), Arg.Any>(), this.TestCancellationToken).Returns(EvaluationContext.Empty);
+ invocationHook.BeforeAsync(Arg.Any>(), Arg.Any>(), this.TestCancellationToken).Returns(EvaluationContext.Empty);
+ providerHook.BeforeAsync(Arg.Any>(), Arg.Any>(), this.TestCancellationToken).Returns(EvaluationContext.Empty);
+ providerHook.AfterAsync(Arg.Any>(), Arg.Any>(), Arg.Any>(), this.TestCancellationToken).Returns(new ValueTask());
+ invocationHook.AfterAsync(Arg.Any>(), Arg.Any>(), Arg.Any>(), this.TestCancellationToken).Returns(new ValueTask());
+ clientHook.AfterAsync(Arg.Any>(), Arg.Any>(), Arg.Any>(), this.TestCancellationToken).Returns(new ValueTask());
+ apiHook.AfterAsync(Arg.Any>(), Arg.Any>(), Arg.Any>(), this.TestCancellationToken).Returns(new ValueTask());
+ providerHook.FinallyAsync(Arg.Any>(), Arg.Any>(), this.TestCancellationToken).Returns(new ValueTask());
+ invocationHook.FinallyAsync(Arg.Any>(), Arg.Any>(), this.TestCancellationToken).Returns(new ValueTask());
+ clientHook.FinallyAsync(Arg.Any>(), Arg.Any>(), this.TestCancellationToken).Returns(new ValueTask());
+ apiHook.FinallyAsync(Arg.Any>(), Arg.Any>(), this.TestCancellationToken).Returns(new ValueTask());
var testProvider = new TestProvider();
testProvider.AddHook(providerHook);
@@ -57,37 +57,36 @@ public async Task Hooks_Should_Be_Called_In_Order()
var client = Api.Instance.GetClient(domain, clientVersion);
client.AddHooks(clientHook);
- await client.GetBooleanValueAsync(flagName, defaultValue, EvaluationContext.Empty,
- new FlagEvaluationOptions(invocationHook, ImmutableDictionary.Empty));
+ await client.GetBooleanValueAsync(flagName, defaultValue, EvaluationContext.Empty, new FlagEvaluationOptions(invocationHook, ImmutableDictionary.Empty), this.TestCancellationToken);
Received.InOrder(() =>
{
- apiHook.BeforeAsync(Arg.Any>(), Arg.Any>());
- clientHook.BeforeAsync(Arg.Any>(), Arg.Any>());
- invocationHook.BeforeAsync(Arg.Any>(), Arg.Any>());
- providerHook.BeforeAsync(Arg.Any>(), Arg.Any>());
- providerHook.AfterAsync(Arg.Any>(), Arg.Any>(), Arg.Any>());
- invocationHook.AfterAsync(Arg.Any>(), Arg.Any>(), Arg.Any>());
- clientHook.AfterAsync(Arg.Any>(), Arg.Any>(), Arg.Any>());
- apiHook.AfterAsync(Arg.Any>(), Arg.Any>(), Arg.Any>());
- providerHook.FinallyAsync(Arg.Any>(), Arg.Any>());
- invocationHook.FinallyAsync(Arg.Any>(), Arg.Any>());
- clientHook.FinallyAsync(Arg.Any>(), Arg.Any>());
- apiHook.FinallyAsync(Arg.Any>(), Arg.Any>());
+ apiHook.BeforeAsync(Arg.Any>(), Arg.Any>(), this.TestCancellationToken);
+ clientHook.BeforeAsync(Arg.Any>(), Arg.Any>(), this.TestCancellationToken);
+ invocationHook.BeforeAsync(Arg.Any>(), Arg.Any>(), this.TestCancellationToken);
+ providerHook.BeforeAsync(Arg.Any>(), Arg.Any>(), this.TestCancellationToken);
+ providerHook.AfterAsync(Arg.Any>(), Arg.Any>(), Arg.Any>(), this.TestCancellationToken);
+ invocationHook.AfterAsync(Arg.Any>(), Arg.Any>(), Arg.Any>(), this.TestCancellationToken);
+ clientHook.AfterAsync(Arg.Any>(), Arg.Any>(), Arg.Any>(), this.TestCancellationToken);
+ apiHook.AfterAsync(Arg.Any>(), Arg.Any>(), Arg.Any>(), this.TestCancellationToken);
+ providerHook.FinallyAsync(Arg.Any>(), Arg.Any>(), this.TestCancellationToken);
+ invocationHook.FinallyAsync(Arg.Any>(), Arg.Any>(), this.TestCancellationToken);
+ clientHook.FinallyAsync(Arg.Any>(), Arg.Any>(), this.TestCancellationToken);
+ apiHook.FinallyAsync(Arg.Any>(), Arg.Any>(), this.TestCancellationToken);
});
- _ = apiHook.Received(1).BeforeAsync(Arg.Any>(), Arg.Any>());
- _ = clientHook.Received(1).BeforeAsync(Arg.Any>(), Arg.Any>());
- _ = invocationHook.Received(1).BeforeAsync(Arg.Any>(), Arg.Any>());
- _ = providerHook.Received(1).BeforeAsync(Arg.Any>(), Arg.Any