コード例 #1
0
        public void Parameter_Constructor()
        {
            HttpResponseMessage response = new HttpResponseMessage();
            OperationResponseItem responseItem = new OperationResponseItem(response);

            Assert.Same(response, responseItem.Response);
        }
コード例 #2
0
        public void Dispose_DisposesHttpResponseMessage()
        {
            OperationResponseItem responseItem = new OperationResponseItem(new MockHttpResponseMessage());

            responseItem.Dispose();

            Assert.True(((MockHttpResponseMessage)responseItem.Response).IsDisposed);
        }
コード例 #3
0
        public void WriteResponseAsync_NullWriter_Throws()
        {
            OperationResponseItem responseItem = new OperationResponseItem(new HttpResponseMessage());

            Assert.ThrowsArgumentNull(
                () => responseItem.WriteResponseAsync(null, CancellationToken.None).Wait(),
                "writer");
        }
コード例 #4
0
        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());
        }
コード例 #5
0
        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);
        }