IEnumerable<ReportReceipt> expected = new List<ReportReceipt>()
{
new ReportReceipt("fileName1","Hash1","some comments1")
};
IEnumerable<ReportReceipt> actual = new List<ReportReceipt>()
{
new ReportReceipt("fileName1","Hash1","some comments1")
};
Assert.IsTrue(expected.SequenceEqual(actual));
I'm running MSTest with VS 2008.
SequenceEqual determines whether two sequences are equal by comparing the elements by using the default equality comparer for their type.
If you haven't overloaded the Equals and GetHashCode in your class, the fallback object equality check will fail, since the sequences contain two different objects.
Presumably because ReportReceipt doesn't override Equals
- so it's comparing just the references, and they're unequal.
Override Equals
and GetHashCode
appropriately and it should work fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With