What is the most idiomatic way to use NUnit 2.6 to check if an exception property is equal?
The code I would like to write but does not work: Expected 3, but was <empty>
Assert.That(() => someObject.MethodThrows(), Throws.TypeOf<SomeException>().With.Property("Data").Count.EqualTo(3), "Exception expected");
I could use Assert nested expressions, but this seems too complicated and unnecessary:
Assert.AreEqual(3, Assert.Throws<SomeException>( () => someObject.MethodThrows(), "Exception expected").Data.Count);
edit Actually the first code sample works. I do not know why it did not work several times before posting this question.
knittl
source share