简体   繁体   English

如何使用Rhino创建静态类的模拟

[英]how to create mock of static class using Rhino

I am using Rhino.Mocks to mock objects for unit testing my .net application. 我正在使用Rhino.Mocks来模拟对象以对.net应用程序进行单元测试。 I want to mock a static class. 我想模拟一个静态类。 If someone has idea of how to do this, please suggest. 如果有人知道如何执行此操作,请提出建议。

Short answer : you can't. 简短答案:您不能。

You can wrap the static up in a facade object and then mock that which will probably acheive wwhat you want. 您可以将静态对象包装在Facade对象中,然后模拟可能会达到所需目的的对象。

See Mocking Static methods using Rhino.Mocks 请参阅使用Rhino.Mocks模拟静态方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM