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 serialized to JSON as normal, but if we get an unhandled exception, we serialize based on a different object.
We need unit tests around this but I cannot figure out how to write them. The means to validate that it worked revolves around the StatusCode, the fault Message instance, and the ContentType of the response.
To modify the Response going back, I utilize the WebOperationContext static class. I have seen examples of mocking this, but it seems like I have to hard code special logic that would then begin to percolate into the actual code, which I don't want.
What are some of the best ways to unit test a WCF behavior extension?