How to assert that a collection has exactly one item of a specified type? At the moment what I can do is:
items.Should().HaveCount(1); items[0].Should().BeOfType<MyType>();
There come some questions:
- Is it possible to do the same with a one-liner? I'm aware of the HaveElementAt() method, but it requires an object instance to compare with. I can imagine a one-argument overload of:
object HaveElementAt(int index)
items.Should().HaveCount(1).And.HaveElementAt(0).OfType<MyType>();
- In general, is it technically correct for FA to put multiple assertions in one test method?