How to write an unit test for WCF behaviors?

Posted by katie77 on Stack Overflow See other posts from Stack Overflow or by katie77
Published on 2012-07-03T03:12:24Z Indexed on 2012/07/03 3:15 UTC
Read the original article Hit count: 104

Filed under:
|
|

I am new to unit testing. How do I write a unit test for a method when I am extending a WCF behavior. Since I am not sure of when the class is being instantiated, or I can not change the method signature. In the behavior implementation, I am getting the header and looking up a value in the config.

public class IncomingValidator : IDispatchMessageInspector
{

    public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
    {
            // Grab the header and see if one of the particular values(read from config) is there. 
    }

    public void BeforeSendReply(ref Message reply, object correlationState)
    {
    }
}

© Stack Overflow or respective owner

Related posts about wcf

Related posts about unit-testing