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