IFoovia its constructor and it uses it in its
IFoo.DoSomethingmethod by passing it a well-known string.
Setupto specify incoming parameters and return values.
Setupconstruct is used to configure expectations on the invocations of a method of the mocked type. At this time developers can set expectations on the incoming parameters too. In this case, Moq is instructed using the
It.IsAny<string>()method to accept any string.
Returnsconstruct is used to specify the return values of the mocked method.
string) of the method
true. Thanks to Moq's strongly-typed API, it's impossible to configure a method with wrong types.
Verifymethod to verify that the expected call had actually happened. In this example, we verify that
DoSomethingwas invoked exactly once with the string