Because of the lack of views to this post, I posted on StackOverflow:  
http://stackoverflow.com/questions/11037639/rhinomocks-getting-the-value-passed-into-an-indexer-this

jimmy_keen was able to provide an answer:

The exception tells you exactly what is happening:

InvalidOperationException: No expectations were setup to be verified, *
ensure* that the *method* call in the action is a *virtual* (C#) / 
overridable (VB.Net) method call.

Which means, in order for Rhino to properly work (or, in order for Castle 
to generate working proxies <http://stackoverflow.com/a/10796367/343266>) 
your indexer has to be virtual. If you can't make it so, Rhino won't help 
you in this situation.

Once you make your indexer virtual, it is simple task:

var cache = MockRepository.GenerateMock<WebDataChache>();
cache.Expect(c => c["SomeKey"]).Returns("SomeValue");

// perform actual test

mock.VerifyAllExpectations();

This ensures that cache is accessed with ["SomeKey"]. If key value will be 
different, test will fail atVerifyAllExpectations line.

-- 
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rhinomocks/-/ozkZDACjOh0J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rhinomocks?hl=en.

Reply via email to