var homer =newPerson { Name ="Homer", Salary =30000 };var denominator =1;Should.Throw<DivideByZeroException>(() => {var y =homer.Salary/ denominator; });
Task doSomething() should throw System.DivideByZeroException but did not
ShouldThrow Action Extension
var homer =newPerson { Name ="Homer", Salary =30000 };var denominator =1;var action = () => {var y =homer.Salary/ denominator; };action.ShouldThrow<DivideByZeroException>();
Task `var task = Task.Factory.StartNew( () => { var y = homer.Salary / denominator; }); return task;`
should throw
System.DivideByZeroException
but did not