Successive Method Calls With MoQ
Posted by: youve been HAACKED,
on 30 Sep 2009 |
View original | Bookmarked: 0 time(s)
One area where using MoQ is confusing is when mocking successive calls to the same method of an object. For example, I was writing some tests for legacy code where I needed to fake out multiple calls to a data reader. You remember data readers, dont you? Heres a snippet of the code I was testing. Ignore the map method and focus on the call to reader.Read. while(reader.Read()) {
yield return map(reader);
}
Notice that there are multiple calls to reader.Read. The first couple times,...