public void CustomTemplatesTagsRecognized() { GadgetReferencingTemplateLibrary testData = new GadgetReferencingTemplateLibrary(); GadgetMaster master = GadgetMaster.CreateGadget(TEST_FACTORY_KEY, testData.Source); //new GadgetMaster(ControlFactory.GetControlFactory(TEST_FACTORY_KEY)); Assert.AreEqual(0, master.MasterCustomTagFactory.CustomTags.Count, "Custom tags not initially zero"); BasicLibrary testLib = new BasicLibrary(); TemplatesRoot library = master.LoadTemplateLibrary(testData.ExpectedTemplateLibraryUri, BasicLibrary.Source); Assert.IsTrue(master.MasterCustomTagFactory.IsCustomTag("foo:bar")); Assert.IsTrue(master.MasterCustomTagFactory.IsCustomTag("foo:dog")); }
public void TemplateLibraryHasTag() { GadgetReferencingTemplateLibrary testData = new GadgetReferencingTemplateLibrary(); GadgetMaster master = GadgetMaster.CreateGadget(TEST_FACTORY_KEY, testData.Source); //new GadgetMaster(ControlFactory.GetControlFactory(TEST_FACTORY_KEY)); Assert.Greater(testData.ExpectedCustomTags.Count, 0, "No expected tags"); BasicLibrary testLib = new BasicLibrary(); TemplatesRoot library = master.LoadTemplateLibrary(testData.ExpectedTemplateLibraryUri, BasicLibrary.Source); Assert.AreEqual(2, library.CustomTags.Count, "Incorrect template count"); Assert.IsFalse(String.IsNullOrEmpty(library.CustomTags[0].Tag), "tag is empty"); }
/// <summary> /// Loads a template library into the custom tag factory /// </summary> /// <param name="uriKey">Original uri key to the library</param> /// <param name="templateLibrary">XML contents of the library file</param> /// <param name="offsets">Offset list for the library</param> public TemplatesRoot LoadTemplateLibrary(string uriKey, string templateLibrary, OffsetItem offsetItem) { TemplatesRoot lib = new TemplatesRoot(templateLibrary, this, offsetItem); MyCustomTagFactory.RegisterCustomTags(lib.CustomTags); foreach (TemplateLibraryDef templateDef in TemplateLibraries.Libraries) { if (uriKey == templateDef.Uri) { templateDef.LibraryXml = templateLibrary; templateDef.Loaded = true; break; } } return(lib); }
public void CountCustomTemplates() { GadgetReferencingTemplateLibrary testData = new GadgetReferencingTemplateLibrary(); GadgetMaster master = GadgetMaster.CreateGadget(TEST_FACTORY_KEY, testData.Source); //new GadgetMaster(ControlFactory.GetControlFactory(TEST_FACTORY_KEY)); Assert.AreEqual(0, master.MasterCustomTagFactory.CustomTags.Count, "Custom tags not initially zero"); Assert.IsFalse(master.NeedsReparse); BasicLibrary testLib = new BasicLibrary(); TemplatesRoot library = master.LoadTemplateLibrary(testData.ExpectedTemplateLibraryUri, BasicLibrary.Source); int tcount = master.MasterCustomTagFactory.CustomTags.Count; Assert.Greater(master.MasterCustomTagFactory.CustomTags.Count, 0, "No Custom tags registered"); string result = master.RenderToString("canvas"); Assert.AreEqual(tcount, master.MasterCustomTagFactory.CustomTags.Count); }
public void MultipleRootIsRootElementTest() { GadgetMaster gm = new GadgetMaster(); Assert.IsTrue(testFactory.IsRootElement(gm), "GadgetMaster not recognized root"); //TemplateLibrary TemplatesRoot templates = new TemplatesRoot(); Assert.IsTrue(testFactory.IsRootElement(templates), "TemplatesRoot not recognized root"); //RootElement RootElementMaster ram = new RootElementMaster(); Assert.IsTrue(testFactory.IsRootElement(ram), "RootElementMaster not recognized root"); OsmlRepeater repeater = new OsmlRepeater(); Assert.IsFalse(testFactory.IsRootElement(repeater), "OsmlRepeater incorrectly recognized as root"); }
public void RenderWithExternalTemplates() { GadgetReferencingTemplateLibrary testData = new GadgetReferencingTemplateLibrary(); GadgetMaster master = GadgetMaster.CreateGadget(TEST_FACTORY_KEY, testData.Source); //new GadgetMaster(ControlFactory.GetControlFactory(TEST_FACTORY_KEY)); BasicLibrary testLib = new BasicLibrary(); TemplatesRoot library = master.LoadTemplateLibrary(testData.ExpectedTemplateLibraryUri, BasicLibrary.Source); master.RenderingOptions.ClientRenderCustomTemplates = false; master.RenderingOptions.ClientRenderDataContext = false; master.RenderingOptions.DivWrapContentBlocks = false; master.RenderingOptions.SuppressWhitespace = true; master.ReParse(); ResolveDataControlValues(master.MyDataContext, testData.ExpectedViewer, testData.ExpectedViewer, testData.ExpectedFriends); string result = ControlTestHelper.NormalizeRenderResult(master.RenderToString("canvas")); result = result.Replace(" ", " "); string expected = ControlTestHelper.NormalizeRenderResult(testData.ExpectedCanvas); Assert.AreEqual(expected, result, "Rendered results don't match expected"); }