问题描述
当我编写单元测试时,我喜欢使用 Rhino Mocks.
When I write unit tests I like to use Rhino Mocks.
所以当我开始我的第一个 Windows 应用商店应用程序时,我自然而然地首先开始我的单元测试.当我尝试通过 NuGetRhinoMocks/a> 我收到以下错误
So when I started my first Windows Store application I naturally started with my unit tests first. When I tried to add RhinoMocks via NuGet I recieved the following error
无法安装软件包RhinoMocks 3.6.1".你正试图将此包安装到目标项目中'.NETCore,Version=v4.5',但包不包含任何程序集与该框架兼容的参考.更多信息,请联系包作者.
我对起订量也有同样的问题.
I had the same issue with Moq.
是否有 .NETCor,Version=v4.5 的模拟框架?
Is there a mocking framework for .NETCor,Version=v4.5?
推荐答案
大多数模拟框架都基于 Reflection.Emit
.不幸的是,Reflection.Emit
不在 WinRT 中.这意味着你不能做动态代理.(即运行时模拟).这留下了在编译时引用的模拟的预生成.我知道的唯一框架是 Moq 的一个实验分支:https://github.com/mbrit/moqrt
Most mocking frameworks are based on Reflection.Emit
. Unfortunately Reflection.Emit
isn't in WinRT. This means you can't do dynamic proxies. (I.e. Run-time mocking). This leaves pre-generation of mocks that get referenced at compile-time. The only framework I know of is an experimental branch of Moq: https://github.com/mbrit/moqrt
这篇关于Windows Store 应用程序的单元测试库中选择的模拟框架是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!