How do I use Assert.Throws to assert the type of the exception?

后端 未结 7 1613
你的背包
你的背包 2020-12-02 04:51

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

Something like this:

Assert.Throws

        
7条回答
  •  一个人的身影
    2020-12-02 05:39

    Assert.That(myTestDelegate, Throws.ArgumentException
        .With.Property("Message").EqualTo("your argument is invalid."));
    

提交回复
热议问题