Testing Exception Messages with Shouldly
<p>Is there a way to test the exception messages with shouldly?</p>

<p>An example:</p>

<pre><code>public class MyException: Exception{
}
</code></pre>

<p>The method  to be tested:</p>

<pre><code>public class ClassUnderTest
{
    public void DoSomething() 
    {
        throw new MyException("Message");
    }
}
</code></pre>

<p>I would usually test this in this way:</p>

<pre><code>[TestMethod]
public void Test()
{
    try
    {
        new ClassUnderTest().DoSomething();
        Assert.Fail("Exception not thrown");
    } catch(MyException me)
    {
        Assert.AreEqual("Message", me.Message);
    }catch(Exception e)
       Assert.Fail("Wrong exception thrown");
    }
}
</code></pre>

<p>With shouldly I can now test if a exception is thrown:</p>

<pre><code>[TestMethod]
public void TestWithShouldly()
{
    Should.ThrowException&lt;MyException&gt;(() =&gt; new ClassUnderTest().DoSomething());
}
</code></pre>

<p>But how can I test the message of the exception?</p>