Created
September 26, 2023 19:16
-
-
Save rcollette/a0d6780ad1d7058e4fb321c35255f623 to your computer and use it in GitHub Desktop.
FluentAssertion Matcher for Moq
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
namespace Moq; | |
public static class ItExt | |
{ | |
public static T IsEquivalentTo<T>(T expected) | |
{ | |
// An inner function like this is called a local function, equivalent to Func<>() = ()=> ; | |
bool Validate(T actual) | |
{ | |
actual.Should().BeEquivalentTo(expected); | |
return true; | |
} | |
// Passing in a method this way is called a Method Group | |
return Match.Create<T>(Validate); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment