Merge pull request #2020 from tomjepp/master
[mono.git] / mcs / class / System.Net.Http / Test / System.Net.Http / StreamContentTest.cs
index c19e88ccbadda5aa52d46725460dd858f8dafe51..e56094741263210f94b21d56a8bb6093ffb410ff 100644 (file)
@@ -36,6 +36,7 @@ using System.IO;
 using System.Threading.Tasks;
 using System.Net;
 using System.Linq;
+using System.Text;
 
 namespace MonoTests.System.Net.Http
 {
@@ -160,7 +161,7 @@ namespace MonoTests.System.Net.Http
                 * The .NET runtime hits the "#9" assertion.
                 * The test succeeds with Mono.
                 */
-               [Category ("NotWorking")]
+               [Category ("NotDotNet")]
                public void CopyToAsync ()
                {
                        var ms = new MemoryStream ();
@@ -222,6 +223,7 @@ namespace MonoTests.System.Net.Http
                        Assert.AreEqual (330, scm.Headers.ContentLength, "#2");
 
                        headers.Allow.Add ("a1");
+                       headers.ContentDisposition = new ContentDispositionHeaderValue ("cd1");
                        headers.ContentEncoding.Add ("ce1");
                        headers.ContentLanguage.Add ("cl1");
                        headers.ContentLength = 23;
@@ -234,6 +236,12 @@ namespace MonoTests.System.Net.Http
 
 
                        headers.Add ("allow", "a2");
+                       try {
+                               headers.Add ("content-disposition", "cd2");
+                               Assert.Fail ("content-disposition");
+                       } catch (FormatException) {
+                       }
+
                        headers.Add ("content-encoding", "ce3");
                        headers.Add ("content-language", "cl2");
 
@@ -307,6 +315,7 @@ namespace MonoTests.System.Net.Http
                        Assert.AreEqual (new MediaTypeHeaderValue ("multipart/*"), headers.ContentType);
                        Assert.AreEqual (new DateTimeOffset (DateTime.Today), headers.Expires);
                        Assert.AreEqual (new DateTimeOffset (DateTime.Today), headers.LastModified);
+                       Assert.AreEqual (new ContentDispositionHeaderValue ("cd1"), headers.ContentDisposition);
                }
 
                [Test]
@@ -319,6 +328,15 @@ namespace MonoTests.System.Net.Http
                        Assert.AreEqual ("Content-MD5: AwU=\r\n", headers.ToString (), "#1");
                }
 
+               [Test]
+               public void Headers_ContentLength ()
+               {
+                       var content = new StreamContent (new MemoryStream (Encoding.UTF8.GetBytes ("test")));
+                       Assert.AreEqual ("", content.Headers.ToString ());
+                       var length = content.Headers.ContentLength;
+                       Assert.AreEqual ("Content-Length: 4\r\n", content.Headers.ToString ());
+               }
+
                [Test]
                public void Headers_Invalid ()
                {