summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Test/Messaging/HttpRequestInfoTests.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2012-03-05 17:38:00 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2012-03-05 17:38:00 -0800
commit9a3885e6992462122057f532b7cbcda3695ca6bd (patch)
tree679678fe05814b95e8aaf8e3ca441c3410f1c8c5 /src/DotNetOpenAuth.Test/Messaging/HttpRequestInfoTests.cs
parenta292822196d0911a68fc56597ed52a8c84a41cbe (diff)
downloadDotNetOpenAuth-9a3885e6992462122057f532b7cbcda3695ca6bd.zip
DotNetOpenAuth-9a3885e6992462122057f532b7cbcda3695ca6bd.tar.gz
DotNetOpenAuth-9a3885e6992462122057f532b7cbcda3695ca6bd.tar.bz2
Replaced API requirements for HttpRequestInfo with HttpRequestBase (new in .NET 3.5 SP1).
This makes us more friendly to MVC as well as mock-based unit testing.
Diffstat (limited to 'src/DotNetOpenAuth.Test/Messaging/HttpRequestInfoTests.cs')
-rw-r--r--src/DotNetOpenAuth.Test/Messaging/HttpRequestInfoTests.cs39
1 files changed, 5 insertions, 34 deletions
diff --git a/src/DotNetOpenAuth.Test/Messaging/HttpRequestInfoTests.cs b/src/DotNetOpenAuth.Test/Messaging/HttpRequestInfoTests.cs
index b2f2b14..fbe1d6b 100644
--- a/src/DotNetOpenAuth.Test/Messaging/HttpRequestInfoTests.cs
+++ b/src/DotNetOpenAuth.Test/Messaging/HttpRequestInfoTests.cs
@@ -13,25 +13,6 @@ namespace DotNetOpenAuth.Test.Messaging {
[TestFixture]
public class HttpRequestInfoTests : TestBase {
- [Test]
- public void CtorDefault() {
- HttpRequestInfo info = new HttpRequestInfo();
- Assert.AreEqual("GET", info.HttpMethod);
- }
-
- [Test]
- public void CtorRequest() {
- HttpRequest request = new HttpRequest("file", "http://someserver?a=b", "a=b");
- ////request.Headers["headername"] = "headervalue"; // PlatformNotSupportedException prevents us mocking this up
- HttpRequestInfo info = new HttpRequestInfo(request);
- Assert.AreEqual(request.Headers["headername"], info.Headers["headername"]);
- Assert.AreEqual(request.Url.Query, info.Query);
- Assert.AreEqual(request.QueryString["a"], info.QueryString["a"]);
- Assert.AreEqual(request.Url, info.Url);
- Assert.AreEqual(request.Url, info.UrlBeforeRewriting);
- Assert.AreEqual(request.HttpMethod, info.HttpMethod);
- }
-
// All these tests are ineffective because ServerVariables[] cannot be set.
////[Test]
////public void CtorRequestWithDifferentPublicHttpHost() {
@@ -77,21 +58,11 @@ namespace DotNetOpenAuth.Test.Messaging {
////}
/// <summary>
- /// Checks that a property dependent on another null property
- /// doesn't generate a NullReferenceException.
- /// </summary>
- [Test]
- public void QueryBeforeSettingUrl() {
- HttpRequestInfo info = new HttpRequestInfo();
- Assert.IsNull(info.Query);
- }
-
- /// <summary>
/// Verifies that looking up a querystring variable is gracefully handled without a query in the URL.
/// </summary>
[Test]
public void QueryStringLookupWithoutQuery() {
- HttpRequestInfo info = new HttpRequestInfo();
+ var info = new HttpRequestInfo("GET", new Uri("http://somehost/somepath"));
Assert.IsNull(info.QueryString["hi"]);
}
@@ -104,7 +75,7 @@ namespace DotNetOpenAuth.Test.Messaging {
var serverVariables = new NameValueCollection();
serverVariables["HTTP_X_FORWARDED_PROTO"] = "https";
serverVariables["HTTP_HOST"] = "somehost";
- Uri actual = HttpRequestInfo.GetPublicFacingUrl(req, serverVariables);
+ Uri actual = new HttpRequestWrapper(req).GetPublicFacingUrl(serverVariables);
Uri expected = new Uri("https://somehost/a.aspx?a=b");
Assert.AreEqual(expected, actual);
}
@@ -118,7 +89,7 @@ namespace DotNetOpenAuth.Test.Messaging {
var serverVariables = new NameValueCollection();
serverVariables["HTTP_X_FORWARDED_PROTO"] = "https";
serverVariables["HTTP_HOST"] = "somehost:999";
- Uri actual = HttpRequestInfo.GetPublicFacingUrl(req, serverVariables);
+ Uri actual = new HttpRequestWrapper(req).GetPublicFacingUrl(serverVariables);
Uri expected = new Uri("https://somehost:999/a.aspx?a=b");
Assert.AreEqual(expected, actual);
}
@@ -131,7 +102,7 @@ namespace DotNetOpenAuth.Test.Messaging {
HttpRequest req = new HttpRequest("a.aspx", "http://someinternalhost/a.aspx?a=b", "a=b");
var serverVariables = new NameValueCollection();
serverVariables["HTTP_HOST"] = "somehost";
- Uri actual = HttpRequestInfo.GetPublicFacingUrl(req, serverVariables);
+ Uri actual = new HttpRequestWrapper(req).GetPublicFacingUrl(serverVariables);
Uri expected = new Uri("http://somehost/a.aspx?a=b");
Assert.AreEqual(expected, actual);
}
@@ -144,7 +115,7 @@ namespace DotNetOpenAuth.Test.Messaging {
HttpRequest req = new HttpRequest("a.aspx", "http://someinternalhost/a.aspx?a=b", "a=b");
var serverVariables = new NameValueCollection();
serverVariables["HTTP_HOST"] = "somehost:79";
- Uri actual = HttpRequestInfo.GetPublicFacingUrl(req, serverVariables);
+ Uri actual = new HttpRequestWrapper(req).GetPublicFacingUrl(serverVariables);
Uri expected = new Uri("http://somehost:79/a.aspx?a=b");
Assert.AreEqual(expected, actual);
}