Exemplo n.º 1
0
        public void DisableBuffering_IfRequestIsNull_Throws()
        {
            // Arrange
            IOwinRequest request = null;

            // Act & Assert
            Assert.ThrowsArgumentNull(() => OwinRequestExtensions.DisableBuffering(request), "request");
        }
Exemplo n.º 2
0
        public void GetContentLength_IfHeadersDoesNotContainContentLengthHeader_ReturnsNull()
        {
            // Arrange
            IHeaderDictionary headers = CreateStubHeaders();
            IOwinRequest      request = CreateStubRequest(headers);

            // Act
            int?length = OwinRequestExtensions.GetContentLength(request);

            // Assert
            Assert.False(length.HasValue);
        }
Exemplo n.º 3
0
        public void GetContentLength_IfContentLengthHeaderIsNegative_ReturnsNull()
        {
            // Arrange
            IHeaderDictionary headers = CreateStubHeaders("Content-Length", new string[] { "-1" });
            IOwinRequest      request = CreateStubRequest(headers);

            // Act
            int?length = OwinRequestExtensions.GetContentLength(request);

            // Assert
            Assert.False(length.HasValue);
        }
Exemplo n.º 4
0
        public void GetContentLength_IfHeadersIsNull_ReturnsNull()
        {
            // Arrange
            IOwinRequest request = CreateStubRequest(headers: null);

            Assert.Null(request.Headers); // Guard

            // Act
            int?length = OwinRequestExtensions.GetContentLength(request);

            // Assert
            Assert.False(length.HasValue);
        }
Exemplo n.º 5
0
        public void DisableBuffering_IfActionIsAvailable_CallsAction()
        {
            // Arrange
            bool   bufferingDisabled                 = false;
            Action disableBufferingAction            = () => bufferingDisabled = true;
            IDictionary <string, object> environment = CreateStubEnvironment(disableBufferingAction);
            IOwinRequest request = CreateStubRequest(environment);

            // Act
            OwinRequestExtensions.DisableBuffering(request);

            // Assert
            Assert.True(bufferingDisabled);
        }