public void CanInvokeMethodWithParamsArray() { var viewContext = _mocks.DynamicViewContext("someView"); var viewDataContainer = _mocks.DynamicMock<IViewDataContainer>(); HtmlExtensionDuck.AddExtension(typeof(HtmlExtensionForTesting)); var htmlExtensionDuck = new HtmlExtensionDuck(viewContext, viewDataContainer); Object[] args = {"foo", "bar"}; object result = htmlExtensionDuck.Invoke("Bar", args); Assert.That(result, Is.EqualTo("Bar3")); }
public void CanFindMethodWithAmbiguousOverloads() { var viewContext = _mocks.DynamicViewContext("someView"); var viewDataContainer = _mocks.DynamicMock<IViewDataContainer>(); HtmlExtensionDuck.AddExtension(typeof(HtmlExtensionForTesting)); var htmlExtensionDuck = new HtmlExtensionDuck(viewContext, viewDataContainer); object result = htmlExtensionDuck.Invoke("Bar", "x"); Assert.That(result, Is.EqualTo("Bar")); }
public void CanAddExtensionsToHtmlExtensionDuck() { var viewContext = _mocks.DynamicViewContext("someView"); var viewDataContainer = _mocks.DynamicMock<IViewDataContainer>(); HtmlExtensionDuck.AddExtension(typeof(HtmlExtensionForTesting)); var htmlExtensionDuck = new HtmlExtensionDuck(viewContext, viewDataContainer); object result = htmlExtensionDuck.Invoke("Foo"); Assert.That(result, Is.EqualTo("Bar")); }
private static void AddHtmlExtensionsFromConfig() { var section = ConfigurationManager.GetSection("nvelocity"); if (section == null) { return; } var config = (NVelocityConfiguration)section; foreach (var t in config.HtmlExtensionTypes) { HtmlExtensionDuck.AddExtension(t); } }
public void SetUp() { _mocks = new MockRepository(); var httpContext = _mocks.DynamicMock<HttpContextBase>(); var httpResponse = _mocks.DynamicMock<HttpResponseBase>(); var httpSessionState = _mocks.DynamicMock<HttpSessionStateBase>(); SetupResult.For(httpContext.Session).Return(httpSessionState); SetupResult.For(httpContext.Response).Return(httpResponse); var routeData = new RouteData(); routeData.Values["controller"] = "testcontroller"; var requestContext = new RequestContext(httpContext, routeData ); var controller = _mocks.DynamicMock<ControllerBase>(); var controllerContext = new ControllerContext(requestContext, controller); var view = _mocks.DynamicMock<IView>(); _mocks.ReplayAll(); var viewPage = new ViewPage(); var viewContext = new ViewContext(controllerContext, view,new ViewDataDictionary(), new TempDataDictionary(), new StringWriter()); _htmlHelper = new HtmlHelper(viewContext, viewPage); _htmlHelperDuck = new HtmlExtensionDuck(_htmlHelper) {Introspector = new Introspector(new Logger())}; }
private void CreateAndAddHelpers(Hashtable entries) { entries["html"] = entries["htmlhelper"] = new HtmlExtensionDuck(_viewContext, this); entries["url"] = entries["urlhelper"] = new UrlHelper(_viewContext.RequestContext); }