In Fluent Assertions when comparing objects with DateTime properties there are sometimes a slight mismatch in the milliseconds and the comparison fail. The way we get around it
Actually, you can. The default configuration factory is exposed by the static
property EquivalencyAssertionOptions
. You can easily assign an alternative configuration for a particular data type, or extend the default configuration with additional behavior. Something like:
var defaultAssertionOptions = EquivalencyAssertionOptions.Default;
EquivalencyAssertionOptions.Default = () =>
{
var config = defaultAssertionOptions();
config.Using(ctx => ctx.Subject.Should().BeCloseTo(ctx.Expectation)).WhenTypeIs();
return config;
};
If you want you can get the current default and tuck that away in some variable that you use from your factory method.