Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible in AutoFixture SemanticComparison to set custom comparer for specified type

Is it possible in AutoFixture SemanticComparison to set custom comparer for specified property of a object or for specified type.

For example you need to compare objects that have property of type DateTime. You want to compare them using Likenes but you want the precision of the comparison to discard differences on milliseconds level (possibly you lost precision after retrieving DateTime from database).

like image 347
Krzysztof Branicki Avatar asked Oct 19 '22 11:10

Krzysztof Branicki


1 Answers

You may use the EqualsWhen member of the Likeness (Fluent) API for doing that.

Here is a quite similar example.

like image 113
Nikos Baxevanis Avatar answered Oct 21 '22 04:10

Nikos Baxevanis