In some scenarios it makes sense to auto-accept any changes as part of a given test run. For example:
- Keeping a text representation of a Database schema in a
.verified.sql
file (see Verify.SqlServer).
This can be done using AutoVerify()
:
var settings = new VerifySettings();
settings.AutoVerify();
Note that auto accepted changes in .verified.
files remain visible in source control tooling.
OnVerify
takes two actiosn that are called before and after each verification.OnFirstVerify
is called when there is no verified file.OnVerifyMismatch
is called when a received file does not match the existing verified file.
public Task OnHandlersSample()
{
VerifierSettings.OnVerify(
before: () => { Debug.WriteLine("before"); },
after: () => { Debug.WriteLine("after"); });
VerifierSettings.OnFirstVerify(
receivedFile =>
{
Debug.WriteLine(receivedFile);
return Task.CompletedTask;
});
VerifierSettings.OnVerifyMismatch(
(filePair, message) =>
{
Debug.WriteLine(filePair.Received);
Debug.WriteLine(filePair.Verified);
Debug.WriteLine(message);
return Task.CompletedTask;
});
return Verifier.Verify("value");
}