简体   繁体   English

是否有.NET / C#模拟框架,不需要虚拟方法

[英]Is there a .NET/C# mocking framework that doesn't require virtual methods

I'm trying to unit test a .NET web project with Visual Studio 2013's built-in tools. 我正在尝试使用Visual Studio 2013的内置工具对.NET Web项目进行单元测试。 I have added Moq with NuGet, but can't test the controllers without rewriting the entire project with virtual methods and/or interfaces. 我已经使用NuGet添加了Moq,但是如果不使用虚拟方法和/或接口重写整个项目,则无法测试控制器。 So I am seeking a way to test the code without mucking about in the existing source code. 所以我正在寻找一种方法来测试代码,而不是在现有的源代码中捣乱。

Thanks in advance for any help 在此先感谢您的帮助

也许看看FakeItEasy: http ://fakeiteasy.github.io/

Since you are using VS2013 you can take advantage of Microsoft Fakes and Shims. 由于您使用的是VS2013,因此您可以利用Microsoft Fakes和Shims。 More details and usage at http://msdn.microsoft.com/en-us/library/hh549175.aspx 有关更多详细信息和用法,请访问http://msdn.microsoft.com/en-us/library/hh549175.aspx

The three current libraries able to do "elevated" mocking are: 能够进行“提升”模拟的三个当前库是:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM