Skip to content

Commit

Permalink
fix Fields beforeVerify and afterVerify Not Properly Handled in Verif…
Browse files Browse the repository at this point in the history
…ySettings (#1373)
  • Loading branch information
SimonCropp authored Dec 19, 2024
1 parent 7e1deb1 commit 946a5c6
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/verify-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public Task OnCallbacks()
return Verify("value", settings);
}
```
<sup><a href='/src/Verify.Tests/Tests.cs#L122-L150' title='Snippet source file'>snippet source</a> | <a href='#snippet-OnInstanceHandlers' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Tests.cs#L137-L165' title='Snippet source file'>snippet source</a> | <a href='#snippet-OnInstanceHandlers' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down Expand Up @@ -215,7 +215,7 @@ public Task OnFluentCallbacks() =>
return Task.CompletedTask;
});
```
<sup><a href='/src/Verify.Tests/Tests.cs#L152-L176' title='Snippet source file'>snippet source</a> | <a href='#snippet-OnFluentHandlers' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Tests.cs#L167-L191' title='Snippet source file'>snippet source</a> | <a href='#snippet-OnFluentHandlers' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ var result = await Verify(
});
Assert.Contains("Value To Check", result.Text);
```
<sup><a href='/src/Verify.Tests/Tests.cs#L414-L423' title='Snippet source file'>snippet source</a> | <a href='#snippet-VerifyResult' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Tests.cs#L429-L438' title='Snippet source file'>snippet source</a> | <a href='#snippet-VerifyResult' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

If using `Verifier.Throws`, the resulting `Exception` will also be accessible
Expand Down
1 change: 1 addition & 0 deletions src/Verify.Tests/Tests.OnCallbacksTest.verified.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
value
15 changes: 15 additions & 0 deletions src/Verify.Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 3 additions & 0 deletions src/Verify/VerifySettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 946a5c6

Please sign in to comment.