public void ReadAsHttpResponseMessageAsync_IncompleteResponse(string incompleteResponse) { StringContent content = new StringContent(incompleteResponse); content.Headers.ContentType = ParserData.HttpResponseMediaType; Assert.Throws <IOException>(() => content.ReadAsHttpResponseMessageAsync().Result); }
public Task ReadAsHttpResponseMessageAsync_IncompleteResponse(string incompleteResponse) { StringContent content = new StringContent(incompleteResponse); content.Headers.ContentType = ParserData.HttpResponseMediaType; return(Assert.ThrowsAsync <IOException>(() => content.ReadAsHttpResponseMessageAsync())); }
public void ReadAsHttpResponseMessageAsync_VerifyArguments() { Assert.ThrowsArgumentNull( () => HttpContentMessageExtensions.ReadAsHttpResponseMessageAsync(null), "content" ); Assert.ThrowsArgument( () => new ByteArrayContent(new byte[] { }).ReadAsHttpResponseMessageAsync(), "content" ); Assert.ThrowsArgument( () => new StringContent(String.Empty).ReadAsHttpResponseMessageAsync(), "content" ); Assert.ThrowsArgument( () => new StringContent( String.Empty, Encoding.UTF8, "application/http" ).ReadAsHttpResponseMessageAsync(), "content" ); Assert.ThrowsArgument( () => { HttpContent content = new StringContent(String.Empty); content.Headers.ContentType = ParserData.HttpRequestMediaType; content.ReadAsHttpResponseMessageAsync(); }, "content" ); Assert.ThrowsArgumentGreaterThanOrEqualTo( () => { HttpContent content = new StringContent(String.Empty); content.Headers.ContentType = ParserData.HttpResponseMediaType; content.ReadAsHttpResponseMessageAsync(ParserData.MinBufferSize - 1); }, "bufferSize", ParserData.MinBufferSize.ToString(), ParserData.MinBufferSize - 1 ); }
public void ReadAsHttpResponseMessageAsync_VerifyArguments() { Assert.ThrowsArgumentNull(() => HttpContentMessageExtensions.ReadAsHttpResponseMessageAsync(null), "content"); Assert.ThrowsArgument(() => new ByteArrayContent(new byte[] { }).ReadAsHttpResponseMessageAsync(), "content"); Assert.ThrowsArgument(() => new StringContent(String.Empty).ReadAsHttpResponseMessageAsync(), "content"); Assert.ThrowsArgument(() => new StringContent(String.Empty, Encoding.UTF8, "application/http").ReadAsHttpResponseMessageAsync(), "content"); Assert.ThrowsArgument(() => { HttpContent content = new StringContent(String.Empty); content.Headers.ContentType = ParserData.HttpRequestMediaType; content.ReadAsHttpResponseMessageAsync(); }, "content"); Assert.ThrowsArgumentGreaterThanOrEqualTo(() => { HttpContent content = new StringContent(String.Empty); content.Headers.ContentType = ParserData.HttpResponseMediaType; content.ReadAsHttpResponseMessageAsync(ParserData.MinBufferSize - 1); }, "bufferSize", ParserData.MinBufferSize.ToString(), ParserData.MinBufferSize - 1); }
public void ReadAsHttpResponseMessageAsync_IncompleteResponse(string incompleteResponse) { StringContent content = new StringContent(incompleteResponse); content.Headers.ContentType = ParserData.HttpResponseMediaType; Assert.Throws<IOException>(() => content.ReadAsHttpResponseMessageAsync().Result); }