Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Mocking Framework that supports optional parameters and .Net 4.0

Is there a mocking framework that exists for C# that supports .Net 4.0 and C# completely. Specifically, I'm looking for it to support optional parameters.

like image 219
Mark S. Avatar asked Jul 12 '11 19:07

Mark S.


2 Answers

I was able to get Moq to handle this by writing an extension method that accepted a method name and a dictionary of the parameter names and values that you did want to specify and the extension method creates calls to It.IsAny() for all the parameters that you didn't specify:

http://d4nt.com/handling-method-parameter-default-values-using-moq/

like image 155
d4nt Avatar answered Oct 14 '22 15:10

d4nt


I'm pretty sure MOQ does - http://code.google.com/p/moq/

http://code.google.com/p/moq/issues/detail?id=221 - optional param support in .NET 4.0

like image 27
slandau Avatar answered Oct 14 '22 13:10

slandau