Unit Testing a WCF Behavior Extension

流过昼夜 提交于 2019-11-30 22:40:43

I had a similar situation, and was unable to mock WCF (at least using Moq), mainly because most classes are either sealed or had internal constructors.

What I did was to have my behavior just apply an IParameterInspector and an IClientMessageInspector (in my case I needed both) and put all my logic in either the AfterCall or BeforeCall, or whichever one you need, depending on the inspector type.

That way I could test all the logic I cared about. The actual WCF Behavior remained untested, but all it really did was just add the two inspectors and nothing else.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!