Skip to content

Instantly share code, notes, and snippets.

@rcollette
Created September 26, 2023 19:16
Show Gist options
  • Save rcollette/a0d6780ad1d7058e4fb321c35255f623 to your computer and use it in GitHub Desktop.
Save rcollette/a0d6780ad1d7058e4fb321c35255f623 to your computer and use it in GitHub Desktop.
FluentAssertion Matcher for Moq
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