Skip to content

Commit ab3b4fb

Browse files
committed
Fix unit test.
Signed-off-by: André Silva <[email protected]>
1 parent 194901a commit ab3b4fb

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

test/OpenFeature.Tests/OpenFeatureTests.cs

+13-8
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ public async Task OpenFeature_Should_Initialize_Provider()
3131
providerMockDefault.Status.Returns(ProviderStatus.NotReady);
3232

3333
await Api.Instance.SetProviderAsync(providerMockDefault);
34-
await providerMockDefault.Received(1).InitializeAsync(Api.Instance.GetContext());
34+
35+
await providerMockDefault.Received(1).InitializeAsync(Arg.Is<EvaluationContext>(e => e.Count == 0));
3536

3637
var providerMockNamed = Substitute.For<FeatureProvider>();
3738
providerMockNamed.Status.Returns(ProviderStatus.NotReady);
3839

3940
await Api.Instance.SetProviderAsync("the-name", providerMockNamed);
40-
await providerMockNamed.Received(1).InitializeAsync(Api.Instance.GetContext());
41+
await providerMockNamed.Received(1).InitializeAsync(Arg.Is<EvaluationContext>(e => e.Count == 0));
4142
}
4243

4344
[Fact]
@@ -49,26 +50,26 @@ public async Task OpenFeature_Should_Shutdown_Unused_Provider()
4950
providerA.Status.Returns(ProviderStatus.NotReady);
5051

5152
await Api.Instance.SetProviderAsync(providerA);
52-
await providerA.Received(1).InitializeAsync(Api.Instance.GetContext());
53+
await providerA.Received(1).InitializeAsync(Arg.Is<EvaluationContext>(e => e.Count == 0));
5354

5455
var providerB = Substitute.For<FeatureProvider>();
5556
providerB.Status.Returns(ProviderStatus.NotReady);
5657

5758
await Api.Instance.SetProviderAsync(providerB);
58-
await providerB.Received(1).InitializeAsync(Api.Instance.GetContext());
59+
await providerB.Received(1).InitializeAsync(Arg.Is<EvaluationContext>(e => e.Count == 0));
5960
await providerA.Received(1).ShutdownAsync();
6061

6162
var providerC = Substitute.For<FeatureProvider>();
6263
providerC.Status.Returns(ProviderStatus.NotReady);
6364

6465
await Api.Instance.SetProviderAsync("named", providerC);
65-
await providerC.Received(1).InitializeAsync(Api.Instance.GetContext());
66+
await providerC.Received(1).InitializeAsync(Arg.Is<EvaluationContext>(e => e.Count == 0));
6667

6768
var providerD = Substitute.For<FeatureProvider>();
6869
providerD.Status.Returns(ProviderStatus.NotReady);
6970

7071
await Api.Instance.SetProviderAsync("named", providerD);
71-
await providerD.Received(1).InitializeAsync(Api.Instance.GetContext());
72+
await providerD.Received(1).InitializeAsync(Arg.Is<EvaluationContext>(e => e.Count == 0));
7273
await providerC.Received(1).ShutdownAsync();
7374
}
7475

@@ -212,13 +213,17 @@ public void Should_Set_Given_Context()
212213

213214
Api.Instance.SetContext(context);
214215

215-
Api.Instance.GetContext().Should().BeSameAs(context);
216+
var context2 = Api.Instance.GetContext();
217+
context2.Count.Should().Be(context.Count);
218+
context2.TargetingKey?.Should().Be(context.TargetingKey);
216219

217220
context = EvaluationContext.Builder().Build();
218221

219222
Api.Instance.SetContext(context);
220223

221-
Api.Instance.GetContext().Should().BeSameAs(context);
224+
var context3 = Api.Instance.GetContext();
225+
context3.Count.Should().Be(context.Count);
226+
context3.TargetingKey?.Should().Be(context.TargetingKey);
222227
}
223228

224229
[Fact]

0 commit comments

Comments
 (0)