I have next interface
public interface IMyInterface
{
string this[string key] { get; set; }
}
and i want implement get/set in my test
var _Nvp = //...
var mockMyInterface = new Mock<IMyInterface>();
mockMyInterface
.Setup(e => e[It.IsAny<string>()])
.Returns((string key) => _Nvp[key]);
mockMyInterface
.SetupSet(c => c[It.IsAny<string>()] = It.IsAny<string>())
.Callback((string key, string value) => { _Nvp[key] = value; }));
But it does not work.. No errors, no messages..
var oj = mockMyInterface.Object;
oj["key"] = "value";
var value = oj["key"];
Variable value is always null.