예제 #1
0
		public void LoadIntoBuffer_BufferOverflow ()
		{
			var ms = new MemoryStream ();
			ms.Write (new byte[10000], 0, 10000);
			ms.Seek (0, SeekOrigin.Begin);

			var sc = new StreamContent (ms);
			try {
				Assert.IsTrue (sc.LoadIntoBufferAsync (50).Wait (200));
				Assert.Fail ("#1");
			} catch (AggregateException e) {
				Assert.IsInstanceOfType (typeof (HttpRequestException), e.InnerException, "#2");
			}
		}
예제 #2
0
		public void LoadIntoBuffer ()
		{
			var ms = new MemoryStream ();
			ms.WriteByte (4);
			ms.Seek (0, SeekOrigin.Begin);

			var sc = new StreamContent (ms);
			Assert.IsTrue (sc.LoadIntoBufferAsync (400).Wait (200));
		}
예제 #3
0
		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");
		}
예제 #4
0
		public void ContentLengthAfterLoad ()
		{
			var sc = new StreamContent (new CannotSeekStream ());
			Assert.IsTrue (sc.LoadIntoBufferAsync ().Wait (3000), "#1");
			Assert.AreEqual (11, sc.Headers.ContentLength, "#2");
		}
예제 #5
0
		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");
		}