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,...

Advertisement
Free Agile Project Management Tool from Telerik
TeamPulse Community Edition helps your team effectively capture requirements, manage project plans, assign and track work, and most importantly, be continually connected with each other.
Category: Agile | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 1102 | Hits: 38

Similar Posts

  • Fun With Method Missing and C# 4 more
  • Exception Handling Advice for ASP.NET Web Applications more
  • AJAX Logging with Exponential Backoff more
  • The MethodLinq concept more
  • Minimizing unit Test Fragility 8 features in Typemock Isolator to help more
  • Dynamic Delegates with Expression Trees more
  • Method_Missing: Cool Uses more
  • Adding Method-Missing support to VB.NET using CTru and Typemock Open-AOP more
  • Making extension methods amenable to mocking more
  • Background: Extension Methods, Silverlight & Linq more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD