Answers for "nunit throws message"

0

nunit throws message

[Test]
public void TestException()
{
	MyException ex = Assert.Throws<MyException>(
	delegate { throw new MyException("message", 42); });

	Assert.That(ex.Message, Is.EqualTo("message"));
	Assert.That(ex.MyParam, Is.EqualTo(42)); 
}
Posted by: Guest on April-01-2020
0

nunit throws message

[Test]
  public void TestException()
  {
    Assert.Throws(Is.TypeOf<MyException>()
                 .And.Message.EqualTo("message")
                 .And.Property("MyParam").EqualTo(42),
      delegate { throw new MyException("message", 42); });
  }
Posted by: Guest on April-01-2020

Browse Popular Code Answers by Language