We have to implement a retry-mechanism.
To test the RetryProvider
, I want a fake of a class to throw exceptions on the first two calls, but return a valid object on the third call.
Under normal circumstances (without throwing exceptions) we could use A.CallTo(() => this.fakeRepo.Get(1)).ReturnsNextFromSequence("a", "b", "c");
I want something similar:
How can I configure my fake to do this?
Thanks in advance
var fakeRepo = A.Fake<IFakeRepo>();
A.CallTo(() => fakeRepo.Get(1))
.Throws<NullReferenceException>()
.Once()
.Then
.Throws<NullReferenceException>()
.Once()
.Then
.Returns('a');
See more about this at Specifying different behaviors for successive calls.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With