public static MvcHtmlString RenderCMSObject(this HtmlHelper helper, CMSObject cmsObject) { var actionName = string.IsNullOrEmpty(cmsObject.ActionName) ? "Index" : cmsObject.ActionName; var controllerName = string.IsNullOrEmpty(cmsObject.ControllerName) ? "Default" : cmsObject.ControllerName; return(ActionInvoker.Action(helper, actionName, controllerName, cmsObject)); }
public void GivenACmsObjectWithCompletedActionAndController_WhenRenderCMSObject_ThenExpectedActionOutcomeforActionAndControllerIsGiven() { const string actionName = "foo"; const string controllerName = "bar"; const string expectedOutcome = "<h1>Bruce</h1>"; // Arrange var cmsObject = new CMSObject { ActionName = actionName, ControllerName = controllerName }; var mockInvoker = new Mock <IHtmlHelperActionInvoker>(); mockInvoker.Setup(x => x.Action(null, actionName, controllerName, cmsObject)).Returns(MvcHtmlString.Create(expectedOutcome)); SomeHtmlHelperClass.ActionInvoker = mockInvoker.Object; // Act var result = SomeHtmlHelperClass.RenderCMSObject(null, cmsObject); // Verify Assert.That(result.ToString(), Is.EqualTo(expectedOutcome)); }
public MvcHtmlString Action(HtmlHelper helper, string action, string controller, CMSObject model) { return(helper.Action(action, controller, model)); }