Windows Store应用程序的单元测试库中选择的模拟框架是什么? [英] What is the mocking framework of choice in Unit Test Library for Windows Store Applications?

查看:47
本文介绍了Windows Store应用程序的单元测试库中选择的模拟框架是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编写单元测试时,我喜欢使用Rhino Mocks.

When I write unit tests I like to use Rhino Mocks.

因此,当我启动第一个Windows Store应用程序时,我自然首先要进行单元测试.当我尝试通过 NuGet RhinoMocks 添加时/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',但该软件包不包含任何程序集 与该框架兼容的参考.欲了解更多 信息,请与软件包作者联系.

Could not install package 'RhinoMocks 3.6.1'. You are trying to install this package into a project that targets '.NETCore,Version=v4.5', but the package does not contain any assembly references that are compatible with that framework. For more information, contact the package author.

我的起订量也有同样的问题.

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应用程序的单元测试库中选择的模拟框架是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆