Sanitize or Count custom members #1149
-
I've got a class like this which I would like to apply counting or sanitizing like is done automatically for guids and dates: public record Commit(string Hash, string ParentHash) these hashes change every test, like a Guid, I just want to verify that they are stable across many objects. For example if this is my json: [
{"hash": "abc", "parentHash": "none"},
{"hash": "xyz", "parentHash": "abc"}
] then it would be sanitized into this: [
{"hash": "hash1", "parentHash": "hash2"},
{"hash": "hash3", "parentHash": "hash1"}
] And I could configure this by specifying members I want to put into the same counting bucket. I'm not sure how I would do that today. If there was a way I could map a member to another value then I could implement it myself by converting the hash to something consistent, basically writing my own counter like guid or dates do. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
there is no built in feature to achieve this. but your could leverage MemberConverter https://github.com/VerifyTests/Verify/blob/main/docs/serializer-settings.md#converting-a-member
produces
|
Beta Was this translation helpful? Give feedback.
there is no built in feature to achieve this. but your could leverage MemberConverter https://github.com/VerifyTests/Verify/blob/main/docs/serializer-settings.md#converting-a-member