public void IsMatching_should_return_true_for_same_parameterized_actions() { var actionItem = new FilterRegistryActionItem <FakeController>(c => c.Edit(0, null), new Func <FilterAttribute> [0]); var controllerContext = new ControllerContext { Controller = new FakeController() }; var controllerDescriptor = new Mock <ControllerDescriptor>(); controllerDescriptor.SetupGet(cd => cd.ControllerName).Returns("Fake"); var intergerParameterDescriptor = new Mock <ParameterDescriptor>(); intergerParameterDescriptor.SetupGet(pd => pd.ParameterType).Returns(typeof(int)); var formsParameterDescriptor = new Mock <ParameterDescriptor>(); formsParameterDescriptor.SetupGet(pd => pd.ParameterType).Returns(typeof(FormCollection)); var actionDescriptor = new Mock <ActionDescriptor>(); actionDescriptor.SetupGet(ad => ad.ControllerDescriptor).Returns(controllerDescriptor.Object); actionDescriptor.SetupGet(ad => ad.ActionName).Returns("Edit"); actionDescriptor.Setup(ad => ad.GetParameters()).Returns(new[] { intergerParameterDescriptor.Object, formsParameterDescriptor.Object }); Assert.True(actionItem.IsMatching(controllerContext, actionDescriptor.Object)); }
public void IsMatching_should_return_false_for_same_action_when_parameter_differs() { var actionItem = new FilterRegistryActionItem <FakeController>(c => c.Edit(0), new Func <FilterAttribute> [0]); var controllerContext = new ControllerContext { Controller = new FakeController() }; var controllerDescriptor = new Mock <ControllerDescriptor>(); controllerDescriptor.SetupGet(cd => cd.ControllerName).Returns("Fake"); var parameterDescriptor = new Mock <ParameterDescriptor>(); parameterDescriptor.SetupGet(pd => pd.ParameterType).Returns(typeof(FormCollection)); var actionDescriptor = new Mock <ActionDescriptor>(); actionDescriptor.SetupGet(ad => ad.ControllerDescriptor).Returns(controllerDescriptor.Object); actionDescriptor.SetupGet(ad => ad.ActionName).Returns("Edit"); actionDescriptor.Setup(ad => ad.GetParameters()).Returns(new[] { parameterDescriptor.Object }); Assert.False(actionItem.IsMatching(controllerContext, actionDescriptor.Object)); }
public void IsMatching_should_return_false_for_other_action() { var actionItem = new FilterRegistryActionItem<FakeController>(c => c.Index(), new Func<FilterAttribute>[0]); var controllerContext = new ControllerContext { Controller = new FakeController() }; var controllerDescriptor = new Mock<ControllerDescriptor>(); controllerDescriptor.SetupGet(cd => cd.ControllerName).Returns("Fake"); var actionDescriptor = new Mock<ActionDescriptor>(); actionDescriptor.SetupGet(ad => ad.ControllerDescriptor).Returns(controllerDescriptor.Object); actionDescriptor.SetupGet(ad => ad.ActionName).Returns("About"); Assert.False(actionItem.IsMatching(controllerContext, actionDescriptor.Object)); }
public void IsMatching_should_return_false_for_other_action() { var actionItem = new FilterRegistryActionItem <FakeController>(c => c.Index(), new Func <FilterAttribute> [0]); var controllerContext = new ControllerContext { Controller = new FakeController() }; var controllerDescriptor = new Mock <ControllerDescriptor>(); controllerDescriptor.SetupGet(cd => cd.ControllerName).Returns("Fake"); var actionDescriptor = new Mock <ActionDescriptor>(); actionDescriptor.SetupGet(ad => ad.ControllerDescriptor).Returns(controllerDescriptor.Object); actionDescriptor.SetupGet(ad => ad.ActionName).Returns("About"); Assert.False(actionItem.IsMatching(controllerContext, actionDescriptor.Object)); }
public void IsMatching_should_return_false_for_same_action_when_parameter_differs() { var actionItem = new FilterRegistryActionItem<FakeController>(c => c.Edit(0), new Func<FilterAttribute>[0]); var controllerContext = new ControllerContext { Controller = new FakeController() }; var controllerDescriptor = new Mock<ControllerDescriptor>(); controllerDescriptor.SetupGet(cd => cd.ControllerName).Returns("Fake"); var parameterDescriptor = new Mock<ParameterDescriptor>(); parameterDescriptor.SetupGet(pd => pd.ParameterType).Returns(typeof(FormCollection)); var actionDescriptor = new Mock<ActionDescriptor>(); actionDescriptor.SetupGet(ad => ad.ControllerDescriptor).Returns(controllerDescriptor.Object); actionDescriptor.SetupGet(ad => ad.ActionName).Returns("Edit"); actionDescriptor.Setup(ad => ad.GetParameters()).Returns(new[] { parameterDescriptor.Object }); Assert.False(actionItem.IsMatching(controllerContext, actionDescriptor.Object)); }
public void IsMatching_should_return_false_when_controller_context_is_null() { var actionItem = new FilterRegistryActionItem<FakeController>(c => c.Index(), new Func<FilterAttribute>[0]); Assert.False(actionItem.IsMatching(null, null)); }
public void IsMatching_should_return_true_for_same_parameterized_actions() { var actionItem = new FilterRegistryActionItem<FakeController>(c => c.Edit(0, null), new Func<FilterAttribute>[0]); var controllerContext = new ControllerContext { Controller = new FakeController() }; var controllerDescriptor = new Mock<ControllerDescriptor>(); controllerDescriptor.SetupGet(cd => cd.ControllerName).Returns("Fake"); var intergerParameterDescriptor = new Mock<ParameterDescriptor>(); intergerParameterDescriptor.SetupGet(pd => pd.ParameterType).Returns(typeof(int)); var formsParameterDescriptor = new Mock<ParameterDescriptor>(); formsParameterDescriptor.SetupGet(pd => pd.ParameterType).Returns(typeof(FormCollection)); var actionDescriptor = new Mock<ActionDescriptor>(); actionDescriptor.SetupGet(ad => ad.ControllerDescriptor).Returns(controllerDescriptor.Object); actionDescriptor.SetupGet(ad => ad.ActionName).Returns("Edit"); actionDescriptor.Setup(ad => ad.GetParameters()).Returns(new[] { intergerParameterDescriptor.Object, formsParameterDescriptor.Object }); Assert.True(actionItem.IsMatching(controllerContext, actionDescriptor.Object)); }
public void IsMatching_should_return_false_when_action_descriptor_is_null() { var actionItem = new FilterRegistryActionItem <FakeController>(c => c.Index(), new Func <FilterAttribute> [0]); Assert.False(actionItem.IsMatching(new ControllerContext(), null)); }