[Cross Posted from http://www.skimedic.com/blog]
One of the trickiest types of code to mock out for testing is recursive methods. In a typical recursion, the same method is called multiple times, and each time there are typically different parameters passed in, and different return values. To easily handle this, JustMock gives you two options:
- Adding InSequence() to each arrange
- Chaining Returns() calls together.
To illustrate the first option, look at the following test:
public void Show_Sequential_InSequence_Arrange_Option()
var service = Mock.Create<IService>();
Mock.Arrange(() => service.GetSum(Arg.AnyInt, Arg.AnyInt))