-
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Verifier before after callbacks (#348)
- Loading branch information
1 parent
0fdd133
commit 50b68b4
Showing
12 changed files
with
76 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,66 @@ | ||
namespace VerifyTests | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace VerifyTests | ||
{ | ||
public static partial class VerifierSettings | ||
{ | ||
internal static FirstVerify? handleOnFirstVerify; | ||
static FirstVerify? handleOnFirstVerify; | ||
|
||
public static void OnFirstVerify(FirstVerify firstVerify) | ||
{ | ||
Guard.AgainstNull(firstVerify, nameof(firstVerify)); | ||
handleOnFirstVerify += firstVerify; | ||
} | ||
|
||
internal static VerifyMismatch? handleOnVerifyMismatch; | ||
internal static Task RunOnFirstVerify(FilePair item) | ||
{ | ||
if (handleOnFirstVerify == null) | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
|
||
return handleOnFirstVerify(item); | ||
} | ||
|
||
static VerifyMismatch? handleOnVerifyMismatch; | ||
|
||
internal static Task RunOnVerifyMismatch(FilePair item, string? message) | ||
{ | ||
if (handleOnVerifyMismatch == null) | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
|
||
return handleOnVerifyMismatch(item, message); | ||
} | ||
|
||
public static void OnVerifyMismatch(VerifyMismatch verifyMismatch) | ||
{ | ||
Guard.AgainstNull(verifyMismatch, nameof(verifyMismatch)); | ||
handleOnVerifyMismatch += verifyMismatch; | ||
} | ||
|
||
public static void OnVerify(Action before, Action after) | ||
{ | ||
Guard.AgainstNull(before, nameof(before)); | ||
Guard.AgainstNull(after, nameof(after)); | ||
beforeVerify += before; | ||
afterVerify += after; | ||
} | ||
|
||
static Action? beforeVerify; | ||
|
||
internal static void RunBeforeCallbacks() | ||
{ | ||
beforeVerify?.Invoke(); | ||
} | ||
|
||
static Action? afterVerify; | ||
|
||
internal static void RunAfterCallbacks() | ||
{ | ||
afterVerify?.Invoke(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters