/// <summary> /// Adds the action. /// </summary> /// <param name="action">The action.</param> /// <param name="metaDescriptor">The meta descriptor.</param> public void AddAction(object action, ActionMetaDescriptor metaDescriptor) { if (action == null) throw new ArgumentNullException("action"); if (metaDescriptor == null) throw new ArgumentNullException("metaDescriptor"); actionMetaDescriptors[action] = metaDescriptor; }
/// <summary> /// Adds the action. /// </summary> /// <param name="action">The action.</param> /// <param name="metaDescriptor">The meta descriptor.</param> public void AddAction(object action, ActionMetaDescriptor metaDescriptor) { if (action == null) { throw new ArgumentNullException("action"); } if (metaDescriptor == null) { throw new ArgumentNullException("metaDescriptor"); } actionMetaDescriptors[action] = metaDescriptor; }
public void ShouldReflectAbsenceOfConfigurationOnMetaDescriptor() { BaseController controller = new BaseController(); ActionMetaDescriptor actionMeta = new ActionMetaDescriptor(); ActionMethodExecutor executor = new ActionMethodExecutor(GetActionMethod(controller), actionMeta); Assert.IsFalse(executor.ShouldSkipAllFilters); Assert.IsFalse(executor.ShouldSkipRescues); Assert.IsFalse(executor.ShouldSkipFilter(typeof(DummyFilter))); Assert.IsNull(executor.LayoutOverride); Assert.AreEqual(0, executor.Resources.Length); }
public void ShouldReturnTrueToSkipSpecifiedFiltersReflectingMeta() { BaseController controller = new BaseController(); ActionMetaDescriptor actionMeta = new ActionMetaDescriptor(); actionMeta.SkipFilters.Add(new SkipFilterAttribute(typeof(DummyFilter))); ActionMethodExecutor executor = new ActionMethodExecutor(GetActionMethod(controller), actionMeta); Assert.IsTrue(executor.ShouldSkipFilter(typeof(DummyFilter))); Assert.IsFalse(executor.ShouldSkipRescues); Assert.IsFalse(executor.ShouldSkipAllFilters); Assert.IsNull(executor.LayoutOverride); Assert.AreEqual(0, executor.Resources.Length); }
public void CompatibleExecutorDelegatesInvocationToControllerUsingDelegate() { var controller = new BaseController(); var actionMeta = new ActionMetaDescriptor(); ActionMethodExecutorCompatible.InvokeOnController delegateToController = controller.InvokeMethodStub; var executor = new ActionMethodExecutorCompatible(GetActionMethod(controller), actionMeta, delegateToController); var req = new StubRequest(); var res = new StubResponse(); var services = new StubMonoRailServices(); IEngineContext engineContext = new StubEngineContext(req, res, services, new UrlInfo("area", "controller", "action")); var retVal = executor.Execute(engineContext, controller, new ControllerContext()); Assert.IsTrue(controller.WasExecuted); Assert.AreEqual(2, retVal); }
/// <summary> /// Initializes a new instance of the <see cref="ActionMethodExecutorCompatible"/> class. /// </summary> /// <param name="actionMethod">The action method.</param> /// <param name="metaDescriptor">The meta descriptor.</param> /// <param name="invoke">The invoke.</param> public ActionMethodExecutorCompatible(MethodInfo actionMethod, ActionMetaDescriptor metaDescriptor, InvokeOnController invoke) : base(actionMethod, metaDescriptor) { this.invoke = invoke; }
/// <summary> /// Initializes a new instance of the <see cref="ActionMethodExecutor"/> class. /// </summary> /// <param name="actionMethod">The action method.</param> /// <param name="metaDescriptor">The meta descriptor.</param> public ActionMethodExecutor(MethodInfo actionMethod, ActionMetaDescriptor metaDescriptor) : base(metaDescriptor) { this.actionMethod = actionMethod; }
public void ShouldReturnLayoutReflectingMeta() { BaseController controller = new BaseController(); ActionMetaDescriptor actionMeta = new ActionMetaDescriptor(); actionMeta.Layout = new LayoutDescriptor("layoutname"); ActionMethodExecutor executor = new ActionMethodExecutor(GetActionMethod(controller), actionMeta); Assert.IsFalse(executor.ShouldSkipFilter(typeof(DummyFilter))); Assert.IsFalse(executor.ShouldSkipRescues); Assert.IsFalse(executor.ShouldSkipAllFilters); Assert.AreEqual("layoutname", executor.LayoutOverride[0]); Assert.AreEqual(0, executor.Resources.Length); }
public void ExecutesActionAndReturnValue() { BaseController controller = new BaseController(); ActionMetaDescriptor actionMeta = new ActionMetaDescriptor(); ActionMethodExecutor executor = new ActionMethodExecutor(GetActionMethod(controller), actionMeta); StubRequest req = new StubRequest(); StubResponse res = new StubResponse(); StubMonoRailServices services = new StubMonoRailServices(); IEngineContext engineContext = new StubEngineContext(req, res, services, new UrlInfo("area", "controller", "action")); object retVal = executor.Execute(engineContext, controller, new ControllerContext()); Assert.IsTrue(controller.WasExecuted); Assert.AreEqual(1, retVal); }
public void ShouldReturnResourcesReflectingMeta() { BaseController controller = new BaseController(); ActionMetaDescriptor actionMeta = new ActionMetaDescriptor(); actionMeta.Resources = new ResourceDescriptor[] { new ResourceDescriptor(typeof(BaseController), "name", "resname", "cult", "assm") }; ActionMethodExecutor executor = new ActionMethodExecutor(GetActionMethod(controller), actionMeta); Assert.IsFalse(executor.ShouldSkipFilter(typeof(DummyFilter))); Assert.IsFalse(executor.ShouldSkipRescues); Assert.IsFalse(executor.ShouldSkipAllFilters); Assert.IsNull(executor.LayoutOverride); Assert.AreEqual(1, executor.Resources.Length); }