MOQ - verify exception was thrown

前端 未结 7 1913
暗喜
暗喜 2021-01-07 16:22

I working with MOQ framework for my testing. I have a scenario in which I expect a fault exception to be thrown. How can I verify it was thrown?

public void          


        
7条回答
  •  长发绾君心
    2021-01-07 17:08

    You can test that an Exception is thrown using NUnit Asserts:

    Assert.That(() => testObject.methodToTest(), Throws.TypeOf());
    

提交回复
热议问题