Skip to content

Instantly share code, notes, and snippets.

@musukvl
Last active July 24, 2020 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save musukvl/9343e25636912e49055590ec0e720059 to your computer and use it in GitHub Desktop.
Save musukvl/9343e25636912e49055590ec0e720059 to your computer and use it in GitHub Desktop.
Fluent assertions: skip checking for default fields in Expectation. (for cases if we want to check only defined non-default fields)
class IgnoreNullMembersInExpectation : IEquivalencyStep
{
public bool CanHandle(IEquivalencyValidationContext context, IEquivalencyAssertionOptions config) =>
context.Expectation is null ||
context.Expectation is ValueType == default;
public bool Handle(IEquivalencyValidationContext context, IEquivalencyValidator parent, IEquivalencyAssertionOptions config) => true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment