I have in my test suite a test that goes something like this:
[Fact]
public void VerifySomeStuff()
{
var stuffCollection = GetSomeStuff();
Assert.Equal(
If you have more than one item, you can't use Assert.Single.
The expectation seems to be that you should use Assert.Collection
:
var stuffCollection = GetSomeStuff();
Assert.Collection(stuffCollection,
item => true, // this lambda verifies the first item
item => true, // second item
);
The assertion above verifies that there are exactly two items in the collection. You can provide stricter lambdas (such as item => item.property1 == 7
) for each item if you want.
Personally, I'm not a fan; this seems like a very verbose way of saying how long you want the collection to be.