本文介绍了模拟不是接口的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!
问题描述
我一直在用 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
这篇关于模拟不是接口的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!
The End


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)