public Task ConvertResponse_DisposesRequestAndResponseWithContent() { // Arrange Mock <HttpContextBase> contextMock = new Mock <HttpContextBase>() { DefaultValue = DefaultValue.Mock }; contextMock.SetupGet((hcb) => hcb.Response.OutputStream).Returns(Stream.Null); HttpRequestMessage request = new HttpRequestMessage() { Content = new StringContent("request") }; HttpResponseMessage response = new HttpResponseMessage() { Content = new StringContent("response") }; // Act return(HttpControllerHandler.ConvertResponse(contextMock.Object, response, request).ContinueWith( _ => { // Assert Assert.ThrowsObjectDisposed(() => request.Method = HttpMethod.Get, typeof(HttpRequestMessage).FullName); Assert.ThrowsObjectDisposed(() => response.StatusCode = HttpStatusCode.OK, typeof(HttpResponseMessage).FullName); })); }
public void DisposeInnerHttpResponseMessage() { HttpResponseMessage response = CreateResponse(false); HttpMessageContent instance = new HttpMessageContent(response); instance.Dispose(); Assert.ThrowsObjectDisposed(() => { response.StatusCode = HttpStatusCode.OK; }, typeof(HttpResponseMessage).FullName); }
public void DisposeInnerHttpRequestMessage() { HttpRequestMessage request = CreateRequest(ParserData.HttpRequestUri, false); HttpMessageContent instance = new HttpMessageContent(request); instance.Dispose(); Assert.ThrowsObjectDisposed(() => { request.Method = HttpMethod.Get; }, typeof(HttpRequestMessage).FullName); }