The “My Adventures in Coding” blog had a great post on utilizing Moq to return different resultsets from one method call. Depending on the setup you need, there are a few options. Using a Queue was an excellent approach and worked great in a test I just did. Check out this post if you are using Moq.
I have been using Moq as my primary mocking framework in C# for several years now. Overall I really like it, the syntax is easy to read, the mock setup is straight forward, etc. However, there are a few cases I need to mock infrequently and I always forget how to do the setup. Often because I am cycling between Scala, Python, and C#. So in this post I am just listing those three cases in hopes they may help others, yet at the same time as a reference to myself!
So for this example, first here is my example service that we will be mocking in our tests:
Return a different value the second time a mocked method is called
Let’s say I have a call in a service that returns the next item to process, such as pulling in customer requests from a queue that need to be…
View original post 401 more words