diff --git a/docs/verify-options.md b/docs/verify-options.md index 2c250906b..3e84c670f 100644 --- a/docs/verify-options.md +++ b/docs/verify-options.md @@ -184,7 +184,7 @@ public Task OnCallbacks() return Verify("value", settings); } ``` -snippet source | anchor +snippet source | anchor @@ -215,7 +215,7 @@ public Task OnFluentCallbacks() => return Task.CompletedTask; }); ``` -snippet source | anchor +snippet source | anchor diff --git a/readme.md b/readme.md index ec41657df..b5434ba6a 100644 --- a/readme.md +++ b/readme.md @@ -800,7 +800,7 @@ var result = await Verify( }); Assert.Contains("Value To Check", result.Text); ``` -snippet source | anchor +snippet source | anchor If using `Verifier.Throws`, the resulting `Exception` will also be accessible diff --git a/src/Verify.Tests/Tests.OnCallbacksTest.verified.txt b/src/Verify.Tests/Tests.OnCallbacksTest.verified.txt new file mode 100644 index 000000000..3c877c57a --- /dev/null +++ b/src/Verify.Tests/Tests.OnCallbacksTest.verified.txt @@ -0,0 +1 @@ +value \ No newline at end of file diff --git a/src/Verify.Tests/Tests.cs b/src/Verify.Tests/Tests.cs index e06e9eff9..d073d6604 100644 --- a/src/Verify.Tests/Tests.cs +++ b/src/Verify.Tests/Tests.cs @@ -119,6 +119,21 @@ public async Task OnVerifyMismatch() Assert.True(onVerifyMismatchCalled2); } + [Fact] + public async Task OnCallbacksTest() + { + var onVerifyBeforeCalled = false; + var onVerifyAfterCalled = false; + var settings = new VerifySettings(); + settings.OnVerify( + before: () => onVerifyBeforeCalled = true, + after: () => onVerifyAfterCalled = true); + + await Verify("value", settings); + Assert.True(onVerifyBeforeCalled); + Assert.True(onVerifyAfterCalled); + } + #region OnInstanceHandlers [Fact] diff --git a/src/Verify/VerifySettings.cs b/src/Verify/VerifySettings.cs index f0205f137..8bf26d54f 100644 --- a/src/Verify/VerifySettings.cs +++ b/src/Verify/VerifySettings.cs @@ -42,6 +42,9 @@ public VerifySettings(VerifySettings? settings) hashParameters = settings.hashParameters; parametersText = settings.parametersText; fileName = settings.fileName; + handleOnFirstVerify = settings.handleOnFirstVerify; + handleOnVerifyDelete = settings.handleOnVerifyDelete; + handleOnVerifyMismatch = settings.handleOnVerifyMismatch; UniquePrefixDisabled = settings.UniquePrefixDisabled; UseUniqueDirectorySplitMode = settings.UseUniqueDirectorySplitMode; Namer = new(settings.Namer);