Ejemplo n.º 1
0
        public void MatchMatchesMultipleMethods()
        {
            ControllerActionCriteria criteria = new ControllerActionCriteria();

            criteria.AddMethod <FakeController>(c => c.Action());
            criteria.AddMethod <FakeController>(c => c.ActionWithParameters(null));

            MethodInfo actionMethod = typeof(FakeController).GetMethod("Action");
            MethodInfo actionMethodWithParameters = typeof(FakeController).GetMethod("ActionWithParameters");

            Assert.True(criteria.Match(this.GetContext(actionMethod)));
            Assert.True(criteria.Match(this.GetContext(actionMethodWithParameters)));
        }
Ejemplo n.º 2
0
        public void MatchMatchesMethod()
        {
            ControllerActionCriteria criteria = new ControllerActionCriteria();

            criteria.AddMethod <FakeController>(c => c.Action());

            MethodInfo actionMethod = typeof(FakeController).GetMethod("Action");

            Assert.True(criteria.Match(this.GetContext(actionMethod)));
        }
Ejemplo n.º 3
0
        public void MatchWorksOnNonReflectedActionDescriptor()
        {
            ControllerActionCriteria criteria = new ControllerActionCriteria();

            criteria.AddMethod <FakeController>(c => c.RealNameIsAliasedAction());

            MethodInfo actionMethod = typeof(FakeController).GetMethod("RealNameIsAliasedAction");

            ActionFilterRegistryContext context = new ActionFilterRegistryContext(new ControllerContext(), new FakeActionDescriptor()
            {
                Name = "AliasedAction"
            });

            Assert.True(criteria.Match(context));
        }