diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2008-09-29 23:16:41 -0700 |
---|---|---|
committer | Andrew <andrewarnott@gmail.com> | 2008-10-02 07:33:55 -0700 |
commit | 5cbd5d7edb994f874b265ed2e7c43f0bcd27b6ac (patch) | |
tree | a7b11de02bc213b279906aaa4aafc7d15ff09bac /src/DotNetOAuth.Test | |
parent | 55c86fc27084af191bbb80fb91da34c24b945c3e (diff) | |
download | DotNetOpenAuth-5cbd5d7edb994f874b265ed2e7c43f0bcd27b6ac.zip DotNetOpenAuth-5cbd5d7edb994f874b265ed2e7c43f0bcd27b6ac.tar.gz DotNetOpenAuth-5cbd5d7edb994f874b265ed2e7c43f0bcd27b6ac.tar.bz2 |
Removed the queue/dequeue methodology of queued responses. Now the methods that generate them return them.
Besides simplifying the API somewhat, this change allows for Consumer, ServiceProvider and Channel classes to be entirely threadsafe and reusable.
Diffstat (limited to 'src/DotNetOAuth.Test')
5 files changed, 9 insertions, 34 deletions
diff --git a/src/DotNetOAuth.Test/ChannelElements/OAuthChannelTests.cs b/src/DotNetOAuth.Test/ChannelElements/OAuthChannelTests.cs index 38ca5f1..790a0d4 100644 --- a/src/DotNetOAuth.Test/ChannelElements/OAuthChannelTests.cs +++ b/src/DotNetOAuth.Test/ChannelElements/OAuthChannelTests.cs @@ -78,9 +78,8 @@ namespace DotNetOAuth.Test.ChannelElements { Name = "Andrew",
Location = new Uri("http://hostb/pathB"),
};
- this.channel.Send(message);
- Response response = this.channel.DequeueIndirectOrResponseMessage();
+ Response response = this.channel.Send(message);
Assert.AreSame(message, response.OriginalMessage);
Assert.AreEqual(HttpStatusCode.OK, response.Status);
Assert.AreEqual(0, response.Headers.Count);
diff --git a/src/DotNetOAuth.Test/Messaging/ChannelTests.cs b/src/DotNetOAuth.Test/Messaging/ChannelTests.cs index e9dd6ea..9caa10d 100644 --- a/src/DotNetOAuth.Test/Messaging/ChannelTests.cs +++ b/src/DotNetOAuth.Test/Messaging/ChannelTests.cs @@ -25,11 +25,6 @@ namespace DotNetOAuth.Test.Messaging { }
[TestMethod]
- public void DequeueIndirectOrResponseMessageReturnsNull() {
- Assert.IsNull(this.Channel.DequeueIndirectOrResponseMessage());
- }
-
- [TestMethod]
public void ReadFromRequestQueryString() {
this.ParameterizedReceiveTest("GET");
}
@@ -69,8 +64,7 @@ namespace DotNetOAuth.Test.Messaging { message.Recipient = new Uri("http://provider/path");
var expected = GetStandardTestFields(FieldFill.CompleteBeforeBindings);
- this.Channel.Send(message);
- Response response = this.Channel.DequeueIndirectOrResponseMessage();
+ Response response = this.Channel.Send(message);
Assert.AreEqual(HttpStatusCode.Redirect, response.Status);
StringAssert.StartsWith(response.Headers[HttpResponseHeader.Location], "http://provider/path");
foreach (var pair in expected) {
@@ -113,8 +107,7 @@ namespace DotNetOAuth.Test.Messaging { Location = new Uri("http://host/path"),
Recipient = new Uri("http://provider/path"),
};
- this.Channel.Send(message);
- Response response = this.Channel.DequeueIndirectOrResponseMessage();
+ Response response = this.Channel.Send(message);
Assert.AreEqual(HttpStatusCode.OK, response.Status, "A form redirect should be an HTTP successful response.");
Assert.IsNull(response.Headers[HttpResponseHeader.Location], "There should not be a redirection header in the response.");
string body = response.Body;
@@ -166,20 +159,6 @@ namespace DotNetOAuth.Test.Messaging { }
[TestMethod, ExpectedException(typeof(ArgumentNullException))]
- public void QueueIndirectOrResponseMessageNull() {
- TestBadChannel badChannel = new TestBadChannel(false);
- badChannel.QueueIndirectOrResponseMessage(null);
- }
-
- [TestMethod, ExpectedException(typeof(InvalidOperationException))]
- public void QueueIndirectOrResponseMessageTwice() {
- TestBadChannel badChannel = new TestBadChannel(false);
- Response response = new Response();
- badChannel.QueueIndirectOrResponseMessage(new Response());
- badChannel.QueueIndirectOrResponseMessage(new Response());
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
public void SendIndirectMessageNull() {
TestBadChannel badChannel = new TestBadChannel(false);
badChannel.SendIndirectMessage(null);
diff --git a/src/DotNetOAuth.Test/Mocks/TestBadChannel.cs b/src/DotNetOAuth.Test/Mocks/TestBadChannel.cs index 5b59ba1..781d65b 100644 --- a/src/DotNetOAuth.Test/Mocks/TestBadChannel.cs +++ b/src/DotNetOAuth.Test/Mocks/TestBadChannel.cs @@ -27,10 +27,6 @@ namespace DotNetOAuth.Test.Mocks { base.CreateFormPostResponse(message, fields);
}
- internal new void QueueIndirectOrResponseMessage(Response response) {
- base.QueueIndirectOrResponseMessage(response);
- }
-
internal new void SendIndirectMessage(IDirectedProtocolMessage message) {
base.SendIndirectMessage(message);
}
@@ -51,7 +47,7 @@ namespace DotNetOAuth.Test.Mocks { throw new NotImplementedException();
}
- protected override void SendDirectMessageResponse(IProtocolMessage response) {
+ protected override Response SendDirectMessageResponse(IProtocolMessage response) {
throw new NotImplementedException();
}
}
diff --git a/src/DotNetOAuth.Test/Mocks/TestChannel.cs b/src/DotNetOAuth.Test/Mocks/TestChannel.cs index b69b756..1f75e3f 100644 --- a/src/DotNetOAuth.Test/Mocks/TestChannel.cs +++ b/src/DotNetOAuth.Test/Mocks/TestChannel.cs @@ -28,7 +28,7 @@ namespace DotNetOAuth.Test.Mocks { throw new NotImplementedException("ReadFromResponse");
}
- protected override void SendDirectMessageResponse(IProtocolMessage response) {
+ protected override Response SendDirectMessageResponse(IProtocolMessage response) {
throw new NotImplementedException("SendDirectMessageResponse");
}
}
diff --git a/src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs b/src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs index 67f5ad6..5b74342 100644 --- a/src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs +++ b/src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs @@ -68,17 +68,18 @@ namespace DotNetOAuth.Test.Scenarios { return this.AwaitIncomingMessage();
}
- protected override void SendDirectMessageResponse(IProtocolMessage response) {
+ protected override Response SendDirectMessageResponse(IProtocolMessage response) {
TestBase.TestLogger.InfoFormat("Sending response: {0}", response);
this.RemoteChannel.incomingMessage = CloneSerializedParts(response, null);
this.CopyDirectionalParts(response, this.RemoteChannel.incomingMessage);
this.RemoteChannel.incomingMessageSignal.Set();
+ return null;
}
- protected override void SendIndirectMessage(IDirectedProtocolMessage message) {
+ protected override Response SendIndirectMessage(IDirectedProtocolMessage message) {
TestBase.TestLogger.Info("Next response is an indirect message...");
// In this mock transport, direct and indirect messages are the same.
- this.SendDirectMessageResponse(message);
+ return this.SendDirectMessageResponse(message);
}
protected override HttpRequestInfo GetRequestFromContext() {
|