I need to mock an interface to call to MSMQ, is there a way I can use Moq to simulate real MSMQ scenario that there are 10 messages in the queue, I call mocked function 10 t
I sometimes use a simple counter for such scenarios:
int callCounter = 0; var mock = new Mock(); mock.Setup(a => a.SomeMethod()) .Returns(() => { if (callCounter++ < 10) { // do something } else { // do something else } });