Hi All,
I am fairly new to Moq and cant work out how I am to order setups. I have the following code:
_orderRepository.Setup(r => r.Update(It.Is<Order>(a => ((int)a.OrderStatusReference.EntityKey.EntityKeyValues[0].Value) == 2)))
.Throws(exception)
.AtMost(5);
I want this to be executed 5 times (its retry logic, if the update fails). After the 5th time I want to setup and expect that it is successful (An exception is not thrown):
_orderRepository.Setup(r => r.Update(It.Is<Order>(a => ((int)a.OrderStatusReference.EntityKey.EntityKeyValues[0].Value) == 2))).AtMostOnce();
Unfortinatly it continues to use the 1st code sample, and never successfully updates.
If I were not using the Throws method, then I can use the Callback method, however its not available after a throw :(.
If there a way or is this a limitation of Moq?