Example #1
0
 public void Securing_a_specific_action()
 {
     FluentMvcConfiguration.Create()
     .WithConvention(new MvcConvention())
     .WithFilter <AuthorizeAttribute>(Apply.For <TestController>(tc => tc.ReturnPost()))
     .BuildFilterProvider();
 }
Example #2
0
 public override void Because()
 {
     actionFilterRegistry = new ActionFilterRegistry(CreateStub <IFluentMvcObjectFactory>());
     filterInstance       = CreateStub <IActionFilter>();
     FluentMvcConfiguration.Create(CreateStub <IFluentMvcResolver>(), actionFilterRegistry, CreateStub <IActionResultRegistry>(), CreateStub <IFilterConventionCollection>())
     .WithFilter(filterInstance).BuildFilterProvider();
 }
 public override void Given()
 {
     objectFactory        = CreateStub <IFluentMvcObjectFactory>();
     actionFilterRegistry = CreateStub <IActionFilterRegistry>();
     Configuration        = FluentMvcConfiguration.Create(CreateStub <IFluentMvcResolver>(), actionFilterRegistry, CreateStub <IActionResultRegistry>(), CreateStub <IFilterConventionCollection>())
                            .ResolveWith(objectFactory)
                            .WithResultFactory <JsonResultFactory>();
 }
        public override void Given()
        {
            Expression <Func <TestController, object> > func = c => c.ReturnPost();

            actionDescriptor     = func.CreateActionDescriptor();
            actionFilterRegistry = new ActionFilterRegistry(CreateStub <IFluentMvcObjectFactory>());
            Configuration        = FluentMvcConfiguration.Create(CreateStub <IFluentMvcResolver>(), actionFilterRegistry, CreateStub <IActionResultRegistry>(), CreateStub <IFilterConventionCollection>())
                                   .WithFilter <TestActionFilter>();
        }
Example #5
0
            public override void Given()
            {
                Expression <Func <ControllerWithOverloadedActions, object> > registeredAction = c => c.OverloadedAction(default(Model));

                actionFilterRegistry = new ActionFilterRegistry(CreateStub <IFluentMvcObjectFactory>());

                FluentMvcConfiguration.Create(CreateStub <IFluentMvcResolver>(), actionFilterRegistry, CreateStub <IActionResultRegistry>(), CreateStub <IFilterConventionCollection>())
                .WithFilter <TestActionFilter>(Apply.For(registeredAction))
                .BuildFilterProvider();
            }
Example #6
0
        public override void Given()
        {
            fluentMvcResolver          = CreateStub <IFluentMvcResolver>();
            actionFilterRegistry       = CreateStub <IActionFilterRegistry>();
            actionResultRegistry       = CreateStub <IActionResultRegistry>();
            filterConventionCollection = CreateStub <IFilterConventionCollection>();

            Configuration = FluentMvcConfiguration
                            .Create(fluentMvcResolver, actionFilterRegistry, actionResultRegistry, filterConventionCollection);
        }
        public override void Given()
        {
            actionFilterRegistry = new ActionFilterRegistry(CreateStub <IFluentMvcObjectFactory>());
            Expression <Func <SecondTestController, object> > func          = controller => controller.ReturnPost();
            Expression <Func <TestController, object> >       exceptForFunc = controller => controller.ReturnViewResult();

            actionDescriptor          = func.CreateActionDescriptor();
            exceptforActionDescriptor = exceptForFunc.CreateActionDescriptor();
            Configuration             = FluentMvcConfiguration.Create(CreateStub <IFluentMvcResolver>(), actionFilterRegistry, CreateStub <IActionResultRegistry>(), CreateStub <IFilterConventionCollection>())
                                        .WithFilter <TestActionFilter>(Apply.For <SecondTestController>().ExceptFor(exceptForFunc));
        }
        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();
            thirdActionDescriptor  = func3.CreateActionDescriptor();
            actionFilterRegistry   = new ActionFilterRegistry(CreateStub <IFluentMvcObjectFactory>());
            Configuration          = FluentMvcConfiguration.Create(CreateStub <IFluentMvcResolver>(), actionFilterRegistry, CreateStub <IActionResultRegistry>(), CreateStub <IFilterConventionCollection>())
                                     .WithFilter <AuthorizeAttribute>(Except.For <TestController>().AndFor <ThirdTestController>());
        }
Example #10
0
            public override void Given()
            {
                actionFilterRegistry = new ActionFilterRegistry(CreateStub <IFluentMvcObjectFactory>());
                Expression <Func <TestController, object> > func      = controller => controller.ReturnNull();
                Expression <Func <TestController, object> > otherFunc = controller => controller.ReturnNull(null);

                var proxyGenerator           = new ProxyGenerator();
                var interfaceProxyWithTarget = proxyGenerator.CreateClassProxy <TestController>();

                var controllerType = interfaceProxyWithTarget.GetType();

                var methodInfos = controllerType.GetMethods();

                actionDescriptor = new ReflectedActionDescriptor(methodInfos.First(x => x.Name.Equals("ReturnNull") && x.GetParameters().Count() == 0), "ReturnNull", new ReflectedControllerDescriptor(controllerType));

                Configuration = FluentMvcConfiguration.Create(CreateStub <IFluentMvcResolver>(), actionFilterRegistry, CreateStub <IActionResultRegistry>(), CreateStub <IFilterConventionCollection>())
                                .WithFilter <TestActionFilter>(Apply.For(func).AndFor(otherFunc));
            }
        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();
        }
 public override void Given()
 {
     actionFilterRegistry = new ActionFilterRegistry(CreateStub <IFluentMvcObjectFactory>());
     Configuration        = FluentMvcConfiguration.Create(CreateStub <IFluentMvcResolver>(), actionFilterRegistry, CreateStub <IActionResultRegistry>(), CreateStub <IFilterConventionCollection>())
                            .WithFilter <TestActionFilter>(Apply.When <TrueReturningConstraint>());
 }
Example #14
0
 public override void Given()
 {
     Configuration = FluentMvcConfiguration.Create();
 }
Example #15
0
 public override void Given()
 {
     resultFactory = CreateStub <AbstractActionResultFactory>();
     Configuration = FluentMvcConfiguration.Create();
 }
Example #16
0
 public override void Given()
 {
     Configuration      = FluentMvcConfiguration.Create();
     ExpectedConvention = CreateStub <FluentMvcConvention>();
 }
Example #17
0
 public override void Because()
 {
     Configuration = FluentMvcConfiguration.Create();
 }
Example #18
0
 public override void Given()
 {
     ExpectedDefaultFactory = CreateStub <IActionResultFactory>();
     Configuration          = FluentMvcConfiguration.Create();
 }
Example #19
0
 public override void Given()
 {
     Configuration = FluentMvcConfiguration.Create();
     Child1        = CreateStub <IActionResultFactory>();
     Child2        = CreateStub <IActionResultFactory>();
 }
Example #20
0
 public void Standard_Mvc()
 {
     FluentMvcConfiguration.Create()
     .WithConvention(new MvcConvention())
     .BuildFilterProvider();
 }