コード例 #1
0
        public async Task WriteAsync_WritesTheStatusCode204()
        {
            // Arrange
            var context = new OutputFormatterWriteContext(
                new DefaultHttpContext(),
                new TestHttpResponseStreamWriterFactory().CreateWriter,
                typeof(string),
                @object: null);

            var formatter = new HttpNoContentOutputFormatter();

            // Act
            await formatter.WriteAsync(context);

            // Assert
            Assert.Equal(StatusCodes.Status204NoContent, context.HttpContext.Response.StatusCode);
        }
コード例 #2
0
        public async Task WriteAsync_ContextStatusCodeSet_WritesSameStatusCode()
        {
            // Arrange
            var httpContext = new DefaultHttpContext();

            httpContext.Response.StatusCode = StatusCodes.Status201Created;

            var context = new OutputFormatterWriteContext(
                httpContext,
                new TestHttpResponseStreamWriterFactory().CreateWriter,
                typeof(string),
                @object: null);

            var formatter = new HttpNoContentOutputFormatter();

            // Act
            await formatter.WriteAsync(context);

            // Assert
            Assert.Equal(StatusCodes.Status201Created, httpContext.Response.StatusCode);
        }
コード例 #3
0
        public async Task WriteAsync_ContextStatusCodeSet_WritesSameStatusCode()
        {
            // Arrange
            var httpContext = new DefaultHttpContext();
            httpContext.Response.StatusCode = StatusCodes.Status201Created;

            var context = new OutputFormatterWriteContext(
                httpContext,
                new TestHttpResponseStreamWriterFactory().CreateWriter,
                typeof(string),
                @object: null);

            var formatter = new HttpNoContentOutputFormatter();

            // Act
            await formatter.WriteAsync(context);

            // Assert
            Assert.Equal(StatusCodes.Status201Created, httpContext.Response.StatusCode);
        }
コード例 #4
0
        public async Task WriteAsync_WritesTheStatusCode204()
        {
            // Arrange
            var context = new OutputFormatterWriteContext(
                new DefaultHttpContext(),
                new TestHttpResponseStreamWriterFactory().CreateWriter,
                typeof(string),
                @object: null);

            var formatter = new HttpNoContentOutputFormatter();

            // Act
            await formatter.WriteAsync(context);

            // Assert
            Assert.Equal(StatusCodes.Status204NoContent, context.HttpContext.Response.StatusCode);
        }