I have the following Func method which i need to mock off
Func<Owned<ISomeInterface>> someMethod { get; set; }
but cant figure out how to mock it off using 'Moq' framework.
I have read a similar post on SO but still cant seem to mock it off, it always comes back with
Expression is not a method invocation: x => Invoke(x.someMethod )
or
A matching constructor for the given arguments was not found on the mocked type. ----> System.MissingMethodException : Constructor on type 'Owned`1Proxy40a9bf91815d4658ad2453298c903652' not found.
The Funct is defined as a property so you should use SetupSet within Moq
. In your test :
You create a mock for the Func:
THen you setup the mock for the Class containing the Func as a property and you setup the expectation on the Set method :
You create the container object for the mock:
Here is the definition of Another method of the Container class, if get the func as an input parameter and set it to the property of the contained object