summaryrefslogtreecommitdiff
path: root/mcs/class/System.Net.Http/Test
diff options
context:
space:
mode:
authorJo Shields <directhex@apebox.org>2014-02-19 22:12:43 +0000
committerJo Shields <directhex@apebox.org>2014-02-19 22:12:43 +0000
commit9972bf87b4f27d9c8f358ef8414ac1ab957a2f0f (patch)
tree5bb230c1d698659115f918e243c1d4b0aa4c7f51 /mcs/class/System.Net.Http/Test
parentd0a215f5626219ff7927f576588a777e5331c7be (diff)
downloadmono-upstream/3.2.8+dfsg.tar.gz
Imported Upstream version 3.2.8+dfsgupstream/3.2.8+dfsg
Diffstat (limited to 'mcs/class/System.Net.Http/Test')
-rw-r--r--mcs/class/System.Net.Http/Test/System.Net.Http.Headers/HttpHeadersTest.cs8
-rw-r--r--mcs/class/System.Net.Http/Test/System.Net.Http.Headers/NameValueHeaderValueTest.cs3
-rw-r--r--mcs/class/System.Net.Http/Test/System.Net.Http/HttpRequestMessageTest.cs47
-rw-r--r--mcs/class/System.Net.Http/Test/System.Net.Http/HttpResponseMessageTest.cs50
-rw-r--r--mcs/class/System.Net.Http/Test/System.Net.Http/StreamContentTest.cs15
5 files changed, 120 insertions, 3 deletions
diff --git a/mcs/class/System.Net.Http/Test/System.Net.Http.Headers/HttpHeadersTest.cs b/mcs/class/System.Net.Http/Test/System.Net.Http.Headers/HttpHeadersTest.cs
index a4b2555160..cae4a65c82 100644
--- a/mcs/class/System.Net.Http/Test/System.Net.Http.Headers/HttpHeadersTest.cs
+++ b/mcs/class/System.Net.Http/Test/System.Net.Http.Headers/HttpHeadersTest.cs
@@ -131,6 +131,14 @@ namespace MonoTests.System.Net.Http.Headers
}
[Test]
+ public void TryGetValuesTest ()
+ {
+ IEnumerable<string> headerValues;
+ Assert.IsFalse (headers.TryGetValues (null, out headerValues), "#1");
+ Assert.IsFalse (headers.TryGetValues ("some-name", out headerValues), "#2");
+ }
+
+ [Test]
public void ToStringTest ()
{
headers.Add ("aa", "v");
diff --git a/mcs/class/System.Net.Http/Test/System.Net.Http.Headers/NameValueHeaderValueTest.cs b/mcs/class/System.Net.Http/Test/System.Net.Http.Headers/NameValueHeaderValueTest.cs
index 7d08832868..32cf785a0e 100644
--- a/mcs/class/System.Net.Http/Test/System.Net.Http.Headers/NameValueHeaderValueTest.cs
+++ b/mcs/class/System.Net.Http/Test/System.Net.Http.Headers/NameValueHeaderValueTest.cs
@@ -157,6 +157,9 @@ namespace MonoTests.System.Net.Http.Headers
NameValueHeaderValue res;
Assert.IsFalse (NameValueHeaderValue.TryParse ("", out res), "#1");
Assert.IsNull (res, "#2");
+
+ Assert.IsFalse (NameValueHeaderValue.TryParse ("\"a\"=b", out res), "#3");
+ Assert.IsNull (res, "#4");
}
}
}
diff --git a/mcs/class/System.Net.Http/Test/System.Net.Http/HttpRequestMessageTest.cs b/mcs/class/System.Net.Http/Test/System.Net.Http/HttpRequestMessageTest.cs
index b852fdc05f..79ae114f65 100644
--- a/mcs/class/System.Net.Http/Test/System.Net.Http/HttpRequestMessageTest.cs
+++ b/mcs/class/System.Net.Http/Test/System.Net.Http/HttpRequestMessageTest.cs
@@ -35,6 +35,7 @@ using System.Net.Http;
using System.Net;
using System.Net.Http.Headers;
using System.Linq;
+using System.IO;
namespace MonoTests.System.Net.Http
{
@@ -361,15 +362,55 @@ namespace MonoTests.System.Net.Http
}
[Test]
- public void Headers_Complex ()
+ public void Headers_MultiValues ()
{
HttpRequestMessage message = new HttpRequestMessage ();
HttpRequestHeaders headers = message.Headers;
+ headers.Add ("Accept", "application/vnd.citrix.requesttokenresponse+xml, application/vnd.citrix.requesttokenchoices+xml");
+ headers.Add ("Accept-Charset", "aa ;Q=0,bb;Q=1");
+ headers.Add ("Expect", "x=1; v, y=5");
+ headers.Add ("If-Match", "\"a\",*, \"b\",*");
headers.Add ("user-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.62 Safari/537.36");
+ Assert.AreEqual (2, headers.Accept.Count, "#1a");
+ Assert.IsTrue (headers.Accept.SequenceEqual (
+ new[] {
+ new MediaTypeWithQualityHeaderValue ("application/vnd.citrix.requesttokenresponse+xml"),
+ new MediaTypeWithQualityHeaderValue ("application/vnd.citrix.requesttokenchoices+xml"),
+ }
+ ), "#1b");
- Assert.AreEqual (6, headers.UserAgent.Count);
+ Assert.AreEqual (2, headers.AcceptCharset.Count, "#2a");
+ Assert.IsTrue (headers.AcceptCharset.SequenceEqual (
+ new[] {
+ new StringWithQualityHeaderValue ("aa", 0),
+ new StringWithQualityHeaderValue ("bb", 1),
+ }
+ ), "#2b");
+
+ Assert.AreEqual (2, headers.Expect.Count, "#3a");
+ var expect_expected = new[] {
+ new NameValueWithParametersHeaderValue ("x", "1") {
+ },
+ new NameValueWithParametersHeaderValue ("y", "5"),
+ };
+ expect_expected [0].Parameters.Add (new NameValueHeaderValue ("v"));
+ Assert.IsTrue (headers.Expect.SequenceEqual (
+ expect_expected
+ ), "#3b");
+
+ Assert.AreEqual (4, headers.IfMatch.Count, "#4a");
+ Assert.IsTrue (headers.IfMatch.SequenceEqual (
+ new[] {
+ new EntityTagHeaderValue ("\"a\""),
+ EntityTagHeaderValue.Any,
+ new EntityTagHeaderValue ("\"b\""),
+ EntityTagHeaderValue.Any
+ }
+ ), "#4b");
+
+ Assert.AreEqual (6, headers.UserAgent.Count, "#10a");
Assert.IsTrue (headers.UserAgent.SequenceEqual (
new[] {
@@ -380,7 +421,7 @@ namespace MonoTests.System.Net.Http
new ProductInfoHeaderValue ("Chrome", "29.0.1547.62"),
new ProductInfoHeaderValue ("Safari", "537.36")
}
- ));
+ ), "#10b");
}
[Test]
diff --git a/mcs/class/System.Net.Http/Test/System.Net.Http/HttpResponseMessageTest.cs b/mcs/class/System.Net.Http/Test/System.Net.Http/HttpResponseMessageTest.cs
index b92b3e644d..b13e8cae41 100644
--- a/mcs/class/System.Net.Http/Test/System.Net.Http/HttpResponseMessageTest.cs
+++ b/mcs/class/System.Net.Http/Test/System.Net.Http/HttpResponseMessageTest.cs
@@ -295,6 +295,56 @@ namespace MonoTests.System.Net.Http
}
[Test]
+ public void Headers_MultiValues ()
+ {
+ var message = new HttpResponseMessage ();
+ var headers = message.Headers;
+
+ headers.Add ("Proxy-Authenticate", "x, y, z,i");
+ headers.Add ("Upgrade", "HTTP/2.0, SHTTP/1.3, IRC, RTA/x11");
+ headers.Add ("Via", "1.0 fred, 1.1 nowhere.com (Apache/1.1)");
+ headers.Add ("Warning", "199 Miscellaneous \"w\", 200 a \"b\"");
+
+ Assert.AreEqual (4, headers.ProxyAuthenticate.Count, "#1a");
+ Assert.IsTrue (headers.ProxyAuthenticate.SequenceEqual (
+ new[] {
+ new AuthenticationHeaderValue ("x"),
+
+ new AuthenticationHeaderValue ("y"),
+ new AuthenticationHeaderValue ("z"),
+ new AuthenticationHeaderValue ("i")
+ }
+ ), "#1b");
+
+
+ Assert.AreEqual (4, headers.Upgrade.Count, "#2a");
+ Assert.IsTrue (headers.Upgrade.SequenceEqual (
+ new[] {
+ new ProductHeaderValue ("HTTP", "2.0"),
+ new ProductHeaderValue ("SHTTP", "1.3"),
+ new ProductHeaderValue ("IRC"),
+ new ProductHeaderValue ("RTA", "x11")
+ }
+ ), "#2b");
+
+ Assert.AreEqual (2, headers.Via.Count, "#3a");
+ Assert.IsTrue (headers.Via.SequenceEqual (
+ new[] {
+ new ViaHeaderValue ("1.0", "fred"),
+ new ViaHeaderValue ("1.1", "nowhere.com", null, "(Apache/1.1)")
+ }
+ ), "#2b");
+
+ Assert.AreEqual (2, headers.Warning.Count, "#4a");
+ Assert.IsTrue (headers.Warning.SequenceEqual (
+ new[] {
+ new WarningHeaderValue (199, "Miscellaneous", "\"w\""),
+ new WarningHeaderValue (200, "a", "\"b\"")
+ }
+ ), "#4b");
+ }
+
+ [Test]
public void Header_BaseImplementation ()
{
HttpResponseMessage message = new HttpResponseMessage ();
diff --git a/mcs/class/System.Net.Http/Test/System.Net.Http/StreamContentTest.cs b/mcs/class/System.Net.Http/Test/System.Net.Http/StreamContentTest.cs
index edd4b839c1..413e459526 100644
--- a/mcs/class/System.Net.Http/Test/System.Net.Http/StreamContentTest.cs
+++ b/mcs/class/System.Net.Http/Test/System.Net.Http/StreamContentTest.cs
@@ -309,6 +309,21 @@ namespace MonoTests.System.Net.Http
}
[Test]
+ public void Headers_Multi ()
+ {
+ var sc = new StreamContent (MemoryStream.Null);
+ var headers = sc.Headers;
+
+ headers.Add ("Allow", "");
+ headers.Add ("Allow", "a , b, c");
+
+ Assert.AreEqual (3, headers.Allow.Count, "#1a");
+ Assert.IsTrue (headers.Allow.SequenceEqual (
+ new[] { "a", "b", "c" }
+ ), "#1b");
+ }
+
+ [Test]
public void LoadIntoBuffer ()
{
var ms = new MemoryStream ();