Using FluentAssertions:
I'm able to exclude a single property using ShouldBeEquivalentTo.
x.ShouldBeEquivalentTo(y, opts => opts.Excluding(si => !si.PropertyInfo.CanWrite));
But, how do I exclude more then 1 property when using ShouldBeEquivalentTo() ?
You don't necessarily need a separate method. Chain multiple calls fluently like so.
x.ShouldBeEquivalentTo(y, opts => opts.Excluding(si => !si.PropertyInfo.CanWrite).Excluding(si => si.SomeOtherProperty));
You 'll have to use a Function for that instead of an Expression.
x.ShouldBeEquivalentTo(y, ExcludeProperties);
private EquivalencyAssertionOptions<xx> ExcludeProperties(EquivalencyAssertionOptions<xx> options)
{
options.Excluding(t => t.CeOperator);
options.Excluding(t => t.CeOperatorName);
options.Excluding(t => t.Status);
options.Excluding(t => t.IsOperational);
return options;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With