public override void SetUp() { base.SetUp(); _htmlHelper = new HtmlHelper(); _httpContextStub = MockRepository.GenerateStub <HttpContextBase> (); _control = MockRepository.GenerateStub <IListMenu>(); _control.Stub(stub => stub.UniqueID).Return("MyListMenu"); _control.Stub(stub => stub.ClientID).Return("MyListMenu"); _control.Stub(stub => stub.MenuItems).Return(new WebMenuItemCollection(_control)); _control.Stub(stub => stub.Enabled).Return(true); _control.Stub(stub => stub.HasClientScript).Return(true); _control.Stub(stub => stub.ResolveClientUrl(null)).IgnoreArguments().Do((Func <string, string>)(url => url.TrimStart('~'))); _control.Stub(stub => stub.GetUpdateScriptReference("null")).Return("Update();"); var pageStub = MockRepository.GenerateStub <IPage>(); _clientScriptManagerMock = MockRepository.GenerateMock <IClientScriptManager>(); pageStub.Stub(page => page.ClientScript).Return(_clientScriptManagerMock); _control.Stub(stub => stub.Page).Return(pageStub); _resourceUrlFactory = new FakeResourceUrlFactory(); PopulateMenu(); }
public override void SetUp() { base.SetUp(); _htmlHelper = new HtmlHelper(); _httpContext = MockRepository.GenerateStub <HttpContextBase> (); _control = MockRepository.GenerateStub <IDropDownMenu>(); _control.ID = "DropDownMenu1"; _control.Stub(stub => stub.UniqueID).Return("DropDownMenu1"); _control.Stub(stub => stub.ClientID).Return("DropDownMenu1"); _control.Stub(stub => stub.MenuItems).Return(new WebMenuItemCollection(_control)); _control.Stub(stub => stub.GetBindOpenEventScript(null, null, true)).IgnoreArguments().Return("OpenDropDownMenuEventReference"); _control.Stub(stub => stub.MenuHeadClientID).Return("DropDownMenu1_MenuDiv"); _control.Stub(stub => stub.ResolveClientUrl(null)).IgnoreArguments().Do((Func <string, string>)(url => url.TrimStart('~'))); IPage pageStub = MockRepository.GenerateStub <IPage>(); pageStub.Stub(stub => stub.Context).Return(MockRepository.GenerateStub <HttpContextBase>()); _control.Stub(stub => stub.Page).Return(pageStub); StateBag stateBag = new StateBag(); _control.Stub(stub => stub.Attributes).Return(new AttributeCollection(stateBag)); _control.Stub(stub => stub.ControlStyle).Return(new Style(stateBag)); IClientScriptManager scriptManagerMock = MockRepository.GenerateMock <IClientScriptManager> (); _control.Page.Stub(stub => stub.ClientScript).Return(scriptManagerMock); _resourceUrlFactory = new FakeResourceUrlFactory(); }
public void SetUp() { _htmlHelper = new HtmlHelper(); _httpContextStub = MockRepository.GenerateStub <HttpContextBase>(); _control = MockRepository.GenerateStub <IListMenu>(); _control.Stub(stub => stub.UniqueID).Return("MyListMenu"); _control.Stub(stub => stub.ClientID).Return("MyListMenu"); _control.Stub(stub => stub.ControlType).Return("ListMenu"); _control.Stub(stub => stub.MenuItems).Return(new WebMenuItemCollection(_control)); _control.Stub(stub => stub.Enabled).Return(true); _control.Stub(stub => stub.HasClientScript).Return(true); _control.Stub(stub => stub.ResolveClientUrl(null)).IgnoreArguments().Do((Func <string, string>)(url => url.TrimStart('~'))); _control.Stub(stub => stub.GetUpdateScriptReference("null")).Return("Update();"); var pageStub = MockRepository.GenerateStub <IPage>(); _clientScriptManagerMock = MockRepository.GenerateMock <IClientScriptManager>(); pageStub.Stub(page => page.ClientScript).Return(_clientScriptManagerMock); _control.Stub(stub => stub.Page).Return(pageStub); PopulateMenu(); var serviceLocator = DefaultServiceLocator.Create(); serviceLocator.RegisterSingle <IRenderingFeatures> (() => RenderingFeatures.WithDiagnosticMetadata); _serviceLocatorScope = new ServiceLocatorScope(serviceLocator); }
public static void Register(IClientScriptManager manager, Registrations registrations, Nparams attrib) { if (manager == null) { throw new ArgumentNullException("manager"); } if ((registrations & Registrations.SwfUpload) == Registrations.SwfUpload) { //string swfUploadVersion; string version = SwfUploadVersion; // ((attrib != null) && attrib.TryGetValue("swfUploadVersion", out swfUploadVersion) ? swfUploadVersion : SwfUploadVersion); if (string.IsNullOrEmpty(version)) { throw new InvalidOperationException("version"); } string versionFolder = "Contoso.Resource_.SwfUpload" + version.Replace(".", "_"); // STATE HttpContext.Current.Set <ClientScriptRegistrarSwfUploadShape>(new ClientScriptRegistrarSwfUploadShape { SwfUploadFlashUrl = ClientScriptManagerEx.GetWebResourceUrl(_type, versionFolder + ".swfupload.swf"), }); // INCLUDES manager.EnsureItem <HtmlHead>("SwfUpload", () => new IncludeForResourceClientScriptItem(_type, "Contoso.Resource_.SwfUpload" + version + ".js")); if ((registrations & Registrations.SwfUploadCookiePlugin) == Registrations.SwfUploadCookiePlugin) { manager.EnsureItem <HtmlHead>("CookiePlugin", () => new IncludeForResourceClientScriptItem(_type, versionFolder + ".cookies.js")); } if ((registrations & Registrations.SwfUploadQueuePlugin) == Registrations.SwfUploadQueuePlugin) { manager.EnsureItem <HtmlHead>("QueuePlugin", () => new IncludeForResourceClientScriptItem(_type, versionFolder + ".queue.js")); } if ((registrations & Registrations.SwfUploadSpeedPlugin) == Registrations.SwfUploadSpeedPlugin) { manager.EnsureItem <HtmlHead>("SpeedPlugin", () => new IncludeForResourceClientScriptItem(_type, versionFolder + ".speed.js")); } if ((registrations & Registrations.SwfUploadSwfObjectPlugin) == Registrations.SwfUploadSwfObjectPlugin) { manager.EnsureItem <HtmlHead>("SwfObjectPlugin", () => new IncludeForResourceClientScriptItem(_type, versionFolder + ".swfobject.js")); } } }
public static void Register(IClientScriptManager manager, Registrations registrations, Nparams attrib) { if (manager == null) { throw new ArgumentNullException("manager"); } if ((registrations & Registrations.SwfObject) == Registrations.SwfObject) { var version = SwfObjectVersion; // ((attrib != null) && attrib.TryGetValue("swfObjectVersion", out swfObjectVersion) ? swfObjectVersion : SwfObjectVersion); if (string.IsNullOrEmpty(version)) { throw new InvalidOperationException("version"); } var versionFolder = "Contoso.Resource_.SwfObject" + version.Replace(".", "_"); // STATE HttpContext.Current.Set <ClientScriptRegistrarSwfObjectShape>(new ClientScriptRegistrarSwfObjectShape { SwfObjectExpressInstallFlashUrl = ClientScriptManagerEx.GetWebResourceUrl(_type, versionFolder + ".expressInstall.swf"), }); // INCLUDES manager.EnsureItem <HtmlHead>("SwfObject", () => new IncludeForResourceClientScriptItem(_type, "Contoso.Resource_.SwfObject" + version + ".js")); } }
/// <summary> /// Registers the specified manager. /// </summary> /// <param name="manager">The manager.</param> /// <param name="registrations">The registrations.</param> /// <param name="attrib">The attrib.</param> public static void Register(IClientScriptManager manager, Registrations registrations, Nparams attrib) { if (manager == null) throw new ArgumentNullException("manager"); if ((registrations & Registrations.SwfUpload) == Registrations.SwfUpload) { //string swfUploadVersion; var version = SwfUploadVersion; // ((attrib != null) && attrib.TryGetValue("swfUploadVersion", out swfUploadVersion) ? swfUploadVersion : SwfUploadVersion); if (string.IsNullOrEmpty(version)) throw new InvalidOperationException("version"); var versionFolder = "Contoso.Resource_.SwfUpload" + version.Replace(".", "_"); // STATE HttpContext.Current.Set<ClientScriptRegistrarSwfUploadShape>(new ClientScriptRegistrarSwfUploadShape { SwfUploadFlashUrl = ClientScriptManagerEx.GetWebResourceUrl(_type, versionFolder + ".swfupload.swf"), }); // INCLUDES manager.EnsureItem<HtmlHead>("SwfUpload", () => new IncludeForResourceClientScriptItem(_type, "Contoso.Resource_.SwfUpload" + version + ".js")); if ((registrations & Registrations.SwfUploadCookiePlugin) == Registrations.SwfUploadCookiePlugin) manager.EnsureItem<HtmlHead>("CookiePlugin", () => new IncludeForResourceClientScriptItem(_type, versionFolder + ".cookies.js")); if ((registrations & Registrations.SwfUploadQueuePlugin) == Registrations.SwfUploadQueuePlugin) manager.EnsureItem<HtmlHead>("QueuePlugin", () => new IncludeForResourceClientScriptItem(_type, versionFolder + ".queue.js")); if ((registrations & Registrations.SwfUploadSpeedPlugin) == Registrations.SwfUploadSpeedPlugin) manager.EnsureItem<HtmlHead>("SpeedPlugin", () => new IncludeForResourceClientScriptItem(_type, versionFolder + ".speed.js")); if ((registrations & Registrations.SwfUploadSwfObjectPlugin) == Registrations.SwfUploadSwfObjectPlugin) manager.EnsureItem<HtmlHead>("SwfObjectPlugin", () => new IncludeForResourceClientScriptItem(_type, versionFolder + ".swfobject.js")); } }