简体   繁体   中英

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).

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

Here is a quite similar example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM