public GadgetReferencingTemplateLibrary()
            : base()
        {
            this.Source =
                @"<?xml version='1.0' encoding='utf-8'?>
<Module>
<ModulePrefs>
<Require feature=""opensocial-templates"">
  <Param name=""requireLibrary"">http://www.example.com/basicLibrary.xml</Param>
</Require>
</ModulePrefs>
	<Content type='html' view='canvas'>
  <script type=""text/os-data"">
    <os:ViewerRequest key='vwr' />
  </script>
<script type='text/os-template'>
<h1>User: ${vwr.displayName}</h1>
<foo:bar></foo:bar>
<foo:dog><dog>${vwr.displayName}</dog></foo:dog>
</script>
</Content>
</Module>";
            BasicLibrary testLib = new BasicLibrary();

            ExpectedCustomTags.AddRange(testLib.DefinedTags);


            ExpectedCanvas =
                @"<h1>User: "******"</h1>
<h1>I am a simple template</h1> <div style='border:2px solid lightgrey;'>Woof woof. My name is " + ExpectedViewer.DisplayName + @"</div>
";
        }
Пример #2
0
        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"));
        }
Пример #3
0
        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");
        }
        public void ExternalTemplateCustomTagsRegistered()
        {
            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();

            master.LoadTemplateLibrary(testData.ExpectedTemplateLibraryUri, BasicLibrary.Source);

            foreach (string tag in testData.ExpectedCustomTags)
            {
                Assert.IsTrue(master.MasterCustomTagFactory.IsCustomTag(tag), "Tag: " + tag + " is not registered with tag factory");
            }
        }
Пример #5
0
        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 TemplateLoadStateSetOn()
        {
            GadgetReferencingTemplateLibrary testData = new GadgetReferencingTemplateLibrary();

            GadgetMaster master = GadgetMaster.CreateGadget(TEST_FACTORY_KEY, testData.Source);             //new GadgetMaster(ControlFactory.GetControlFactory(TEST_FACTORY_KEY));

            Assert.IsTrue(master.TemplateLibraries.HasLibraries(), "No libraries defined");
            Assert.IsFalse(master.TemplateLibraries.Libraries[0].Loaded, "Library incorrectly marked as loaded");

            BasicLibrary testLib = new BasicLibrary();

            master.LoadTemplateLibrary(testData.ExpectedTemplateLibraryUri, BasicLibrary.Source);

            Assert.IsFalse(master.TemplateLibraries.HasLibraries(), "No libraries defined");
            Assert.IsTrue(master.TemplateLibraries.Libraries[0].Loaded, "Library incorrectly marked as loaded");

            Assert.IsFalse(string.IsNullOrEmpty(master.TemplateLibraries.Libraries[0].LibraryXml), "LibraryXml value not set on load");
        }
Пример #7
0
        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");
        }