开发者

Trying to Mock the Microsoft Exchange Web Service

I'm trying to test my application, which is using the Microsoft Exchange Web Service dll to access an Exchange Server.

I want to isolate my application from a need for an actual Exchange Server in my tests, and i realized i cannot mock the Exchange DLL...

Another problem, is that i cannot change the operational code, which does not use an interface or an adapter to access the Exchange Web Service DLL, therefore i cannot simply stub it开发者_开发百科...

In my research i found the Microsoft Moles framework, which allows me to Mole and replace any method (even constructors) with my own delegate. However, i found that in the application code, we're using internal Microsoft data types (for example EmailMessage) that do not allow much freedom of how to create them or change them.

Does anybody have any suggestions as to what i can do in such a situation?

Thanks.


If i where you i would try to hide exchange behind an email service facade and replace all code that is directly referenceing exchange with calls to that facade.

Mockin the facade is much easier than mocking exchange itself.

As a sideeffect if customer decides to use some other email system you just have to reimplement the facade instead of changing the whole application.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜