Mocking indexer getters with Moq

Posted by: More Whidbey stuff, on 16 Jul 2009 | View original | Bookmarked: 0 time(s)

This is a follow-up on that other post: Mocking indexer setters with Moq. So thanks to that post, we now know how to intercept the setting of a particular indexed property (in our example, an application variable) and set a local variable with the value that was set by the tested code. Now if you want the application to return that same value when queried by the tested code, you also need to mock the indexer getter. This operation is also not entirely trivial. Heres how you do it: you do a SetupGet...

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: .NET | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 856 | Hits: 33

Similar Posts

  • Monkey Patching CLR Objects 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