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); }
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); }