Reputation: 11818
it seems there are no delegates to properties. Is there a convenient way to do the following?
Assert.Throws<InvalidOperationException>(
delegate
{
// Current is a property as we all know
nullNodeList.GetEnumerator().Current;
});
Upvotes: 9
Views: 3537
Reputation: 188
Fast-forward four years and NUnit now supports this (current version is v2.6 - I've not checked which version this was introduced).
Assert.That(() => nullNodeList.GetEnumerator().Current,
Throws.InvalidOperationException);
Upvotes: 11
Reputation: 1039498
You could try assigning it to a variable or try enumerating:
Assert.Throws<InvalidOperationException>(delegate
{
// Current is a property as we all know
object current = nullNodeList.GetEnumerator().Current;
});
Upvotes: 1
Reputation: 115877
Assert.Throws<InvalidOperationException>(
delegate { object current = nullNodeList.GetEnumerator().Current; });
Upvotes: 8
Reputation: 2259
why not say:
Assert.Throws<InvalidOperationException>(
() => nullNodeList.GetEnumerator().Current);
Upvotes: 0