How to MOQ an Indexed property

It’s not clear what you’re trying to do because you don’t show the declaration of the mock. Are you trying to mock a dictionary?

MyContainer[(string s)] isn’t valid C#.

This compiles:

var mock = new Mock<IDictionary>();
mock.SetupGet( p => p[It.IsAny<string>()]).Returns("foo");

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)