本文介绍了Windows Phone 7 模拟框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有适用于 Windows Phone 7 的模拟框架,或者我是否需要手动创建假货?

Are there any mocking frameworks for Windows Phone 7 or do I need to create fakes manually?

我在 google 上没有找到任何东西,虽然我发现 WP7 资源页面上列出了 Moq,但我无法让它工作.

I've not found any on google, and although I found Moq listed on WP7 resources page, I couldn't get it working.

推荐答案

没有支持 WP7 的 Mocking 框架,我怀疑在 WP7 支持 Reflection.Emit 之前永远不会有任何 Mocking 框架.

There are no Mocking frameworks that support WP7 and I suspect there will never be any until WP7 supports Reflection.Emit.

.net 框架上有 许多选项 可用于创建模拟框架(Profiler API、CodeDem、Refleciton.Emit 等).大多数这些技术不适用于 Silverlight 本身,因为它缺少很多 BCL/CLR.所有现有的 Silverlight 模拟框架都使用 Reflection.Emit.WP7 不支持 Reflection.Emit,因此没有 Silverlight 模拟框架将在 WP7 上工作.

On the .net framework there are many options that exist for the creation of a mocking framework (Profiler API, CodeDem, Refleciton.Emit, et al). The majority of these techniques won't work on Silverlight itself as it's missing quite a lot of the BCL/CLR. All existing Silverlight mocking frameworks use Reflection.Emit. WP7 does not support Reflection.Emit and thus no Silverlight mocking framework will work on WP7.

由于这个原因,我个人在 Silverlight 运行时测试了 WP7 程序集.这远非最佳(很糟糕),但它是在这种情况下可以做到的最好的.

Because of that reason, I personally test WP7 assemblies on the Silverlight runtime. It's far from optimal (it sucks), but it's the best that can be done under the circumstances.

理论上可以构建一个使用后构建 MSIL 编织的 Mocking 框架,该框架应该适用于 WP7,但尚未完成.

One could theoretically build a Mocking framework that uses Post-Build MSIL weaving that should work on WP7, but it's yet to be done.

如果您希望 WP7 支持 Reflection.Emit,请考虑对此用户语音问题进行投票:WP7 应该支持 Reflection.Emit for Mocking 框架

If you'd like WP7 to support Reflection.Emit consider voting on this uservoice issue: WP7 should support Reflection.Emit for Mocking frameworks

编辑 2/12/2011: Mango 支持 Refleciton.Emit.万岁!基于 Reflection.Emit 的 Mocking 框架应该可以正常工作.

EDIT 2/12/2011: Refleciton.Emit is supported on Mango. Hooray! Reflection.Emit based Mocking frameworks should just work.

这篇关于Windows Phone 7 模拟框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-01 06:39