dimanche 12 juin 2016

Invalid setup on a non virtual member using MOQ

I'm moqing an interface which has:

Dictionary<string, object> InstanceVariables { get; set; }

I've created a new mock of the interface and trying to set it up so it returns just a random string like so:

_mockContext.SetupGet(m => m.InstanceVariables[It.IsAny<string>()]).Returns(@"c:\users\randomplace");

But I seem to get an error:

{"Invalid setup on a non-virtual (overridable in VB) member: m => m.InstanceVariables[It.IsAny<String>()]"}

What does this mean exactly? I am mocking the interface so shouldn't this not be a problem?

Thanks

Aucun commentaire:

Enregistrer un commentaire