Assert.IsTrue (hit, "#10");
}
+ [Test]
+ public void CopyToAsync_ClosedInput ()
+ {
+ var stream = new MemoryStream (new byte[] { 1 });
+ var content = new StreamContent (stream);
+ Assert.IsTrue (content.LoadIntoBufferAsync ().Wait (3000), "#1");
+ stream.Close ();
+
+ var stream_out = new MemoryStream (10);
+ Assert.IsTrue (content.CopyToAsync (stream_out).Wait (3000), "#2");
+ }
+
[Test]
public void Headers ()
{
}
}
+ [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 ()
{
Assert.IsTrue (sc.LoadIntoBufferAsync (50).Wait (200));
Assert.Fail ("#1");
} catch (AggregateException e) {
- Assert.IsInstanceOfType (typeof (HttpRequestException), e.InnerException, "#2");
+ Assert.IsTrue (e.InnerException is HttpRequestException, "#2");
}
}
var res = sc.ReadAsStreamAsync ().Result;
Assert.AreEqual (77, res.ReadByte (), "#1");
}
+
+ [Test]
+ public void ReadAsStreamAsync_ClosedInput ()
+ {
+ var stream = new MemoryStream (new byte[] { 1 });
+ var content = new StreamContent (stream);
+ Assert.IsTrue (content.LoadIntoBufferAsync ().Wait (3000), "#1");
+ stream.Close ();
+
+ var stream_read = content.ReadAsStreamAsync ().Result;
+ Assert.IsTrue (stream_read.CanSeek, "#2");
+ Assert.AreEqual (0, stream_read.Position, "#3");
+ Assert.AreEqual (1, stream_read.Length, "#4");
+ }
}
}