public static void RegisterProvider(FilterProviderCollection providerCollection) { var filterProvider = FluentMvcConfiguration .ConfigureFilterProvider(x => { x.WithResultFactory <ActionResultFactory>() .WithResultFactory <JsonResultFactory>() .WithResultFactory <ViewResultFactory>(isDefault: true); x.WithResultFactory <ErrorThrowingResultFactory>( Apply.For <HomeController>(hc => hc.ErrorResultFactory())); x.WithFilter <HandleErrorAttribute>(); x.WithFilter <AuthorizeAttribute>( Except .For <AccountController>(ac => ac.LogOn()) .AndFor <AccountController>( ac => ac.LogOn(null, null, false, null)) .AndFor <HomeController>()); x.WithFilter <ErrorThrowingFilter>( Apply.When <ExpectsHtml>().For <HomeController>(hc => hc.About())); }); providerCollection.Insert(0, filterProvider); }
public override void Given() { Expression <Func <TestController, object> > func = c => c.ReturnPost(); Expression <Func <SecondTestController, object> > func2 = c => c.ReturnPost(); actionDescriptor = func.CreateActionDescriptor(); anotherActionDescriptor = func2.CreateActionDescriptor(); actionFilterRegistry = new ActionFilterRegistry(CreateStub <IFluentMvcObjectFactory>()); Configuration = FluentMvcConfiguration.Create(CreateStub <IFluentMvcResolver>(), actionFilterRegistry, CreateStub <IActionResultRegistry>(), CreateStub <IFilterConventionCollection>()) .WithFilter <TestActionFilter>(Except.For <TestController>()); }
public override void Given() { actionFilterRegistry = new ActionFilterRegistry(CreateStub <IFluentMvcObjectFactory>()); Expression <Func <TestController, object> > func = controller => controller.ReturnPost(); Expression <Func <TestController, object> > otherFunc = controller => controller.ReturnViewResult(); actionDescriptor = func.CreateActionDescriptor(); incorrectActionDescriptor = otherFunc.CreateActionDescriptor(); Configuration = FluentMvcConfiguration.Create(CreateStub <IFluentMvcResolver>(), actionFilterRegistry, CreateStub <IActionResultRegistry>(), CreateStub <IFilterConventionCollection>()) .WithFilter <TestActionFilter>(Except.For <SecondTestController>().AndFor <TestController>(func).AndFor <TestController>(t => t.ReturnNull())); registryTester = new ActionFilterRegistryTester(actionFilterRegistry); }
public override void Given() { Expression <Func <TestController, object> > func = c => c.ReturnPost(); Expression <Func <SecondTestController, object> > func2 = c => c.ReturnPost(); Expression <Func <ThirdTestController, object> > func3 = c => c.ReturnPost(); actionDescriptor = func.CreateActionDescriptor(); secondActionDescriptor = func2.CreateActionDescriptor(); excludedActionDescriptor = func3.CreateActionDescriptor(); fluentMvcObjectFactory = CreateStub <IFluentMvcObjectFactory>(); fluentMvcObjectFactory.Stub(x => x.Resolve <object>(Arg <Type> .Is.Anything)).Return(CreateStub <IActionFilter>()); actionFilterRegistry = new ActionFilterRegistry(fluentMvcObjectFactory); Configuration = FluentMvcConfiguration.Create(CreateStub <IFluentMvcResolver>(), actionFilterRegistry, CreateStub <IActionResultRegistry>(), CreateStub <IFilterConventionCollection>()) .WithFilter <AcceptVerbsAttribute>() .WithFilter <AuthorizeAttribute>(Except.For <TestController>().AndFor(func3)); resolver = new ActionFilterResolver(actionFilterRegistry, fluentMvcObjectFactory); }
public override void Because() { actionFilter = new TestActionFilter(); objectFactory = CreateStub <IFluentMvcObjectFactory>(); objectFactory.Stub(of => of.Resolve <IActionFilter>(Arg <Type> .Is.Anything)) .Return(actionFilter).Repeat.Any(); actionFilterRegistry = new ActionFilterRegistry(objectFactory); func = c => c.ReturnPost(); var config = FluentMvcConfiguration.Create(CreateStub <IFluentMvcResolver>(), actionFilterRegistry, CreateStub <IActionResultRegistry>(), CreateStub <IFilterConventionCollection>()); config.ExposeConfiguration(x => { x.WithFilter <TestActionFilter>(Except.For <ThirdTestController>()); x.WithFilter <TestActionFilter>(Apply.For <TestController>().AndFor <SecondTestController>()); }); config.BuildFilterProvider(); }