Reputation: 11454
I have a unit test where I mock the result of something which has a DateTime property which is set when I perform the action - a "CreatedOn" property. Since I can't create my result and perform the action at the same time my Assert.AreEqual always fails. How can I test that my two objects are the same Except for certain DateTime fields?
Upvotes: 2
Views: 1609
Reputation: 236208
I usually do one of following things:
Upvotes: 1
Reputation: 564403
There are really two options here:
CreatedOn
after the creation time to make the properties match. This may or may not be possible given your API.CreatedOn
property. Just use that. This is effectively just multiple Assert.AreEqual
calls, but on individual properties, not just the object as a whole.Upvotes: 1