Throw
ShouldThrowAction
var homer = new Person { Name = "Homer", Salary = 30000 };
var denominator = 1;
Should.Throw<DivideByZeroException>(() =>
{
var y = homer.Salary / denominator;
});Exception
`var y = homer.Salary / denominator;`
should throw
System.DivideByZeroException
but did notShouldThrowAsync
Task doSomething() => Task.CompletedTask;
var exception = await Should.ThrowAsync<DivideByZeroException>(() => doSomething());Exception
Task doSomething() should throw System.DivideByZeroException but did not
ShouldThrow Action Extension
Exception
ShouldThrowFunc
Exception
ShouldThrow Func Extension
Exception
ShouldThrowFuncOfTask
Exception
Last updated