Ejemplo n.º 1
0
        public async Task WriteAsync_Sets406NotAcceptable()
        {
            // Arrange
            var formatter = new HttpNotAcceptableOutputFormatter();

            var context = new OutputFormatterWriteContext(
                new DefaultHttpContext(),
                new TestHttpResponseStreamWriterFactory().CreateWriter,
                objectType: null,
                @object: null);

            // Act
            await formatter.WriteAsync(context);

            // Assert
            Assert.Equal(StatusCodes.Status406NotAcceptable, context.HttpContext.Response.StatusCode);
        }
Ejemplo n.º 2
0
        public void CanWriteResult_ReturnsTrue_WhenConnegHasFailed()
        {
            // Arrange
            var formatter = new HttpNotAcceptableOutputFormatter();

            var context = new OutputFormatterWriteContext(
                new DefaultHttpContext(),
                new TestHttpResponseStreamWriterFactory().CreateWriter,
                objectType: null,
                @object: null)
            {
                FailedContentNegotiation = true,
            };

            // Act
            var result = formatter.CanWriteResult(context);

            // Assert
            Assert.True(result);
        }