summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Test/Messaging
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.Test/Messaging')
-rw-r--r--src/DotNetOpenAuth.Test/Messaging/HttpRequestInfoTests.cs45
-rw-r--r--src/DotNetOpenAuth.Test/Messaging/MessagingTestBase.cs2
-rw-r--r--src/DotNetOpenAuth.Test/Messaging/Reflection/MessageDictionaryTests.cs15
-rw-r--r--src/DotNetOpenAuth.Test/Messaging/Reflection/MessagePartTests.cs2
4 files changed, 59 insertions, 5 deletions
diff --git a/src/DotNetOpenAuth.Test/Messaging/HttpRequestInfoTests.cs b/src/DotNetOpenAuth.Test/Messaging/HttpRequestInfoTests.cs
index dd59bae..05ac306 100644
--- a/src/DotNetOpenAuth.Test/Messaging/HttpRequestInfoTests.cs
+++ b/src/DotNetOpenAuth.Test/Messaging/HttpRequestInfoTests.cs
@@ -26,9 +26,54 @@ namespace DotNetOpenAuth.Test.Messaging {
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.
+ ////[TestMethod]
+ ////public void CtorRequestWithDifferentPublicHttpHost() {
+ //// HttpRequest request = new HttpRequest("file", "http://someserver?a=b", "a=b");
+ //// request.ServerVariables["HTTP_HOST"] = "publichost";
+ //// HttpRequestInfo info = new HttpRequestInfo(request);
+ //// Assert.AreEqual("publichost", info.UrlBeforeRewriting.Host);
+ //// Assert.AreEqual(80, info.UrlBeforeRewriting.Port);
+ //// Assert.AreEqual(request.Url.Query, info.Query);
+ //// Assert.AreEqual(request.QueryString["a"], info.QueryString["a"]);
+ ////}
+
+ ////[TestMethod]
+ ////public void CtorRequestWithDifferentPublicHttpsHost() {
+ //// HttpRequest request = new HttpRequest("file", "https://someserver?a=b", "a=b");
+ //// request.ServerVariables["HTTP_HOST"] = "publichost";
+ //// HttpRequestInfo info = new HttpRequestInfo(request);
+ //// Assert.AreEqual("publichost", info.UrlBeforeRewriting.Host);
+ //// Assert.AreEqual(443, info.UrlBeforeRewriting.Port);
+ //// Assert.AreEqual(request.Url.Query, info.Query);
+ //// Assert.AreEqual(request.QueryString["a"], info.QueryString["a"]);
+ ////}
+
+ ////[TestMethod]
+ ////public void CtorRequestWithDifferentPublicHostNonstandardPort() {
+ //// HttpRequest request = new HttpRequest("file", "http://someserver?a=b", "a=b");
+ //// request.ServerVariables["HTTP_HOST"] = "publichost:550";
+ //// HttpRequestInfo info = new HttpRequestInfo(request);
+ //// Assert.AreEqual("publichost", info.UrlBeforeRewriting.Host);
+ //// Assert.AreEqual(550, info.UrlBeforeRewriting.Port);
+ //// Assert.AreEqual(request.Url.Query, info.Query);
+ //// Assert.AreEqual(request.QueryString["a"], info.QueryString["a"]);
+ ////}
+
+ ////[TestMethod]
+ ////public void CtorRequestWithDifferentPublicIPv6Host() {
+ //// HttpRequest request = new HttpRequest("file", "http://[fe80::587e:c6e5:d3aa:657a]:8089/v3.1/", "");
+ //// request.ServerVariables["HTTP_HOST"] = "[fe80::587e:c6e5:d3aa:657b]:8089";
+ //// HttpRequestInfo info = new HttpRequestInfo(request);
+ //// Assert.AreEqual("[fe80::587e:c6e5:d3aa:657b]", info.UrlBeforeRewriting.Host);
+ //// Assert.AreEqual(8089, info.UrlBeforeRewriting.Port);
+ //// Assert.AreEqual(request.Url.Query, info.Query);
+ ////}
+
/// <summary>
/// Checks that a property dependent on another null property
/// doesn't generate a NullReferenceException.
diff --git a/src/DotNetOpenAuth.Test/Messaging/MessagingTestBase.cs b/src/DotNetOpenAuth.Test/Messaging/MessagingTestBase.cs
index 0a11a75..accb182 100644
--- a/src/DotNetOpenAuth.Test/Messaging/MessagingTestBase.cs
+++ b/src/DotNetOpenAuth.Test/Messaging/MessagingTestBase.cs
@@ -70,7 +70,7 @@ namespace DotNetOpenAuth.Test {
}
HttpRequestInfo request = new HttpRequestInfo {
HttpMethod = method,
- Url = requestUri.Uri,
+ UrlBeforeRewriting = requestUri.Uri,
Headers = headers,
InputStream = ms,
};
diff --git a/src/DotNetOpenAuth.Test/Messaging/Reflection/MessageDictionaryTests.cs b/src/DotNetOpenAuth.Test/Messaging/Reflection/MessageDictionaryTests.cs
index 7083b1e..24171e1 100644
--- a/src/DotNetOpenAuth.Test/Messaging/Reflection/MessageDictionaryTests.cs
+++ b/src/DotNetOpenAuth.Test/Messaging/Reflection/MessageDictionaryTests.cs
@@ -331,17 +331,26 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
/// A test for System.Collections.Generic.ICollection&lt;System.Collections.Generic.KeyValuePair&lt;System.String,System.String&lt;&lt;.Clear
/// </summary>
[TestMethod]
- public void Clear() {
- ICollection<KeyValuePair<string, string>> target = this.MessageDescriptions.GetAccessor(this.message);
+ public void ClearValues() {
+ MessageDictionary target = this.MessageDescriptions.GetAccessor(this.message);
IDictionary<string, string> targetAsDictionary = ((IDictionary<string, string>)target);
this.message.Name = "Andrew";
this.message.Age = 15;
targetAsDictionary["extra"] = "value";
- target.Clear();
+ target.ClearValues();
Assert.AreEqual(2, target.Count, "Clearing should remove all keys except for declared non-nullable structs.");
Assert.IsFalse(targetAsDictionary.ContainsKey("extra"));
Assert.IsNull(this.message.Name);
Assert.AreEqual(0, this.message.Age);
}
+
+ /// <summary>
+ /// Verifies that the Clear method throws the expected exception.
+ /// </summary>
+ [TestMethod, ExpectedException(typeof(NotSupportedException))]
+ public void Clear() {
+ MessageDictionary target = this.MessageDescriptions.GetAccessor(this.message);
+ target.Clear();
+ }
}
}
diff --git a/src/DotNetOpenAuth.Test/Messaging/Reflection/MessagePartTests.cs b/src/DotNetOpenAuth.Test/Messaging/Reflection/MessagePartTests.cs
index 0215801..19e6a82 100644
--- a/src/DotNetOpenAuth.Test/Messaging/Reflection/MessagePartTests.cs
+++ b/src/DotNetOpenAuth.Test/Messaging/Reflection/MessagePartTests.cs
@@ -82,7 +82,7 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
Assert.AreEqual("abc", part.GetValue(message));
}
- [TestMethod, ExpectedException(typeof(ArgumentException))]
+ [TestMethod, ExpectedException(typeof(ProtocolException))]
public void ConstantFieldMemberInvalidValues() {
var message = new MessageWithConstantField();
MessagePart part = GetMessagePart(message.GetType(), "ConstantField");