Exemple #1
0
        public ApiApprovalTests()
            : base()
        {
            verifySettings = new VerifySettings();
            verifySettings.UseExtension("cs");

            VerifierSettings.OnVerifyMismatch((filePair, message) => DiffPlexReporter.Report(filePair.Received, filePair.Verified, message));
        }
Exemple #2
0
 public async Task OnHandlersSample()
 {
     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);
     });
     await Verifier.Verify("value");
 }
Exemple #3
0
    public async Task OnVerifyMismatch()
    {
        var onFirstVerifyCalled    = false;
        var onVerifyMismatchCalled = false;

        VerifierSettings.OnFirstVerify(
            filePair =>
        {
            if (filePair.Name.Contains("OnVerifyMismatch"))
            {
                onFirstVerifyCalled = true;
            }

            return(Task.CompletedTask);
        });
        VerifierSettings.OnVerifyMismatch(
            (filePair, _) =>
        {
            if (filePair.Name.Contains("OnVerifyMismatch"))
            {
                Assert.NotEmpty(filePair.Received);
                Assert.NotNull(filePair.Received);
                Assert.NotEmpty(filePair.Verified);
                Assert.NotNull(filePair.Verified);
                onVerifyMismatchCalled = true;
            }

            return(Task.CompletedTask);
        });
        await Assert.ThrowsAsync <Exception>(
            async() =>
        {
            DiffRunner.Disabled = true;
            await Verifier.Verify("value");
        });

        DiffRunner.Disabled = false;

        Assert.False(onFirstVerifyCalled);
        Assert.True(onVerifyMismatchCalled);
    }
Exemple #4
0
 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"));
 }