I have codes like below. The first call of save(), I want it to throw an exception. And the second call when obj.field="ok", I do not want it to throw exception. How do i achieve this through Nsubstitute?
Try { //Source codes
workItem.save() //save() has void as return type
} catch (Exception e) {
if (somecondition){
workItem.field = "OK";
workItem.save();
}
}
// Unit Test
workItem.When(fake => fake.Save()).Do(call => { throw new AggregateException(); });
// How do I make the second call to workItem.save() not throw any exception??