惩戒不属于接口的类 [英] Mocking classes that aren't interfaces

查看:143
本文介绍了惩戒不属于接口的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写在C#中一些供应商来自的ProviderBase类继承。我发现它很难编写使用供应商测试,最嘲讽的框架,将只允许你嘲笑的接口。

I've been writing some providers in c# that inherit from the providerbase class. I've found that it's hard to write tests that use the providers as most mocking frameworks will only allow you to mock an interface.

有没有什么办法来嘲弄呼叫该自ProviderBase继承的提供者?

Is there any way to mock a call to a provider that inherits from providerbase?

如果不是,那里,我可以用它来实现供应商的嘲弄模式?

If not, is there a pattern that I can use to implement mocking of providers?

推荐答案

嘲讽框架应该能够为你创建一个模拟对象。基于一类,只要它有虚拟成员

Mocking frameworks should be able to create for you a mock object based on a class, as long as it's got virtual members.

您可能还需要看一看的 Typemock

You may also want to take a look at Typemock

这篇关于惩戒不属于接口的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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