开发者

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

开发者 https://www.devze.com 2023-03-20 00:52 出处:网络
Is there a mocking framework that exists for C# that supports .Net 4.0 and C# completely.Speci开发者_StackOverflow中文版fically, I\'m looking for it to support optional parameters.I was able to get Mo

Is there a mocking framework that exists for C# that supports .Net 4.0 and C# completely. Speci开发者_StackOverflow中文版fically, I'm looking for it to support optional parameters.


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/


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


I was actually able to find NSubstitute and it did what I need.

0

精彩评论

暂无评论...
验证码 换一张
取 消