1. Is there a simple way to compare two anonymous types using SemanticComparison from AutoFixture ? My current issue is that I can't construct Likeness for second anonymous object. Simplified example :
var srcAnon = new { time = expectedTime, data = docsArray };
var resultAnon = new { time=actualTime, data = sutResponseArray };
var expectedAlike = srcAnon.AsSource()
.OfLikeness<??WhatsHere??>()
2. I think this question is pretty related to the first one as they both use SemanticComparison to create IEquatable
implementations. In this question Mark Seemann provided an answer on how to do it using MSTest assertions and LINQ SequenceEqual
method.
Is this possible to use XUnit2 assertions library in the similar scenario? XUnit supports Assert.Equal()
for collections of the same type, can it be used for collections of different types, but if the elements implement IEquatable (using Likeness). Something like this (this doesn't work as result
and allLikeness
have different types):
Assert.Equal(allLikeness.ToArray(),result.ToArray());
Aucun commentaire:
Enregistrer un commentaire