diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2008-11-18 07:33:29 -0800 |
---|---|---|
committer | Andrew <andrewarnott@gmail.com> | 2008-11-18 07:33:29 -0800 |
commit | 587c9b421f3f0b3607662050c1b1546f203cc8f9 (patch) | |
tree | 896aa100bd0fdc00f9f7891cc53d8192247d85f1 /src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs | |
parent | 6c26c72a01e8ae62474f78e1d44b849c673f8e4e (diff) | |
download | DotNetOpenAuth-587c9b421f3f0b3607662050c1b1546f203cc8f9.zip DotNetOpenAuth-587c9b421f3f0b3607662050c1b1546f203cc8f9.tar.gz DotNetOpenAuth-587c9b421f3f0b3607662050c1b1546f203cc8f9.tar.bz2 |
Moved association creation logic from test assembly to library.
Diffstat (limited to 'src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs')
-rw-r--r-- | src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs b/src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs index bba9285..bb094af 100644 --- a/src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs +++ b/src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs @@ -17,12 +17,16 @@ namespace DotNetOpenAuth.Test.Mocks { private EventWaitHandle incomingMessageSignal = new AutoResetEvent(false); private IProtocolMessage incomingMessage; private Response incomingRawResponse; + private Action<IProtocolMessage> incomingMessageFilter; + private Action<IProtocolMessage> outgoingMessageFilter; - internal CoordinatingChannel(Channel wrappedChannel) + internal CoordinatingChannel(Channel wrappedChannel, Action<IProtocolMessage> incomingMessageFilter, Action<IProtocolMessage> outgoingMessageFilter) : base(GetMessageTypeProvider(wrappedChannel), wrappedChannel.BindingElements.ToArray()) { ErrorUtilities.VerifyArgumentNotNull(wrappedChannel, "wrappedChannel"); this.wrappedChannel = wrappedChannel; + this.incomingMessageFilter = incomingMessageFilter; + this.outgoingMessageFilter = outgoingMessageFilter; } /// <summary> @@ -35,26 +39,32 @@ namespace DotNetOpenAuth.Test.Mocks { } protected override IProtocolMessage RequestInternal(IDirectedProtocolMessage request) { + this.ProcessMessageFilter(request, true); HttpRequestInfo requestInfo = this.SpoofHttpMethod(request); // Drop the outgoing message in the other channel's in-slot and let them know it's there. this.RemoteChannel.incomingMessage = requestInfo.Message; this.RemoteChannel.incomingMessageSignal.Set(); // Now wait for a response... - return this.AwaitIncomingMessage(); + IProtocolMessage response = this.AwaitIncomingMessage(); + this.ProcessMessageFilter(response, false); + return response; } protected override Response SendDirectMessageResponse(IProtocolMessage response) { + this.ProcessMessageFilter(response, true); this.RemoteChannel.incomingMessage = CloneSerializedParts(response, null); this.RemoteChannel.incomingMessageSignal.Set(); return null; } protected override Response SendIndirectMessage(IDirectedProtocolMessage message) { + this.ProcessMessageFilter(message, true); // In this mock transport, direct and indirect messages are the same. return this.SendDirectMessageResponse(message); } protected override IDirectedProtocolMessage ReadFromRequestInternal(HttpRequestInfo request) { + this.ProcessMessageFilter(request.Message, false); return request.Message; } @@ -104,5 +114,17 @@ namespace DotNetOpenAuth.Test.Mocks { this.incomingMessage = null; return response; } + + private void ProcessMessageFilter(IProtocolMessage message, bool outgoing) { + if (outgoing) { + if (this.outgoingMessageFilter != null) { + this.outgoingMessageFilter(message); + } + } else { + if (this.incomingMessageFilter != null) { + this.incomingMessageFilter(message); + } + } + } } } |