ExpectedException Assert

前端 未结 5 1213
死守一世寂寞
死守一世寂寞 2021-02-08 05:25

I need to write a unit test for the next function and I saw I can use [ExpectedException]

this is the function to be tested.

public static T FailIfEnumIs         


        
5条回答
  •  伪装坚强ぢ
    2021-02-08 05:50

    Assert the exception is throw with the correct exception message with :

    var ex = Assert.Throws(() => _foo.DoSomething(a, b, c));
    Assert.That(ex.Message, Is.EqualTo("Your exception message"));
    

提交回复
热议问题