I have a function called GetNumber() in Math class. I would like to return 1 for the first call, 2 for the second call and so on. I have done this in Mockito something like this
when(mathObj.GetNumber()).thenReturn(1).thenReturn(2).thenReturn(3);
How can I do the same with FakeItEasy
A.CallTo( () => mathObj.GetNumber()).Returns("")
See Return Values Calculated at Call Time and Changing behavior between calls for a few examples. One option is
A.CallTo(() => mathObj.GetNumber()).ReturnsNextFromSequence(1, 2, 3);
another is
A.CallTo(() => mathObj.GetNumber())
.Returns(1).Once()
.Then
.Returns(2).Once()
.Then
.Returns(3).Once();
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