diff --git a/test/OpenFeature.Tests/OpenFeatureHookTests.cs b/test/OpenFeature.Tests/OpenFeatureHookTests.cs index e81c5d3c..aa0c75c4 100644 --- a/test/OpenFeature.Tests/OpenFeatureHookTests.cs +++ b/test/OpenFeature.Tests/OpenFeatureHookTests.cs @@ -482,34 +482,33 @@ public async Task Hook_Hints_May_Be_Optional() [Specification("4.4.7", "If an error occurs in the `before` hooks, the default value MUST be returned.")] public async Task When_Error_Occurs_In_Before_Hook_Should_Return_Default_Value() { - var featureProvider = new Mock(MockBehavior.Strict); - var hook = new Mock(MockBehavior.Strict); + var featureProvider = Substitute.For(); + var hook = Substitute.For(); var exceptionToThrow = new Exception("Fails during default"); - var sequence = new MockSequence(); - - featureProvider.Setup(x => x.GetMetadata()) - .Returns(new Metadata(null)); - - hook.InSequence(sequence) - .Setup(x => x.Before(It.IsAny>(), It.IsAny>())) - .ThrowsAsync(exceptionToThrow); - - hook.InSequence(sequence) - .Setup(x => x.Error(It.IsAny>(), It.IsAny(), null)).Returns(Task.CompletedTask); + featureProvider.GetMetadata().Returns(new Metadata(null)); - hook.InSequence(sequence) - .Setup(x => x.Finally(It.IsAny>(), null)).Returns(Task.CompletedTask); + // Sequence + hook.Before(Arg.Any>(), Arg.Any>()).ThrowsAsync(exceptionToThrow); + hook.Error(Arg.Any>(), Arg.Any(), null).Returns(Task.CompletedTask); + hook.Finally(Arg.Any>(), null).Returns(Task.CompletedTask); var client = Api.Instance.GetClient(); - client.AddHooks(hook.Object); + client.AddHooks(hook); var resolvedFlag = await client.GetBooleanValue("test", true); + Received.InOrder(() => + { + hook.Before(Arg.Any>(), Arg.Any>()); + hook.Error(Arg.Any>(), Arg.Any(), null); + hook.Finally(Arg.Any>(), null); + }); + resolvedFlag.Should().BeTrue(); - hook.Verify(x => x.Before(It.IsAny>(), null), Times.Once); - hook.Verify(x => x.Error(It.IsAny>(), exceptionToThrow, null), Times.Once); - hook.Verify(x => x.Finally(It.IsAny>(), null), Times.Once); + _ = hook.Received(1).Before(Arg.Any>(), null); + _ = hook.Received(1).Error(Arg.Any>(), exceptionToThrow, null); + _ = hook.Received(1).Finally(Arg.Any>(), null); } [Fact]