How do I assert that collection contains only one element with given property value?
For example:
class Node
{
private readonly string myName;
public Node(string name)
{
myName = name;
}
public string Name { get; set; }
}
[Test]
public void Test()
{
var array = new[]{ new Node("1"), new Node("2"), new Node("1")};
Assert.That(array, Has.Some.Property("Name").EqualTo("1"));
Assert.That(array, Has.None.Property("Name").EqualTo("1"));
// and how to assert that node with Name="1" is single?
Assert.That(array, Has.???Single???.Property("Name").EqualTo("1"));
}