Actually, there is indeed a better way to do this:
void describe_some_exceptional_behavior()
{
context["when throwing an exception"] = () =>
{
act = () => throw new InvalidOperationException();
it["should raise the exception"] = expect<InvalidOperationException>();
};
}
Note: you assign the result of expect
directly to it
. This tripped me up the first time.
See the nspec specs for more examples.