Unit Testing a WCF Behavior Extension

后端 未结 1 1547
执念已碎
执念已碎 2021-01-06 07:08

This is driving me crazy. I have an extension which we use to alter the Content Response of a request if there is an error. Basically, if everything works it gets serialize

相关标签:
1条回答
  • 2021-01-06 07:59

    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.

    0 讨论(0)
提交回复
热议问题