vendredi 27 avril 2018

When using Moq to mock an interface, what happens to the methods?

When using Moq to mock an interface, what happens to the methods?

Let's say I have an interace ISomething, which IoC maps to the class Something. Then in my test I do this: var something = new Mock<ISomething>();.

Lets say the interface contains a method: string method();.

Now, if I call that method on the mocked instance, something.method(), will it be mapped to the class Something's implementation, or will it just return void? Will Moq try to map an interface with an implementation?

Aucun commentaire:

Enregistrer un commentaire