我一直在用 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
这篇关于模拟不是接口的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!