Exemple #1
0
        public void StatusCode_ThrowsWhenHasStarted()
        {
            var responseInformation = new ResponseFeature();

            responseInformation.HasStarted = true;

            Assert.Throws <InvalidOperationException>(() => responseInformation.StatusCode   = 400);
            Assert.Throws <InvalidOperationException>(() => responseInformation.ReasonPhrase = "Hello World");
        }
Exemple #2
0
        public void StatusCode_MustBeGreaterThan99()
        {
            var responseInformation = new ResponseFeature();

            Assert.Throws <ArgumentOutOfRangeException>(() => responseInformation.StatusCode = 99);
            Assert.Throws <ArgumentOutOfRangeException>(() => responseInformation.StatusCode = 0);
            Assert.Throws <ArgumentOutOfRangeException>(() => responseInformation.StatusCode = -200);
            responseInformation.StatusCode = 100;
            responseInformation.StatusCode = 200;
            responseInformation.StatusCode = 1000;
        }
Exemple #3
0
        public async Task StatusCode_DefaultsTo200()
        {
            // Arrange & Act
            var responseInformation = new ResponseFeature();

            // Assert
            Assert.Equal(200, responseInformation.StatusCode);
            Assert.False(responseInformation.HasStarted);

            await responseInformation.FireOnSendingHeadersAsync();

            Assert.True(responseInformation.HasStarted);
            Assert.True(responseInformation.Headers.IsReadOnly);
        }
Exemple #4
0
        public void OnStarting_ThrowsWhenHasStarted()
        {
            // Arrange
            var responseInformation = new ResponseFeature();

            responseInformation.HasStarted = true;

            // Act & Assert
            Assert.Throws <InvalidOperationException>(() =>
            {
                responseInformation.OnStarting((status) =>
                {
                    return(Task.FromResult(string.Empty));
                }, state: "string");
            });
        }