summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Test/Messaging/MessagingTestBase.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2012-03-21 22:58:36 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2012-03-21 22:58:36 -0700
commit80028b1c5442c85909b889b3c52cfbd0c0121437 (patch)
treeb1b651c08a349957bb3d26ad5234a266d8d3e42e /src/DotNetOpenAuth.Test/Messaging/MessagingTestBase.cs
parentf02ccf1e93367b7ab8bece3a2c53e960e98d221d (diff)
parente1455ee979b150d1ea4afdf1bc82a9e5cbc5b2ba (diff)
downloadDotNetOpenAuth-80028b1c5442c85909b889b3c52cfbd0c0121437.zip
DotNetOpenAuth-80028b1c5442c85909b889b3c52cfbd0c0121437.tar.gz
DotNetOpenAuth-80028b1c5442c85909b889b3c52cfbd0c0121437.tar.bz2
Merge branch 'v4.0' into dev11
Conflicts: src/DotNetOpenAuth.sln
Diffstat (limited to 'src/DotNetOpenAuth.Test/Messaging/MessagingTestBase.cs')
-rw-r--r--src/DotNetOpenAuth.Test/Messaging/MessagingTestBase.cs27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/DotNetOpenAuth.Test/Messaging/MessagingTestBase.cs b/src/DotNetOpenAuth.Test/Messaging/MessagingTestBase.cs
index e3700b8..b7c0980 100644
--- a/src/DotNetOpenAuth.Test/Messaging/MessagingTestBase.cs
+++ b/src/DotNetOpenAuth.Test/Messaging/MessagingTestBase.cs
@@ -7,6 +7,7 @@
namespace DotNetOpenAuth.Test {
using System;
using System.Collections.Generic;
+ using System.Collections.Specialized;
using System.IO;
using System.Net;
using System.Xml;
@@ -19,6 +20,8 @@ namespace DotNetOpenAuth.Test {
/// The base class that all messaging test classes inherit from.
/// </summary>
public class MessagingTestBase : TestBase {
+ protected internal const string DefaultUrlForHttpRequestInfo = "http://localhost/path";
+
internal enum FieldFill {
/// <summary>
/// An empty dictionary is returned.
@@ -53,29 +56,19 @@ namespace DotNetOpenAuth.Test {
}
internal static HttpRequestInfo CreateHttpRequestInfo(string method, IDictionary<string, string> fields) {
- string query = MessagingUtilities.CreateQueryString(fields);
- UriBuilder requestUri = new UriBuilder("http://localhost/path");
- WebHeaderCollection headers = new WebHeaderCollection();
- MemoryStream ms = new MemoryStream();
+ var requestUri = new UriBuilder(DefaultUrlForHttpRequestInfo);
+ var headers = new NameValueCollection();
+ NameValueCollection form = null;
if (method == "POST") {
- headers.Add(HttpRequestHeader.ContentType, "application/x-www-form-urlencoded");
- StreamWriter sw = new StreamWriter(ms);
- sw.Write(query);
- sw.Flush();
- ms.Position = 0;
+ form = fields.ToNameValueCollection();
+ headers.Add(HttpRequestHeaders.ContentType, Channel.HttpFormUrlEncoded);
} else if (method == "GET") {
- requestUri.Query = query;
+ requestUri.Query = MessagingUtilities.CreateQueryString(fields);
} else {
throw new ArgumentOutOfRangeException("method", method, "Expected POST or GET");
}
- HttpRequestInfo request = new HttpRequestInfo {
- HttpMethod = method,
- UrlBeforeRewriting = requestUri.Uri,
- Headers = headers,
- InputStream = ms,
- };
- return request;
+ return new HttpRequestInfo(method, requestUri.Uri, form: form, headers: headers);
}
internal static Channel CreateChannel(MessageProtections capabilityAndRecognition) {