public void Parameter_Constructor() { HttpResponseMessage response = new HttpResponseMessage(); OperationResponseItem responseItem = new OperationResponseItem(response); Assert.Same(response, responseItem.Response); }
public void Dispose_DisposesHttpResponseMessage() { OperationResponseItem responseItem = new OperationResponseItem(new MockHttpResponseMessage()); responseItem.Dispose(); Assert.True(((MockHttpResponseMessage)responseItem.Response).IsDisposed); }
public void WriteResponseAsync_NullWriter_Throws() { OperationResponseItem responseItem = new OperationResponseItem(new HttpResponseMessage()); Assert.ThrowsArgumentNull( () => responseItem.WriteResponseAsync(null, CancellationToken.None).Wait(), "writer"); }
public void IsResponseSucess_TestResponse() { // Arrange OperationResponseItem successResponseItem = new OperationResponseItem(new HttpResponseMessage(HttpStatusCode.OK)); OperationResponseItem errorResponseItem = new OperationResponseItem(new HttpResponseMessage(HttpStatusCode.Ambiguous)); // Act & Assert Assert.True(successResponseItem.IsResponseSuccessful()); Assert.False(errorResponseItem.IsResponseSuccessful()); }
public void WriteResponseAsync_WritesOperation() { OperationResponseItem responseItem = new OperationResponseItem(new HttpResponseMessage(HttpStatusCode.Accepted)); MemoryStream memoryStream = new MemoryStream(); IODataResponseMessage responseMessage = new ODataMessageWrapper(memoryStream); ODataMessageWriter writer = new ODataMessageWriter(responseMessage); ODataBatchWriter batchWriter = writer.CreateODataBatchWriter(); batchWriter.WriteStartBatch(); responseItem.WriteResponseAsync(batchWriter, CancellationToken.None).Wait(); batchWriter.WriteEndBatch(); memoryStream.Position = 0; string responseString = new StreamReader(memoryStream).ReadToEnd(); Assert.Contains("Accepted", responseString); }