public void AddADesignerForWidgetToMvcDesignerStore_WhenRegisterDesignerIsCalled() { var mvcManager = new MvcManager(); mvcManager.RegisterDesigner<WidgetType, WidgetDesigner>(); var mvcDesignerStore = PowerTools.Instance.Container.Resolve<IMvcDesignerStore>(); Assert.AreEqual(1, mvcDesignerStore.MvcDesigners.Keys.Count); Assert.AreEqual(typeof(WidgetDesigner), mvcDesignerStore.MvcDesigners[typeof(WidgetType)]); }
public void ThrowAnException_WhenRegisterDesignerIsCalledForTheWidgetTypeThatAlreadyHasARegisteredWidget() { var mvcManager = new MvcManager(); mvcManager.RegisterDesigner<WidgetType, WidgetDesigner>(); try { mvcManager.RegisterDesigner<WidgetType, WidgetDesigner>(); Assert.Fail("Exception was supposed to be thrown."); } catch (ArgumentException ex) { Assert.AreEqual(string.Format("A designer for widget of type '{0}' has already been registered.", typeof(WidgetType).FullName), ex.Message); } }
/// <summary> /// Copy the jQuery components. /// </summary> private void CopyScriptFilesFromComponents() { foreach (IScriptableComponent component in scriptableComponents) { string assetKey = string.IsNullOrEmpty(component.AssetKey) ? "default" : component.AssetKey; string filesPath = component.ScriptFilesPath; if (assetKey.IsCaseInsensitiveEqual("default") && WebAssetDefaultSettings.ScriptFilesPath.IsCaseInsensitiveEqual(filesPath)) { if (!DefaultGroup.DefaultPath.IsCaseInsensitiveEqual(WebAssetDefaultSettings.ScriptFilesPath)) { filesPath = DefaultGroup.DefaultPath; } } component.ScriptFileNames.Each(source => Scripts.Add(assetKey, MvcManager.CombinePath(filesPath, source))); } }
/// <summary> /// Copy the jQuery files. /// </summary> private void CopyFrameworkScriptFiles() { if (!ExcludeFrameworkScripts) { FrameworkScriptFileNames.Reverse().Each(source => DefaultGroup.Items.Insert(0, new WebAssetItem(MvcManager.CombinePath(DefaultGroup.DefaultPath, source)))); } }
/// <summary> /// Create the item in the web asset item collection. /// </summary> /// <param name="source">The name of the item to add.</param> /// <returns>The created web asset item.</returns> private WebAssetItem CreateItem(string source) { // If the instance object is null. if (source == null) { throw new System.ArgumentNullException("source"); } string itemSource = source.StartsWith("~/", StringComparison.OrdinalIgnoreCase) ? source : MvcManager.CombinePath(_assetItemGroup.DefaultPath, source); // Return the script web item return(new WebAssetItem(itemSource)); }
/// <summary> /// Create the web asset item /// </summary> /// <param name="source">The name of the source.</param> /// <returns>The new web asset item.</returns> private WebAssetItem CreateItem(string source) { string itemSource = source.StartsWith("~/", StringComparison.OrdinalIgnoreCase) ? source : MvcManager.CombinePath(DefaultPath, source); return(new WebAssetItem(itemSource)); }