Delegates
Moq can be used to create fake delegates. Mocks faking delegates can be configured like normal methods to return a value, execute a callback or throw an exception.
The snippets below are based on the following type
Moq can fake explicit delegates by simply passing their type to the constructor.
Alternatively, Moq supports delegates based on Func
and Action
.
It is possible to configure the delegates as if they were normal methods.
Finally, Moq can generate implicit mocks for delegates too.
Last updated