public void SendBody_HeadRequest_Void()
        {
            //Arrange
            var httpResponse = MockRepository.GenerateMock<HttpResponseBase>();
            var httpResponseHeaderHelper = MockRepository.GenerateMock<IHttpResponseHeaderHelper>();
            var transmitEntityStrategy = MockRepository.GenerateMock<ITransmitEntityStrategy>();
            var requestHttpMethod = HttpMethod.Head;

            var startRange = 0l;
            var endRange = 499l;
            var rangeItem = new RangeItem
            {
                StartRange = startRange,
                EndRange = endRange
            };

            var bytesToRead = endRange - startRange + 1;

            //Act
            var singleByteRangeResponse = new EntityResponseSinglePart(httpResponseHeaderHelper, rangeItem);
            singleByteRangeResponse.SendBody(requestHttpMethod, httpResponse, transmitEntityStrategy);

            //Assert
            transmitEntityStrategy.AssertWasNotCalled(x => x.Transmit(httpResponse, startRange, bytesToRead));
        }
Пример #2
0
        public void SendBody_HeadRequest_Void()
        {
            //Arrange
            var httpResponse             = MockRepository.GenerateMock <HttpResponseBase>();
            var httpResponseHeaderHelper = MockRepository.GenerateMock <IHttpResponseHeaderHelper>();
            var transmitEntityStrategy   = MockRepository.GenerateMock <ITransmitEntityStrategy>();
            var requestHttpMethod        = HttpMethod.Head;

            var startRange = 0L;
            var endRange   = 499L;
            var rangeItem  = new RangeItem
            {
                StartRange = startRange,
                EndRange   = endRange
            };

            var bytesToRead = endRange - startRange + 1;

            //Act
            var singleByteRangeResponse = new EntityResponseSinglePart(httpResponseHeaderHelper, rangeItem);

            singleByteRangeResponse.SendBody(requestHttpMethod, httpResponse, transmitEntityStrategy);

            //Assert
            transmitEntityStrategy.AssertWasNotCalled(x => x.Transmit(httpResponse, startRange, bytesToRead));
        }
Пример #3
0
        public void SendBody_NotAHeadOrGetRequest_Void()
        {
            //Arrange
            var httpResponse             = MockRepository.GenerateMock <HttpResponseBase>();
            var httpResponseHeaderHelper = MockRepository.GenerateMock <IHttpResponseHeaderHelper>();
            var transmitEntityStrategy   = MockRepository.GenerateMock <ITransmitEntityStrategy>();
            var requestHttpMethod        = HttpMethod.Options;

            var startRange = 0L;
            var endRange   = 499L;
            var rangeItem  = new RangeItem
            {
                StartRange = startRange,
                EndRange   = endRange
            };

            var bytesToRead = endRange - startRange + 1;

            //Act
            var singleByteRangeResponse = new EntityResponseSinglePart(httpResponseHeaderHelper, rangeItem);
            var ex = Assert.Throws <Exception>(() => singleByteRangeResponse.SendBody(requestHttpMethod, httpResponse, transmitEntityStrategy));
        }
        public void SendBody_NotAHeadOrGetRequest_Void()
        {
            //Arrange
            var httpResponse = MockRepository.GenerateMock<HttpResponseBase>();
            var httpResponseHeaderHelper = MockRepository.GenerateMock<IHttpResponseHeaderHelper>();
            var transmitEntityStrategy = MockRepository.GenerateMock<ITransmitEntityStrategy>();
            var requestHttpMethod = HttpMethod.Options;

            var startRange = 0l;
            var endRange = 499l;
            var rangeItem = new RangeItem
            {
                StartRange = startRange,
                EndRange = endRange
            };

            var bytesToRead = endRange - startRange + 1;

            //Act
            var singleByteRangeResponse = new EntityResponseSinglePart(httpResponseHeaderHelper, rangeItem);
            var ex = Assert.Throws<Exception>(() => singleByteRangeResponse.SendBody(requestHttpMethod, httpResponse, transmitEntityStrategy));
        }