public void FormatFilter_IsActive( string format, FormatSource place, bool expected) { // Arrange var mockObjects = new MockObjects(format, place); var resultExecutingContext = mockObjects.CreateResultExecutingContext(); var filterAttribute = new FormatFilterAttribute(); var filter = new FormatFilter(mockObjects.IOptions, mockObjects.ScopedInstance); // Act and Assert Assert.Equal(expected, filter.IsActive); }
// Set up application services public void ConfigureServices(IServiceCollection services) { services.AddMvc(options => { var formatFilter = new FormatFilterAttribute(); options.Filters.Add(formatFilter); var customFormatter = new CustomFormatter("application/custom"); options.OutputFormatters.Add(customFormatter); options.FormatterMappings.SetMediaTypeMappingForFormat( "custom", MediaTypeHeaderValue.Parse("application/custom")); }); }
// Set up application services public void ConfigureServices(IServiceCollection services) { var mvcBuilder = services.AddMvc(options => { var formatFilter = new FormatFilterAttribute(); options.Filters.Add(formatFilter); var customFormatter = new CustomFormatter("application/custom"); options.OutputFormatters.Add(customFormatter); options.OutputFormatters.RemoveType<StringOutputFormatter>(); options.FormatterMappings.SetMediaTypeMappingForFormat( "custom", MediaTypeHeaderValue.Parse("application/custom")); }); mvcBuilder.AddXmlDataContractSerializerFormatters(); }
public void FormatFilter_IsActive( string format, FormatSource place, bool expected) { // Arrange var mockObjects = new MockObjects(format, place); var resultExecutingContext = mockObjects.CreateResultExecutingContext(); var filterAttribute = new FormatFilterAttribute(); var filter = new FormatFilter(mockObjects.IOptions, mockObjects.ScopedInstance); // Act and Assert Assert.Equal(expected, filter.IsActive); }