Beispiel #1
0
        private static void LimitFormattersToThisApplication(MvcOptions options)
        {
            options.RespectBrowserAcceptHeader = true;
            options.ReturnHttpNotAcceptable    = true;

            var customMediaType = new MediaTypeHeaderValue(ApiDefinition.ApiMediaType);

            options.SetInputMediaType(customMediaType);
            options.SetOutputMediaType(customMediaType);
        }
        public void SetInputMediaType_should_set_mediaType()
        {
            // Arrange
            var expected = new MediaTypeHeaderValue("application/vnd.test+json");

            // Act
            testSubject.SetInputMediaType(expected);

            var actual =
                testSubject.InputFormatters.OfType <JsonInputFormatter>().First().SupportedMediaTypes.First();

            // Assert
            Assert.Equal(expected.MediaType, actual);
        }