I get a Moq object to return different values on successive calls to a method. This is done by this extension method:
public static void ReturnsInOrder<T, TResult>(this ISetup<T, TResult> setup, params TResult[] results) where T : class
{
setup.Returns(new Queue<TResult>(results).Dequeue);
}
Now I want one of the calls to throw an exception while others return something. Has anyone done this before?
If i do this
mock.Setup(m => m.SomeMethod())
.Throws(new Exception());
mock.Setup(m => m.SomeMethod())
.Returns("ok");
then the the first setup is overwritten and only the second setup persists.