public void CreateControllerModel_DisableCorsAttributeAddsDisableCorsAuthorizationFilter() { // Arrange var corsProvider = new CorsApplicationModelProvider(); var defaultProvider = new DefaultApplicationModelProvider(new TestOptionsManager<MvcOptions>()); var context = new ApplicationModelProviderContext(new[] { typeof(DisableCorsController).GetTypeInfo() }); defaultProvider.OnProvidersExecuting(context); // Act corsProvider.OnProvidersExecuting(context); // Assert var model = Assert.Single(context.Result.Controllers); Assert.Single(model.Filters, f => f is DisableCorsAuthorizationFilter); }
public void BuildActionModel_EnableCorsAttributeAddsCorsAuthorizationFilterFactory() { // Arrange var corsProvider = new CorsApplicationModelProvider(); var defaultProvider = new DefaultApplicationModelProvider(new TestOptionsManager<MvcOptions>()); var context = new ApplicationModelProviderContext(new[] { typeof(EnableCorsController).GetTypeInfo() }); defaultProvider.OnProvidersExecuting(context); // Act corsProvider.OnProvidersExecuting(context); // Assert var controller = Assert.Single(context.Result.Controllers); var action = Assert.Single(controller.Actions); Assert.Single(action.Filters, f => f is CorsAuthorizationFilterFactory); }
public void CreateControllerModel_DisableCorsAttributeAddsDisableCorsAuthorizationFilter() { // Arrange var corsProvider = new CorsApplicationModelProvider(); var defaultProvider = new DefaultApplicationModelProvider(new TestOptionsManager <MvcOptions>()); var context = new ApplicationModelProviderContext(new[] { typeof(DisableCorsController).GetTypeInfo() }); defaultProvider.OnProvidersExecuting(context); // Act corsProvider.OnProvidersExecuting(context); // Assert var model = Assert.Single(context.Result.Controllers); Assert.Single(model.Filters, f => f is DisableCorsAuthorizationFilter); }
public void BuildActionModel_EnableCorsAttributeAddsCorsAuthorizationFilterFactory() { // Arrange var corsProvider = new CorsApplicationModelProvider(); var defaultProvider = new DefaultApplicationModelProvider(new TestOptionsManager <MvcOptions>()); var context = new ApplicationModelProviderContext(new[] { typeof(EnableCorsController).GetTypeInfo() }); defaultProvider.OnProvidersExecuting(context); // Act corsProvider.OnProvidersExecuting(context); // Assert var controller = Assert.Single(context.Result.Controllers); var action = Assert.Single(controller.Actions); Assert.Single(action.Filters, f => f is CorsAuthorizationFilterFactory); }