NotThrow

ShouldNotThrowAction

var homer = new Person { Name = "Homer", Salary = 30000 };
var denominator = 0;
Should.NotThrow(() =>
                {
                    var y = homer.Salary / denominator;
                });

snippet source | anchor

Exception

`var y = homer.Salary / denominator;`
    should not throw but threw
System.DivideByZeroException
    with message
"Attempted to divide by zero."

ShouldNotThrow Action Extension

var homer = new Person { Name = "Homer", Salary = 30000 };
var denominator = 0;
var action = () =>
                {
                    var y = homer.Salary / denominator;
                };
action.ShouldNotThrow();

snippet source | anchor

Exception

ShouldNotThrowFunc

snippet source | anchor

Exception

ShouldNotThrow Func Extension

snippet source | anchor

Exception

ShouldNotThrowFuncOfTask

snippet source | anchor

Exception

Last updated