diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-05-21 17:47:39 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2009-05-21 17:47:39 -0700 |
commit | 683b55a61af3c7bfa11b74a5cc4efd3556e59613 (patch) | |
tree | 33b9b40e83c8932a33de8803ec56a7272458d2e3 /src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs | |
parent | c5c8515e67903baf00ba63417ac6124f665ea38b (diff) | |
parent | 510723cc2773ad3f1e306001310d7a8b28e89d1a (diff) | |
download | DotNetOpenAuth-683b55a61af3c7bfa11b74a5cc4efd3556e59613.zip DotNetOpenAuth-683b55a61af3c7bfa11b74a5cc4efd3556e59613.tar.gz DotNetOpenAuth-683b55a61af3c7bfa11b74a5cc4efd3556e59613.tar.bz2 |
Merge branch 'v3.0' into v3.1
Diffstat (limited to 'src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs')
-rw-r--r-- | src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs b/src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs index e654f02..3bbe6e3 100644 --- a/src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs +++ b/src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs @@ -45,6 +45,12 @@ namespace DotNetOpenAuth.Test.Mocks { private EventWaitHandle incomingMessageSignal = new AutoResetEvent(false); /// <summary> + /// A thread-coordinating signal that is set briefly by this thread whenever + /// a message is picked up. + /// </summary> + private EventWaitHandle messageReceivedSignal = new AutoResetEvent(false); + + /// <summary> /// A flag used to indicate when this channel is waiting for a message /// to arrive. /// </summary> @@ -126,6 +132,12 @@ namespace DotNetOpenAuth.Test.Mocks { /// </summary> /// <param name="message">The message that this channel should receive. This message will be cloned.</param> internal void PostMessage(IProtocolMessage message) { + if (this.incomingMessage != null) { + // The remote party hasn't picked up the last message we sent them. + // Wait for a short period for them to pick it up before failing. + TestBase.TestLogger.Warn("We're blocked waiting to send a message to the remote party and they haven't processed the last message we sent them."); + this.RemoteChannel.messageReceivedSignal.WaitOne(500); + } ErrorUtilities.VerifyInternal(this.incomingMessage == null, "Oops, a message is already waiting for the remote party!"); this.incomingMessage = this.MessageDescriptions.GetAccessor(message).Serialize(); var directedMessage = message as IDirectedProtocolMessage; @@ -273,6 +285,11 @@ namespace DotNetOpenAuth.Test.Mocks { recipient = this.incomingMessageRecipient; this.incomingMessage = null; this.incomingMessageRecipient = null; + + // Briefly signal to another thread that might be waiting for our inbox to be empty + this.messageReceivedSignal.Set(); + this.messageReceivedSignal.Reset(); + return response; } } |