[Code Snippet] Assert.Throws on Exception and Derived Type Nunit

 Code snippet for asserting throw in ArgumentException and its derived types(such as ArgumentNullException) in Nunit - 

public void Test(){

Assert.Throws(Is.InstanceOf<ArgumentException>(), () =>{

    //SUT code

});

}

Comments

Popular posts from this blog

[Code Snippet] Assert Exception in private methods using PrivateObject

Update WPF Interaction Triggers in from .Net Framework 4.8 to .Net 5

[Code snippet] How to set value of private variable in Unit Test Using Reflection ?