NUnit: Assert.Throws

Posted by epitka on Stack Overflow See other posts from Stack Overflow or by epitka
Published on 2009-10-22T19:46:13Z Indexed on 2010/05/19 22:10 UTC
Read the original article Hit count: 213

Filed under:
|
|

How do I use Assert.Throws to assert type of the exception and the actual message workding.

Something like this:

Assert.Throws<Exception>(
    ()=>user.MakeUserActive()).WithMessage("Actual exception message")

Method I am testing throws multiple messages of the same type, with different message and I need a way to test that correct message is thrown depending on the context.

© Stack Overflow or respective owner

Related posts about nunit

Related posts about exception