diff --git a/test/OpenFeature.Tests/OpenFeatureTests.cs b/test/OpenFeature.Tests/OpenFeatureTests.cs index acc53b61..ebc2520e 100644 --- a/test/OpenFeature.Tests/OpenFeatureTests.cs +++ b/test/OpenFeature.Tests/OpenFeatureTests.cs @@ -31,13 +31,14 @@ public async Task OpenFeature_Should_Initialize_Provider() providerMockDefault.Status.Returns(ProviderStatus.NotReady); await Api.Instance.SetProviderAsync(providerMockDefault); - await providerMockDefault.Received(1).InitializeAsync(Api.Instance.GetContext()); + + await providerMockDefault.Received(1).InitializeAsync(Arg.Is(e => e.Count == 0)); var providerMockNamed = Substitute.For(); providerMockNamed.Status.Returns(ProviderStatus.NotReady); await Api.Instance.SetProviderAsync("the-name", providerMockNamed); - await providerMockNamed.Received(1).InitializeAsync(Api.Instance.GetContext()); + await providerMockNamed.Received(1).InitializeAsync(Arg.Is(e => e.Count == 0)); } [Fact] @@ -49,26 +50,26 @@ public async Task OpenFeature_Should_Shutdown_Unused_Provider() providerA.Status.Returns(ProviderStatus.NotReady); await Api.Instance.SetProviderAsync(providerA); - await providerA.Received(1).InitializeAsync(Api.Instance.GetContext()); + await providerA.Received(1).InitializeAsync(Arg.Is(e => e.Count == 0)); var providerB = Substitute.For(); providerB.Status.Returns(ProviderStatus.NotReady); await Api.Instance.SetProviderAsync(providerB); - await providerB.Received(1).InitializeAsync(Api.Instance.GetContext()); + await providerB.Received(1).InitializeAsync(Arg.Is(e => e.Count == 0)); await providerA.Received(1).ShutdownAsync(); var providerC = Substitute.For(); providerC.Status.Returns(ProviderStatus.NotReady); await Api.Instance.SetProviderAsync("named", providerC); - await providerC.Received(1).InitializeAsync(Api.Instance.GetContext()); + await providerC.Received(1).InitializeAsync(Arg.Is(e => e.Count == 0)); var providerD = Substitute.For(); providerD.Status.Returns(ProviderStatus.NotReady); await Api.Instance.SetProviderAsync("named", providerD); - await providerD.Received(1).InitializeAsync(Api.Instance.GetContext()); + await providerD.Received(1).InitializeAsync(Arg.Is(e => e.Count == 0)); await providerC.Received(1).ShutdownAsync(); } @@ -212,13 +213,17 @@ public void Should_Set_Given_Context() Api.Instance.SetContext(context); - Api.Instance.GetContext().Should().BeSameAs(context); + var context2 = Api.Instance.GetContext(); + context2.Count.Should().Be(context.Count); + context2.TargetingKey?.Should().Be(context.TargetingKey); context = EvaluationContext.Builder().Build(); Api.Instance.SetContext(context); - Api.Instance.GetContext().Should().BeSameAs(context); + var context3 = Api.Instance.GetContext(); + context3.Count.Should().Be(context.Count); + context3.TargetingKey?.Should().Be(context.TargetingKey); } [Fact]