diff --git a/src/OpenFeature/Api.cs b/src/OpenFeature/Api.cs
index 440242da..fffc14cc 100644
--- a/src/OpenFeature/Api.cs
+++ b/src/OpenFeature/Api.cs
@@ -1,3 +1,4 @@
+using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
@@ -38,17 +39,40 @@ static Api() { }
private Api() { }
///
- /// Sets the feature provider. In order to wait for the provider to be set, and initialization to complete,
+ /// Sets the default feature provider to given clientName without awaiting its initialization.
+ ///
+ /// The provider cannot be set to null. Attempting to set the provider to null has no effect.
+ /// Implementation of
+ [Obsolete("Will be removed in later versions; use SetProviderAsync, which can be awaited")]
+ public void SetProvider(FeatureProvider featureProvider)
+ {
+ this.EventExecutor.RegisterDefaultFeatureProvider(featureProvider);
+ this._repository.SetProvider(featureProvider, this.GetContext()).ConfigureAwait(false);
+ }
+
+ ///
+ /// Sets the default feature provider. In order to wait for the provider to be set, and initialization to complete,
/// await the returned task.
///
/// The provider cannot be set to null. Attempting to set the provider to null has no effect.
/// Implementation of
- public async Task SetProvider(FeatureProvider featureProvider)
+ public async Task SetProviderAsync(FeatureProvider featureProvider)
{
this.EventExecutor.RegisterDefaultFeatureProvider(featureProvider);
await this._repository.SetProvider(featureProvider, this.GetContext()).ConfigureAwait(false);
}
+ ///
+ /// Sets the feature provider to given clientName without awaiting its initialization.
+ ///
+ /// Name of client
+ /// Implementation of
+ [Obsolete("Will be removed in later versions; use SetProviderAsync, which can be awaited")]
+ public void SetProvider(string clientName, FeatureProvider featureProvider)
+ {
+ this.EventExecutor.RegisterClientFeatureProvider(clientName, featureProvider);
+ this._repository.SetProvider(clientName, featureProvider, this.GetContext()).ConfigureAwait(false);
+ }
///
/// Sets the feature provider to given clientName. In order to wait for the provider to be set, and
@@ -56,7 +80,7 @@ public async Task SetProvider(FeatureProvider featureProvider)
///
/// Name of client
/// Implementation of
- public async Task SetProvider(string clientName, FeatureProvider featureProvider)
+ public async Task SetProviderAsync(string clientName, FeatureProvider featureProvider)
{
this.EventExecutor.RegisterClientFeatureProvider(clientName, featureProvider);
await this._repository.SetProvider(clientName, featureProvider, this.GetContext()).ConfigureAwait(false);
diff --git a/test/OpenFeature.E2ETests/Steps/EvaluationStepDefinitions.cs b/test/OpenFeature.E2ETests/Steps/EvaluationStepDefinitions.cs
index 4847bfb2..d2cd483d 100644
--- a/test/OpenFeature.E2ETests/Steps/EvaluationStepDefinitions.cs
+++ b/test/OpenFeature.E2ETests/Steps/EvaluationStepDefinitions.cs
@@ -42,7 +42,7 @@ public EvaluationStepDefinitions(ScenarioContext scenarioContext)
{
_scenarioContext = scenarioContext;
var flagdProvider = new FlagdProvider();
- Api.Instance.SetProvider(flagdProvider).Wait();
+ Api.Instance.SetProviderAsync(flagdProvider).Wait();
client = Api.Instance.GetClient();
}
diff --git a/test/OpenFeature.Tests/ClearOpenFeatureInstanceFixture.cs b/test/OpenFeature.Tests/ClearOpenFeatureInstanceFixture.cs
index a70921f7..5f31c71a 100644
--- a/test/OpenFeature.Tests/ClearOpenFeatureInstanceFixture.cs
+++ b/test/OpenFeature.Tests/ClearOpenFeatureInstanceFixture.cs
@@ -7,7 +7,7 @@ public ClearOpenFeatureInstanceFixture()
{
Api.Instance.SetContext(null);
Api.Instance.ClearHooks();
- Api.Instance.SetProvider(new NoOpFeatureProvider()).Wait();
+ Api.Instance.SetProviderAsync(new NoOpFeatureProvider()).Wait();
}
}
}
diff --git a/test/OpenFeature.Tests/OpenFeatureClientTests.cs b/test/OpenFeature.Tests/OpenFeatureClientTests.cs
index 30bee168..86c61f83 100644
--- a/test/OpenFeature.Tests/OpenFeatureClientTests.cs
+++ b/test/OpenFeature.Tests/OpenFeatureClientTests.cs
@@ -75,7 +75,7 @@ public async Task OpenFeatureClient_Should_Allow_Flag_Evaluation()
var defaultStructureValue = fixture.Create();
var emptyFlagOptions = new FlagEvaluationOptions(ImmutableList.Empty, ImmutableDictionary.Empty);
- await Api.Instance.SetProvider(new NoOpFeatureProvider());
+ await Api.Instance.SetProviderAsync(new NoOpFeatureProvider());
var client = Api.Instance.GetClient(clientName, clientVersion);
(await client.GetBooleanValue(flagName, defaultBoolValue)).Should().Be(defaultBoolValue);
@@ -121,7 +121,7 @@ public async Task OpenFeatureClient_Should_Allow_Details_Flag_Evaluation()
var defaultStructureValue = fixture.Create();
var emptyFlagOptions = new FlagEvaluationOptions(ImmutableList.Empty, ImmutableDictionary.Empty);
- await Api.Instance.SetProvider(new NoOpFeatureProvider());
+ await Api.Instance.SetProviderAsync(new NoOpFeatureProvider());
var client = Api.Instance.GetClient(clientName, clientVersion);
var boolFlagEvaluationDetails = new FlagEvaluationDetails(flagName, defaultBoolValue, ErrorType.None, NoOpProvider.ReasonNoOp, NoOpProvider.Variant);
@@ -172,7 +172,7 @@ public async Task OpenFeatureClient_Should_Return_DefaultValue_When_Type_Mismatc
mockedFeatureProvider.GetMetadata().Returns(new Metadata(fixture.Create()));
mockedFeatureProvider.GetProviderHooks().Returns(ImmutableList.Empty);
- await Api.Instance.SetProvider(mockedFeatureProvider);
+ await Api.Instance.SetProviderAsync(mockedFeatureProvider);
var client = Api.Instance.GetClient(clientName, clientVersion, mockedLogger);
var evaluationDetails = await client.GetObjectDetails(flagName, defaultValue);
@@ -202,7 +202,7 @@ public async Task Should_Resolve_BooleanValue()
featureProviderMock.GetMetadata().Returns(new Metadata(fixture.Create()));
featureProviderMock.GetProviderHooks().Returns(ImmutableList.Empty);
- await Api.Instance.SetProvider(featureProviderMock);
+ await Api.Instance.SetProviderAsync(featureProviderMock);
var client = Api.Instance.GetClient(clientName, clientVersion);
(await client.GetBooleanValue(flagName, defaultValue)).Should().Be(defaultValue);
@@ -224,7 +224,7 @@ public async Task Should_Resolve_StringValue()
featureProviderMock.GetMetadata().Returns(new Metadata(fixture.Create()));
featureProviderMock.GetProviderHooks().Returns(ImmutableList.Empty);
- await Api.Instance.SetProvider(featureProviderMock);
+ await Api.Instance.SetProviderAsync(featureProviderMock);
var client = Api.Instance.GetClient(clientName, clientVersion);
(await client.GetStringValue(flagName, defaultValue)).Should().Be(defaultValue);
@@ -246,7 +246,7 @@ public async Task Should_Resolve_IntegerValue()
featureProviderMock.GetMetadata().Returns(new Metadata(fixture.Create()));
featureProviderMock.GetProviderHooks().Returns(ImmutableList.Empty);
- await Api.Instance.SetProvider(featureProviderMock);
+ await Api.Instance.SetProviderAsync(featureProviderMock);
var client = Api.Instance.GetClient(clientName, clientVersion);
(await client.GetIntegerValue(flagName, defaultValue)).Should().Be(defaultValue);
@@ -268,7 +268,7 @@ public async Task Should_Resolve_DoubleValue()
featureProviderMock.GetMetadata().Returns(new Metadata(fixture.Create()));
featureProviderMock.GetProviderHooks().Returns(ImmutableList.Empty);
- await Api.Instance.SetProvider(featureProviderMock);
+ await Api.Instance.SetProviderAsync(featureProviderMock);
var client = Api.Instance.GetClient(clientName, clientVersion);
(await client.GetDoubleValue(flagName, defaultValue)).Should().Be(defaultValue);
@@ -290,7 +290,7 @@ public async Task Should_Resolve_StructureValue()
featureProviderMock.GetMetadata().Returns(new Metadata(fixture.Create()));
featureProviderMock.GetProviderHooks().Returns(ImmutableList.Empty);
- await Api.Instance.SetProvider(featureProviderMock);
+ await Api.Instance.SetProviderAsync(featureProviderMock);
var client = Api.Instance.GetClient(clientName, clientVersion);
(await client.GetObjectValue(flagName, defaultValue)).Should().Be(defaultValue);
@@ -313,7 +313,7 @@ public async Task When_Error_Is_Returned_From_Provider_Should_Return_Error()
featureProviderMock.GetMetadata().Returns(new Metadata(fixture.Create()));
featureProviderMock.GetProviderHooks().Returns(ImmutableList.Empty);
- await Api.Instance.SetProvider(featureProviderMock);
+ await Api.Instance.SetProviderAsync(featureProviderMock);
var client = Api.Instance.GetClient(clientName, clientVersion);
var response = await client.GetObjectDetails(flagName, defaultValue);
@@ -338,7 +338,7 @@ public async Task When_Exception_Occurs_During_Evaluation_Should_Return_Error()
featureProviderMock.GetMetadata().Returns(new Metadata(fixture.Create()));
featureProviderMock.GetProviderHooks().Returns(ImmutableList.Empty);
- await Api.Instance.SetProvider(featureProviderMock);
+ await Api.Instance.SetProviderAsync(featureProviderMock);
var client = Api.Instance.GetClient(clientName, clientVersion);
var response = await client.GetObjectDetails(flagName, defaultValue);
@@ -351,7 +351,7 @@ public async Task When_Exception_Occurs_During_Evaluation_Should_Return_Error()
[Fact]
public async Task Should_Use_No_Op_When_Provider_Is_Null()
{
- await Api.Instance.SetProvider(null);
+ await Api.Instance.SetProviderAsync(null);
var client = new FeatureClient("test", "test");
(await client.GetIntegerValue("some-key", 12)).Should().Be(12);
}
diff --git a/test/OpenFeature.Tests/OpenFeatureEventTests.cs b/test/OpenFeature.Tests/OpenFeatureEventTests.cs
index 8c183e63..ed5fb85d 100644
--- a/test/OpenFeature.Tests/OpenFeatureEventTests.cs
+++ b/test/OpenFeature.Tests/OpenFeatureEventTests.cs
@@ -70,7 +70,7 @@ public async Task API_Level_Event_Handlers_Should_Be_Registered()
Api.Instance.AddHandler(ProviderEventTypes.ProviderStale, eventHandler);
var testProvider = new TestProvider();
- await Api.Instance.SetProvider(testProvider);
+ await Api.Instance.SetProviderAsync(testProvider);
testProvider.SendEvent(ProviderEventTypes.ProviderConfigurationChanged);
testProvider.SendEvent(ProviderEventTypes.ProviderError);
@@ -118,7 +118,32 @@ public async Task API_Level_Event_Handlers_Should_Be_Informed_About_Ready_State_
var eventHandler = Substitute.For();
var testProvider = new TestProvider();
- await Api.Instance.SetProvider(testProvider);
+ await Api.Instance.SetProviderAsync(testProvider);
+
+ Api.Instance.AddHandler(ProviderEventTypes.ProviderReady, eventHandler);
+
+ Thread.Sleep(1000);
+ eventHandler
+ .Received()
+ .Invoke(
+ Arg.Is(
+ payload => payload.ProviderName == testProvider.GetMetadata().Name && payload.Type == ProviderEventTypes.ProviderReady
+ ));
+ }
+
+ [Fact]
+ [Specification("5.1.2", "When a `provider` signals the occurrence of a particular `event`, the associated `client` and `API` event handlers MUST run.")]
+ [Specification("5.2.2", "The `API` MUST provide a function for associating `handler functions` with a particular `provider event type`.")]
+ [Specification("5.2.3", "The `event details` MUST contain the `provider name` associated with the event.")]
+ [Specification("5.2.4", "The `handler function` MUST accept a `event details` parameter.")]
+ [Specification("5.3.1", "If the provider's `initialize` function terminates normally, `PROVIDER_READY` handlers MUST run.")]
+ [Specification("5.3.3", "Handlers attached after the provider is already in the associated state, MUST run immediately.")]
+ public void API_Level_Event_Handlers_Should_Be_Informed_About_Ready_State_After_Registering_Provider_Ready_Sync()
+ {
+ var eventHandler = Substitute.For();
+
+ var testProvider = new TestProvider();
+ Api.Instance.SetProvider(testProvider);
Api.Instance.AddHandler(ProviderEventTypes.ProviderReady, eventHandler);
@@ -143,7 +168,7 @@ public async Task API_Level_Event_Handlers_Should_Be_Informed_About_Error_State_
var eventHandler = Substitute.For();
var testProvider = new TestProvider();
- await Api.Instance.SetProvider(testProvider);
+ await Api.Instance.SetProviderAsync(testProvider);
testProvider.SetStatus(ProviderStatus.Error);
@@ -169,7 +194,7 @@ public async Task API_Level_Event_Handlers_Should_Be_Informed_About_Stale_State_
var eventHandler = Substitute.For();
var testProvider = new TestProvider();
- await Api.Instance.SetProvider(testProvider);
+ await Api.Instance.SetProviderAsync(testProvider);
testProvider.SetStatus(ProviderStatus.Stale);
@@ -198,12 +223,12 @@ public async Task API_Level_Event_Handlers_Should_Be_Exchangeable()
Api.Instance.AddHandler(ProviderEventTypes.ProviderConfigurationChanged, eventHandler);
var testProvider = new TestProvider();
- await Api.Instance.SetProvider(testProvider);
+ await Api.Instance.SetProviderAsync(testProvider);
testProvider.SendEvent(ProviderEventTypes.ProviderConfigurationChanged);
var newTestProvider = new TestProvider();
- await Api.Instance.SetProvider(newTestProvider);
+ await Api.Instance.SetProviderAsync(newTestProvider);
newTestProvider.SendEvent(ProviderEventTypes.ProviderConfigurationChanged);
@@ -224,13 +249,13 @@ public async Task API_Level_Event_Handlers_Should_Be_Removable()
Api.Instance.AddHandler(ProviderEventTypes.ProviderReady, eventHandler);
var testProvider = new TestProvider();
- await Api.Instance.SetProvider(testProvider);
+ await Api.Instance.SetProviderAsync(testProvider);
Thread.Sleep(1000);
Api.Instance.RemoveHandler(ProviderEventTypes.ProviderReady, eventHandler);
var newTestProvider = new TestProvider();
- await Api.Instance.SetProvider(newTestProvider);
+ await Api.Instance.SetProviderAsync(newTestProvider);
eventHandler.Received(1).Invoke(Arg.Is(payload => payload.ProviderName == testProvider.GetMetadata().Name));
}
@@ -255,7 +280,7 @@ public async Task API_Level_Event_Handlers_Should_Be_Executed_When_Other_Handler
Api.Instance.AddHandler(ProviderEventTypes.ProviderReady, eventHandler);
var testProvider = new TestProvider(fixture.Create());
- await Api.Instance.SetProvider(testProvider);
+ await Api.Instance.SetProviderAsync(testProvider);
failingEventHandler.Received().Invoke(Arg.Is(payload => payload.ProviderName == testProvider.GetMetadata().Name));
eventHandler.Received().Invoke(Arg.Is(payload => payload.ProviderName == testProvider.GetMetadata().Name));
@@ -274,7 +299,7 @@ public async Task Client_Level_Event_Handlers_Should_Be_Registered()
var myClient = Api.Instance.GetClient(fixture.Create());
var testProvider = new TestProvider();
- await Api.Instance.SetProvider(myClient.GetMetadata().Name, testProvider);
+ await Api.Instance.SetProviderAsync(myClient.GetMetadata().Name, testProvider);
myClient.AddHandler(ProviderEventTypes.ProviderReady, eventHandler);
@@ -303,7 +328,7 @@ public async Task Client_Level_Event_Handlers_Should_Be_Executed_When_Other_Hand
myClient.AddHandler(ProviderEventTypes.ProviderReady, eventHandler);
var testProvider = new TestProvider();
- await Api.Instance.SetProvider(myClient.GetMetadata().Name, testProvider);
+ await Api.Instance.SetProviderAsync(myClient.GetMetadata().Name, testProvider);
Thread.Sleep(1000);
@@ -330,9 +355,9 @@ public async Task Client_Level_Event_Handlers_Should_Be_Registered_To_Default_Pr
var clientProvider = new TestProvider(fixture.Create());
// set the default provider on API level, but not specifically to the client
- await Api.Instance.SetProvider(apiProvider);
+ await Api.Instance.SetProviderAsync(apiProvider);
// set the other provider specifically for the client
- await Api.Instance.SetProvider(myClientWithBoundProvider.GetMetadata().Name, clientProvider);
+ await Api.Instance.SetProviderAsync(myClientWithBoundProvider.GetMetadata().Name, clientProvider);
myClientWithNoBoundProvider.AddHandler(ProviderEventTypes.ProviderReady, eventHandler);
myClientWithBoundProvider.AddHandler(ProviderEventTypes.ProviderReady, clientEventHandler);
@@ -362,7 +387,7 @@ public async Task Client_Level_Event_Handlers_Should_Be_Receive_Events_From_Name
var clientProvider = new TestProvider(fixture.Create());
// set the default provider
- await Api.Instance.SetProvider(defaultProvider);
+ await Api.Instance.SetProviderAsync(defaultProvider);
client.AddHandler(ProviderEventTypes.ProviderConfigurationChanged, clientEventHandler);
@@ -374,7 +399,7 @@ public async Task Client_Level_Event_Handlers_Should_Be_Receive_Events_From_Name
clientEventHandler.Received(1).Invoke(Arg.Is(payload => payload.ProviderName == defaultProvider.GetMetadata().Name && payload.Type == ProviderEventTypes.ProviderConfigurationChanged));
// set the other provider specifically for the client
- await Api.Instance.SetProvider(client.GetMetadata().Name, clientProvider);
+ await Api.Instance.SetProviderAsync(client.GetMetadata().Name, clientProvider);
// now, send another event for the default handler
defaultProvider.SendEvent(ProviderEventTypes.ProviderConfigurationChanged);
@@ -403,7 +428,7 @@ public async Task Client_Level_Event_Handlers_Should_Be_Informed_About_Ready_Sta
var myClient = Api.Instance.GetClient(fixture.Create());
var testProvider = new TestProvider();
- await Api.Instance.SetProvider(myClient.GetMetadata().Name, testProvider);
+ await Api.Instance.SetProviderAsync(myClient.GetMetadata().Name, testProvider);
// add the event handler after the provider has already transitioned into the ready state
myClient.AddHandler(ProviderEventTypes.ProviderReady, eventHandler);
@@ -428,7 +453,7 @@ public async Task Client_Level_Event_Handlers_Should_Be_Removable()
myClient.AddHandler(ProviderEventTypes.ProviderReady, eventHandler);
var testProvider = new TestProvider();
- await Api.Instance.SetProvider(myClient.GetMetadata().Name, testProvider);
+ await Api.Instance.SetProviderAsync(myClient.GetMetadata().Name, testProvider);
// wait for the first event to be received
Thread.Sleep(1000);
diff --git a/test/OpenFeature.Tests/OpenFeatureHookTests.cs b/test/OpenFeature.Tests/OpenFeatureHookTests.cs
index b3aee4d8..b4cb958c 100644
--- a/test/OpenFeature.Tests/OpenFeatureHookTests.cs
+++ b/test/OpenFeature.Tests/OpenFeatureHookTests.cs
@@ -51,7 +51,7 @@ public async Task Hooks_Should_Be_Called_In_Order()
var testProvider = new TestProvider();
testProvider.AddHook(providerHook);
Api.Instance.AddHooks(apiHook);
- await Api.Instance.SetProvider(testProvider);
+ await Api.Instance.SetProviderAsync(testProvider);
var client = Api.Instance.GetClient(clientName, clientVersion);
client.AddHooks(clientHook);
@@ -197,7 +197,7 @@ public async Task Evaluation_Context_Must_Be_Merged_In_Correct_Order()
provider.ResolveBooleanValue(Arg.Any(), Arg.Any(), Arg.Any()).Returns(new ResolutionDetails("test", true));
- await Api.Instance.SetProvider(provider);
+ await Api.Instance.SetProviderAsync(provider);
var hook = Substitute.For();
hook.Before(Arg.Any>(), Arg.Any>()).Returns(hookContext);
@@ -269,7 +269,7 @@ public async Task Hook_Should_Execute_In_Correct_Order()
_ = hook.After(Arg.Any>(), Arg.Any>(), Arg.Any>());
_ = hook.Finally(Arg.Any>(), Arg.Any>());
- await Api.Instance.SetProvider(featureProvider);
+ await Api.Instance.SetProviderAsync(featureProvider);
var client = Api.Instance.GetClient();
client.AddHooks(hook);
@@ -301,7 +301,7 @@ public async Task Register_Hooks_Should_Be_Available_At_All_Levels()
var testProvider = new TestProvider();
testProvider.AddHook(hook4);
Api.Instance.AddHooks(hook1);
- await Api.Instance.SetProvider(testProvider);
+ await Api.Instance.SetProviderAsync(testProvider);
var client = Api.Instance.GetClient();
client.AddHooks(hook2);
await client.GetBooleanValue("test", false, null,
@@ -332,7 +332,7 @@ public async Task Finally_Hook_Should_Be_Executed_Even_If_Abnormal_Termination()
hook2.Finally(Arg.Any>(), null).Returns(Task.CompletedTask);
hook1.Finally(Arg.Any>(), null).Throws(new Exception());
- await Api.Instance.SetProvider(featureProvider);
+ await Api.Instance.SetProviderAsync(featureProvider);
var client = Api.Instance.GetClient();
client.AddHooks(new[] { hook1, hook2 });
client.GetHooks().Count().Should().Be(2);
@@ -377,7 +377,7 @@ public async Task Error_Hook_Should_Be_Executed_Even_If_Abnormal_Termination()
hook2.Error(Arg.Any>(), Arg.Any(), null).Returns(Task.CompletedTask);
hook1.Error(Arg.Any>(), Arg.Any(), null).Returns(Task.CompletedTask);
- await Api.Instance.SetProvider(featureProvider1);
+ await Api.Instance.SetProviderAsync(featureProvider1);
var client = Api.Instance.GetClient();
client.AddHooks(new[] { hook1, hook2 });
@@ -414,7 +414,7 @@ public async Task Error_Occurs_During_Before_After_Evaluation_Should_Not_Invoke_
_ = hook1.Error(Arg.Any>(), Arg.Any(), null);
_ = hook2.Error(Arg.Any>(), Arg.Any(), null);
- await Api.Instance.SetProvider(featureProvider);
+ await Api.Instance.SetProviderAsync(featureProvider);
var client = Api.Instance.GetClient();
client.AddHooks(new[] { hook1, hook2 });
@@ -459,7 +459,7 @@ public async Task Hook_Hints_May_Be_Optional()
hook.Finally(Arg.Any>(), Arg.Any>())
.Returns(Task.CompletedTask);
- await Api.Instance.SetProvider(featureProvider);
+ await Api.Instance.SetProviderAsync(featureProvider);
var client = Api.Instance.GetClient();
await client.GetBooleanValue("test", false, EvaluationContext.Empty, flagOptions);
@@ -537,7 +537,7 @@ public async Task When_Error_Occurs_In_After_Hook_Should_Invoke_Error_Hook()
hook.Finally(Arg.Any>(), Arg.Any>())
.Returns(Task.CompletedTask);
- await Api.Instance.SetProvider(featureProvider);
+ await Api.Instance.SetProviderAsync(featureProvider);
var client = Api.Instance.GetClient();
var resolvedFlag = await client.GetBooleanValue("test", true, config: flagOptions);
diff --git a/test/OpenFeature.Tests/OpenFeatureTests.cs b/test/OpenFeature.Tests/OpenFeatureTests.cs
index 3e8b4d3d..6445ca11 100644
--- a/test/OpenFeature.Tests/OpenFeatureTests.cs
+++ b/test/OpenFeature.Tests/OpenFeatureTests.cs
@@ -33,13 +33,13 @@ public async Task OpenFeature_Should_Initialize_Provider()
var providerMockDefault = Substitute.For();
providerMockDefault.GetStatus().Returns(ProviderStatus.NotReady);
- await Api.Instance.SetProvider(providerMockDefault).ConfigureAwait(false);
+ await Api.Instance.SetProviderAsync(providerMockDefault).ConfigureAwait(false);
await providerMockDefault.Received(1).Initialize(Api.Instance.GetContext()).ConfigureAwait(false);
var providerMockNamed = Substitute.For();
providerMockNamed.GetStatus().Returns(ProviderStatus.NotReady);
- await Api.Instance.SetProvider("the-name", providerMockNamed).ConfigureAwait(false);
+ await Api.Instance.SetProviderAsync("the-name", providerMockNamed).ConfigureAwait(false);
await providerMockNamed.Received(1).Initialize(Api.Instance.GetContext()).ConfigureAwait(false);
}
@@ -51,26 +51,26 @@ public async Task OpenFeature_Should_Shutdown_Unused_Provider()
var providerA = Substitute.For();
providerA.GetStatus().Returns(ProviderStatus.NotReady);
- await Api.Instance.SetProvider(providerA).ConfigureAwait(false);
+ await Api.Instance.SetProviderAsync(providerA).ConfigureAwait(false);
await providerA.Received(1).Initialize(Api.Instance.GetContext()).ConfigureAwait(false);
var providerB = Substitute.For();
providerB.GetStatus().Returns(ProviderStatus.NotReady);
- await Api.Instance.SetProvider(providerB).ConfigureAwait(false);
+ await Api.Instance.SetProviderAsync(providerB).ConfigureAwait(false);
await providerB.Received(1).Initialize(Api.Instance.GetContext()).ConfigureAwait(false);
await providerA.Received(1).Shutdown().ConfigureAwait(false);
var providerC = Substitute.For();
providerC.GetStatus().Returns(ProviderStatus.NotReady);
- await Api.Instance.SetProvider("named", providerC).ConfigureAwait(false);
+ await Api.Instance.SetProviderAsync("named", providerC).ConfigureAwait(false);
await providerC.Received(1).Initialize(Api.Instance.GetContext()).ConfigureAwait(false);
var providerD = Substitute.For();
providerD.GetStatus().Returns(ProviderStatus.NotReady);
- await Api.Instance.SetProvider("named", providerD).ConfigureAwait(false);
+ 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);
}
@@ -88,8 +88,8 @@ public async Task OpenFeature_Should_Support_Shutdown()
var providerB = Substitute.For();
providerB.GetStatus().Returns(ProviderStatus.NotReady);
- await Api.Instance.SetProvider(providerA).ConfigureAwait(false);
- await Api.Instance.SetProvider("named", providerB).ConfigureAwait(false);
+ await Api.Instance.SetProviderAsync(providerA).ConfigureAwait(false);
+ await Api.Instance.SetProviderAsync("named", providerB).ConfigureAwait(false);
await Api.Instance.Shutdown().ConfigureAwait(false);
@@ -103,8 +103,8 @@ public void OpenFeature_Should_Not_Change_Named_Providers_When_Setting_Default_P
{
var openFeature = Api.Instance;
- openFeature.SetProvider(new NoOpFeatureProvider());
- openFeature.SetProvider(TestProvider.DefaultName, new TestProvider());
+ openFeature.SetProviderAsync(new NoOpFeatureProvider());
+ openFeature.SetProviderAsync(TestProvider.DefaultName, new TestProvider());
var defaultClient = openFeature.GetProviderMetadata();
var namedClient = openFeature.GetProviderMetadata(TestProvider.DefaultName);
@@ -119,7 +119,7 @@ public void OpenFeature_Should_Set_Default_Provide_When_No_Name_Provided()
{
var openFeature = Api.Instance;
- openFeature.SetProvider(new TestProvider());
+ openFeature.SetProviderAsync(new TestProvider());
var defaultClient = openFeature.GetProviderMetadata();
@@ -133,8 +133,8 @@ public void OpenFeature_Should_Assign_Provider_To_Existing_Client()
const string name = "new-client";
var openFeature = Api.Instance;
- openFeature.SetProvider(name, new TestProvider());
- openFeature.SetProvider(name, new NoOpFeatureProvider());
+ openFeature.SetProviderAsync(name, new TestProvider());
+ openFeature.SetProviderAsync(name, new NoOpFeatureProvider());
openFeature.GetProviderMetadata(name).Name.Should().Be(NoOpProvider.NoOpProviderName);
}
@@ -146,8 +146,8 @@ public void OpenFeature_Should_Allow_Multiple_Client_Names_Of_Same_Instance()
var openFeature = Api.Instance;
var provider = new TestProvider();
- openFeature.SetProvider("a", provider);
- openFeature.SetProvider("b", provider);
+ openFeature.SetProviderAsync("a", provider);
+ openFeature.SetProviderAsync("b", provider);
var clientA = openFeature.GetProvider("a");
var clientB = openFeature.GetProvider("b");
@@ -188,7 +188,7 @@ public void OpenFeature_Should_Add_Hooks()
[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()
{
- Api.Instance.SetProvider(new NoOpFeatureProvider()).Wait();
+ Api.Instance.SetProviderAsync(new NoOpFeatureProvider()).Wait();
var openFeature = Api.Instance;
var metadata = openFeature.GetProviderMetadata();
@@ -238,8 +238,8 @@ public void OpenFeature_Should_Allow_Multiple_Client_Mapping()
{
var openFeature = Api.Instance;
- openFeature.SetProvider("client1", new TestProvider());
- openFeature.SetProvider("client2", new NoOpFeatureProvider());
+ openFeature.SetProviderAsync("client1", new TestProvider());
+ openFeature.SetProviderAsync("client2", new NoOpFeatureProvider());
var client1 = openFeature.GetClient("client1");
var client2 = openFeature.GetClient("client2");