Home / ASP.NET Weblogs

Latest Microsoft Blogs

Browse by Tags

Related Posts

  • Moq Sequences Revisited

    A while back I wrote about mocking successive calls to the same method which returns a sequence of objects. Read that post for more context. In that post, I had written up an implementation, but quickly was won over by a better extension method implementation from Fredrik Kalseth . public static class MoqExtensions { public static void ReturnsInOrder<T, TResult>( this ISetup<T, TResult> setup, params TResult[] results) where T : class { setup.Returns( new Queue<TResult>(results).Dequeue); } } As good as this extension method is, I was able to improve on it today during a coding session. I was writing some code where I needed the second call to the same method to throw an exception and realized this extension wouldn’t allow...


Page 1 of 1 (1 items)

Archives