Exemple #1
0
        public void EmptyHtml()
        {
            TemplateServices templateServices = TemplateUtilities.CreateTestTemplateServices();

            string html = "";
            Dictionary <string, string> values = new Dictionary <string, string>();
            string actualHtml = null;

            actualHtml = templateServices.InjectTemplateValues(html, values);

            // Check result
            Assert.AreEqual(html, actualHtml);
        }
        public async Task SingleFolderSingleTemplate()
        {
            TemplateServices templateServices       = TemplateUtilities.CreateTestTemplateServices();
            Dictionary <string, Template> templates = new Dictionary <string, Template>();

            await templateServices.LoadTemplatesRecursive(new FolderMock()
            {
                Name = "Folder0", Path = "Folder0"
            }, templates);

            // Check result
            Assert.AreEqual(1, templates.Count);
            Template template = templates["template1"];
        }
Exemple #3
0
        public void NoTemplates()
        {
            TemplateServices templateServices = TemplateUtilities.CreateTestTemplateServices();

            string rawHtml = "some content";
            Dictionary <string, Template> templates = new Dictionary <string, Template>();
            string actualHtml = null;
            Dictionary <string, string> actualValues = new Dictionary <string, string>();

            templateServices.InjectTemplateRecursive(rawHtml, templates, out actualHtml, ref actualValues);

            // Check result
            Assert.AreEqual(rawHtml, actualHtml);
            Assert.AreEqual(0, actualValues.Count);
        }
Exemple #4
0
        public void TwoInjectionPoints()
        {
            TemplateServices templateServices = TemplateUtilities.CreateTestTemplateServices();

            string html = "some <!-- INJECT_TEMPLATE_VALUE valueId='injectionPoint0' --> content <!-- INJECT_TEMPLATE_VALUE valueId='injectionPoint1' --> text";
            Dictionary <string, string> values = new Dictionary <string, string>()
            {
                { "injectionPoint0", "injected text" }, { "injectionPoint1", "injected text2" }
            };
            string actualHtml = null;

            actualHtml = templateServices.InjectTemplateValues(html, values);

            // Check result
            Assert.AreEqual("some injected text content injected text2 text", actualHtml);
        }
Exemple #5
0
        public void TwoInjectionPointsCurlyStartAndEnd()
        {
            TemplateServices templateServices = TemplateUtilities.CreateTestTemplateServices();

            string html = "{{{injectionPoint0}}} some content text {{{injectionPoint1}}}";
            Dictionary <string, string> values = new Dictionary <string, string>()
            {
                { "injectionPoint0", "injected text" }, { "injectionPoint1", "injected text2" }
            };
            string actualHtml = null;

            actualHtml = templateServices.InjectTemplateValues(html, values);

            // Check result
            Assert.AreEqual("injected text some content text injected text2", actualHtml);
        }
Exemple #6
0
        public void SingleInjectionPointCurly()
        {
            TemplateServices templateServices = TemplateUtilities.CreateTestTemplateServices();

            string html = "some {{{injectionPoint0}}} content";
            Dictionary <string, string> values = new Dictionary <string, string>()
            {
                { "injectionPoint0", "injected text" }
            };
            string actualHtml = null;

            actualHtml = templateServices.InjectTemplateValues(html, values);

            // Check result
            Assert.AreEqual("some injected text content", actualHtml);
        }
Exemple #7
0
        public void SingleTemplate()
        {
            TemplateServices templateServices = TemplateUtilities.CreateTestTemplateServices();

            string rawHtml = "some <!-- INJECT_TEMPLATE templateId='template0' --> content";
            Dictionary <string, Template> templates = TemplateUtilities.CreateTestTemplates();
            string actualHtml = null;
            Dictionary <string, string> actualValues = new Dictionary <string, string>();

            templateServices.InjectTemplateRecursive(rawHtml, templates, out actualHtml, ref actualValues);

            // Check result
            string expectedHTML = "some template0 content text content";

            Assert.AreEqual(expectedHTML, actualHtml);
            Assert.AreEqual(0, actualValues.Count);
        }