public void AddsOutputFormatter()
        {
            // Arrange
            var optionsSetup = new XmlDataContractSerializerMvcOptionsSetup(NullLoggerFactory.Instance);
            var options      = new MvcOptions();

            // Act
            optionsSetup.Configure(options);

            // Assert
            Assert.IsType <XmlDataContractSerializerOutputFormatter>(Assert.Single(options.OutputFormatters));
        }
        public void AddsFormatterMapping()
        {
            // Arrange
            var optionsSetup = new XmlDataContractSerializerMvcOptionsSetup(NullLoggerFactory.Instance);
            var options      = new MvcOptions();

            // Act
            optionsSetup.Configure(options);

            // Assert
            var mappedContentType = options.FormatterMappings.GetMediaTypeMappingForFormat("xml");

            Assert.Equal("application/xml", mappedContentType);
        }
Beispiel #3
0
        public void DoesNotOverrideExistingMapping()
        {
            // Arrange
            var optionsSetup = new XmlDataContractSerializerMvcOptionsSetup(Options.Options.Create(new MvcXmlOptions()), NullLoggerFactory.Instance);
            var options      = new MvcOptions();

            options.FormatterMappings.SetMediaTypeMappingForFormat("xml", "text/xml");

            // Act
            optionsSetup.Configure(options);

            // Assert
            var mappedContentType = options.FormatterMappings.GetMediaTypeMappingForFormat("xml");

            Assert.Equal("text/xml", mappedContentType);
        }