public void TearDown()
        {
            ServerOperations.Pages().DeleteAllPages();
            ServerOperations.News().DeleteAllNews();

            FeatherServerOperations.ResourcePackages().DeleteSelectorsData(DesignerViewFileName, JsonFileName, ControllerFileName);
        }
        private void CreateLayoutFile(string layoutFileName)
        {
            PageManager pageManager           = PageManager.GetManager();
            int         initialTemplatesCount = pageManager.GetTemplates().Count();

            using (new UnrestrictedModeRegion())
            {
                var layoutsFolderPath = HostingEnvironment.MapPath(LayoutsFolderRelativePath);

                if (!Directory.Exists(layoutsFolderPath))
                {
                    Directory.CreateDirectory(layoutsFolderPath);
                }

                string layoutFilePath = Path.Combine(layoutsFolderPath, layoutFileName);

                if (File.Exists(layoutFilePath))
                {
                    File.Delete(layoutFilePath);
                }

                FeatherServerOperations.ResourcePackages().AddNewResource(FileResource, layoutFilePath);
                FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(initialTemplatesCount, 1);
            }
        }
        public void AddNewLayoutFile()
        {
            AuthenticationHelper.AuthenticateUser(AdminUserName, AdminPass, true);
            string filePath = FeatherServerOperations.ResourcePackages().GetResourcePackageDestinationFilePath(PackageName, LayoutFileName);

            FeatherServerOperations.ResourcePackages().AddNewResource(FileResource, filePath);
        }
예제 #4
0
        public void ResourcePackage_AddNewPackageWithLayoutFiles_VerifyGeneratedTemplates()
        {
            int templatesCount = this.PageManager.GetTemplates().Count();

            try
            {
                FeatherServerOperations.ResourcePackages().AddNewResourcePackage(Constants.PackageResource);
                FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(templatesCount, 3);

                string[] templateTitles = new string[] { Constants.TemplateTestLayout1, Constants.TemplateTestLayout2, Constants.TemplateTestLayout3 };

                foreach (var title in templateTitles)
                {
                    var template = this.PageManager.GetTemplates().Where(t => t.Title == title).FirstOrDefault();
                    Assert.IsNotNull(template, "Template was not found");
                }
            }
            finally
            {
                string[] templates = new string[] { Constants.TemplateTestLayout1, Constants.TemplateTestLayout2, Constants.TemplateTestLayout3 };

                foreach (var template in templates)
                {
                    ServerOperations.Templates().DeletePageTemplate(template);
                }

                string path = FeatherServerOperations.ResourcePackages().GetResourcePackagesDestination(Constants.TestPackageName);
                FeatherServerOperations.ResourcePackages().DeleteDirectory(path);
            }
        }
예제 #5
0
        public void ResourcePackageLayoutFiles_ReplaceLayoutFile_VerifyTemplateAndPage()
        {
            string resourceForReplace         = "Telerik.Sitefinity.Frontend.TestUtilities.Data.LayoutFileReplace.Package1.zip";
            string packageResource            = "Telerik.Sitefinity.Frontend.TestUtilities.Data.Package1.zip";
            string packageName                = "Package1";
            string layoutFile                 = "test-layout.cshtml";
            string backFileName               = "test-layout.cshtml.bac";
            string sitefinityPath             = FeatherServerOperations.ResourcePackages().SfPath;
            string tempFolder                 = "Temp";
            string templateTitle              = "test-layout";
            string layoutTemplateText         = "Package1 - test layout";
            string layoutTemplateTextReplaced = "Package1 - test layout REPLACED";
            string page = "featherpage";

            PageManager pm             = PageManager.GetManager();
            int         templatesCount = pm.GetTemplates().Count();

            string tempFolderPath = Path.Combine(sitefinityPath, tempFolder);

            if (!Directory.Exists(tempFolderPath))
            {
                Directory.CreateDirectory(tempFolderPath);
            }

            string filePath     = FeatherServerOperations.ResourcePackages().GetResourcePackageDestinationFilePath(packageName, layoutFile);
            string packagePath  = FeatherServerOperations.ResourcePackages().GetResourcePackagesDestination(packageName);
            string tempFilePath = Path.Combine(tempFolderPath, packageName, "Mvc", "Views", "Layouts", layoutFile);
            string backFilePath = Path.Combine(packagePath, backFileName);

            try
            {
                FeatherServerOperations.ResourcePackages().AddNewResourcePackage(resourceForReplace, tempFolderPath);
                FeatherServerOperations.ResourcePackages().AddNewResourcePackage(packageResource);
                FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(templatesCount, 1);

                var template = pm.GetTemplates().Where(t => t.Title == templateTitle).FirstOrDefault();
                Assert.IsNotNull(template, "Template was not found");

                Guid pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, page, page);

                string pageContent = FeatherServerOperations.Pages().GetPageContent(pageId);
                Assert.IsTrue(pageContent.Contains(layoutTemplateText), "Layout template text was not found in the page content");

                File.Replace(tempFilePath, filePath, backFilePath);

                Thread.Sleep(1000);

                pageContent = FeatherServerOperations.Pages().GetPageContent(pageId);

                Assert.AreEqual(pm.GetTemplates().Count(), templatesCount + 1, "Unnecessary template was generated");
                Assert.IsTrue(pageContent.Contains(layoutTemplateTextReplaced), "New layout text was not found in the page content after replace");
            }
            finally
            {
                ServerOperations.Pages().DeleteAllPages();
                ServerOperations.Templates().DeletePageTemplate(templateTitle);
                FeatherServerOperations.ResourcePackages().DeleteDirectory(packagePath);
                FeatherServerOperations.ResourcePackages().DeleteDirectory(tempFolderPath);
            }
        }
예제 #6
0
        public void ResourcePackageLayoutFiles_CreateTemplateAndAddLayoutFile_VerifyPublicPage()
        {
            string packageName            = "TestPackageNoLayouts";
            string packageResource        = "Telerik.Sitefinity.Frontend.TestUtilities.Data.TestPackageNoLayouts.zip";
            string layoutName             = "TestLayout.cshtml";
            string layoutResource         = "Telerik.Sitefinity.Frontend.TestUtilities.Data.TestLayout.cshtml";
            string templateTitle          = "TestPackageNoLayouts.TestLayout";
            string pageTitle              = "FeatherTestPage";
            string testLayoutTemplateText = "Test Layout";

            string packagePath = FeatherServerOperations.ResourcePackages().GetResourcePackagesDestination(packageName);

            FeatherServerOperations.ResourcePackages().AddNewResourcePackage(packageResource);

            try
            {
                var  templateId = FeatherServerOperations.Pages().CreatePureMvcTemplate(templateTitle);
                Guid pageId     = ServerOperations.Pages().CreatePage(pageTitle, templateId);

                var filePath = Path.Combine(packagePath, "MVC", "Views", "Layouts", layoutName);
                FeatherServerOperations.ResourcePackages().AddNewResource(layoutResource, filePath);

                var nodeId      = ServerOperations.Pages().GetPageNodeId(pageId);
                var pageContent = FeatherServerOperations.Pages().GetPageContent(nodeId);
                Assert.IsTrue(pageContent.Contains(testLayoutTemplateText), "Layout text was not found on the page");
            }
            finally
            {
                ServerOperations.Pages().DeleteAllPages();
                ServerOperations.Templates().DeletePageTemplate(templateTitle);
                FeatherServerOperations.ResourcePackages().DeleteDirectory(packagePath);
            }
        }
        public void SetUp()
        {
            AuthenticationHelper.AuthenticateUser(AdminUserName, AdminPass, true);

            string templateFileOriginal = FileInjectHelper.GetDestinationFilePath(this.layoutTemplatePath);
            string templateFileCopy     = FileInjectHelper.GetDestinationFilePath(this.newLayoutTemplatePath);

            PageManager pageManager    = PageManager.GetManager();
            int         templatesCount = pageManager.GetTemplates().Count();

            File.Copy(templateFileOriginal, templateFileCopy);
            FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(templatesCount, 1);

            string filePath = FileInjectHelper.GetDestinationFilePath(this.gridPath);

            Directory.CreateDirectory(Path.GetDirectoryName(filePath));
            Stream destination = new FileStream(filePath, FileMode.Create, FileAccess.Write);

            var    assembly = FileInjectHelper.GetArrangementsAssembly();
            Stream source   = assembly.GetManifestResourceStream(FileResource);

            FileInjectHelper.CopyStream(source, destination);
            source.Close();
            destination.Close();

            Guid templateId = ServerOperations.Templates().GetTemplateIdByTitle(PageTemplateName);

            ServerOperations.Pages().CreatePage(PageName, templateId);
        }
예제 #8
0
        public void FoundationResourcePackage_AddNewLayoutFile_VerifyGeneratedTemplateAndCreatedPageContent()
        {
            int templatesCount = this.PageManager.GetTemplates().Count();

            try
            {
                string filePath = FeatherServerOperations.ResourcePackages().GetResourcePackageDestinationFilePath(Constants.PackageName, Constants.LayoutFileName);
                FeatherServerOperations.ResourcePackages().AddNewResource(Constants.LayoutFileResource, filePath);

                FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(templatesCount, 1);

                var template = this.PageManager.GetTemplates().Where(t => t.Title == Constants.TemplateTitle).FirstOrDefault();
                Assert.IsNotNull(template, "Template was not found");

                Guid pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, Constants.PageTitle, Constants.PageUrl);

                var page    = this.PageManager.GetPageNode(pageId);
                var pageUrl = page.GetFullUrl();
                pageUrl = RouteHelper.GetAbsoluteUrl(pageUrl);

                string pageContent = WebRequestHelper.GetPageWebContent(pageUrl);
                Assert.IsTrue(pageContent.Contains(Constants.LayoutTemplateText), "Layout template text was not found in the page content");
            }
            finally
            {
                ServerOperations.Pages().DeletePage(Constants.PageTitle);
                ServerOperations.Templates().DeletePageTemplate(Constants.TemplateTitle);

                string filePath = FeatherServerOperations.ResourcePackages().GetResourcePackageDestinationFilePath(Constants.PackageName, Constants.LayoutFileName);
                File.Delete(filePath);
            }
        }
예제 #9
0
        public void ResourcePackageLayoutFiles_DeleteTemplateBasedOnLayoutFile_VerifyLayoutFileExistsAndNoTemplateGenerated()
        {
            int    templatesCount = this.PageManager.GetTemplates().Count();
            string adminUserName  = "******";
            string adminPass      = "******";

            try
            {
                FeatherServerOperations.ResourcePackages().AddNewResourcePackage(Constants.PackageResource);
                FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(templatesCount, 3);

                AuthenticationHelper.AuthenticateUser(adminUserName, adminPass, true);
                ServerOperations.Templates().DeletePageTemplate(Constants.TemplateTestLayout1);

                string layoutFile = FeatherServerOperations.ResourcePackages().GetResourcePackageDestinationFilePath(Constants.TestPackageName, Constants.TestLayoutFileName);
                Assert.IsNotNull(layoutFile, "The layout file was not found after the template was deleted.");

                int newCount = this.PageManager.GetTemplates().Count();
                Assert.AreEqual(templatesCount + 2, newCount);
            }
            finally
            {
                AuthenticationHelper.AuthenticateUser(adminUserName, adminPass, true);
                ServerOperations.Templates().DeletePageTemplate(Constants.TemplateTestLayout2);
                ServerOperations.Templates().DeletePageTemplate(Constants.TemplateTestLayout3);

                string path = FeatherServerOperations.ResourcePackages().GetResourcePackagesDestination(Constants.TestPackageName);
                FeatherServerOperations.ResourcePackages().DeleteDirectory(path);
            }
        }
예제 #10
0
        public void LayoutTemplates_CreateTemplateAndAddLayoutFile_VerifyTemplateBasedOnLayout()
        {
            var folderPath = Path.Combine(this.SfPath, "MVC", "Views", "Layouts");

            try
            {
                var  templateId = ServerOperations.Templates().CreatePureMVCPageTemplate(TemplateTitle);
                Guid pageId     = ServerOperations.Pages().CreatePage(PageTitle, templateId);

                if (!Directory.Exists(folderPath))
                {
                    Directory.CreateDirectory(folderPath);
                }

                string filePath = Path.Combine(folderPath, LayoutFileName);

                FeatherServerOperations.ResourcePackages().AddNewResource(LayoutFileResource, filePath);

                var nodeId      = ServerOperations.Pages().GetPageNodeId(pageId);
                var pageContent = FeatherServerOperations.Pages().GetPageContent(nodeId);
                Assert.IsTrue(pageContent.Contains(TestLayoutTemplateText), "Layout text was not found on the page");
            }
            finally
            {
                ServerOperations.Pages().DeleteAllPages();
                ServerOperations.Templates().DeletePageTemplate(TemplateTitle);

                var filePath = Path.Combine(folderPath, LayoutFileName);
                File.Delete(filePath);
            }
        }
예제 #11
0
        public void TearDown()
        {
            ServerOperations.Templates().DeletePageTemplate(TemplateTitle);

            string filePath = FeatherServerOperations.ResourcePackages().GetResourcePackageDestinationFilePath(PackageName, LayoutFileName);

            File.Delete(filePath);
        }
        public void TearDown()
        {
            ServerOperations.Pages().DeleteAllPages();
            ServerOperations.News().DeleteAllNews();
            ServerOperations.Taxonomies().ClearAllTags(TaxonomiesConstants.TagsTaxonomyId);

            FeatherServerOperations.ResourcePackages().DeleteSelectorsData(DesignerViewFileName, JsonFileName, null);
        }
예제 #13
0
        public void TearDown()
        {
            ServerOperations.Pages().DeleteAllPages();
            ServerOperations.DynamicTypes().DeleteAllDynamicItemsForAllModules();
            ServerOperations.ModuleBuilder().DeleteAllModules(string.Empty, "Module Installations");

            FeatherServerOperations.ResourcePackages().DeleteSelectorsData(DesignerViewFileName, JsonFileName, ControllerFileName);
        }
예제 #14
0
        public void LayoutTemplates_ReplaceLayoutFile_VerifyGeneratedTemplateAndCreatedPageContent()
        {
            PageManager pageManager    = PageManager.GetManager();
            int         templatesCount = pageManager.GetTemplates().Count();

            string folderPath = Path.Combine(this.SfPath, "MVC", "Views", "Layouts");

            if (!Directory.Exists(folderPath))
            {
                Directory.CreateDirectory(folderPath);
            }

            string tempFolderPath = Path.Combine(this.SfPath, "MVC", "Views", "Temp");

            if (!Directory.Exists(tempFolderPath))
            {
                Directory.CreateDirectory(tempFolderPath);
            }

            string newLayoutTemplateText = "Test Layout Replaced";
            string layoutResource        = "Telerik.Sitefinity.Frontend.TestUtilities.Data.LayoutFileReplace.TestLayout.cshtml";
            string backFileName          = "TestLayout.cshtml.bac";
            string filePath     = Path.Combine(folderPath, LayoutFileName);
            string tempFilePath = Path.Combine(tempFolderPath, LayoutFileName);
            string backFilePath = Path.Combine(folderPath, backFileName);

            try
            {
                FeatherServerOperations.ResourcePackages().AddNewResource(LayoutFileResource, filePath);
                FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(templatesCount, 1);

                var template = pageManager.GetTemplates().Where(t => t.Title == TemplateTitle).FirstOrDefault();
                Assert.IsNotNull(template, "Template was not found");

                Guid pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, PageTitle, PageUrl);

                string pageContent = FeatherServerOperations.Pages().GetPageContent(pageId);
                Assert.IsTrue(pageContent.Contains(LayoutTemplateText), "Layout template text was not found in the page content");

                FeatherServerOperations.ResourcePackages().AddNewResource(layoutResource, tempFilePath);
                File.Replace(tempFilePath, filePath, backFilePath);

                Thread.Sleep(1000);

                pageContent = FeatherServerOperations.Pages().GetPageContent(pageId);

                Assert.AreEqual(pageManager.GetTemplates().Count(), templatesCount + 1, "Unnecessary template was generated");
                Assert.IsTrue(pageContent.Contains(newLayoutTemplateText), "New layout text was not found in the page content after replace");
            }
            finally
            {
                ServerOperations.Pages().DeleteAllPages();
                ServerOperations.Templates().DeletePageTemplate(TemplateTitle);
                File.Delete(filePath);
                File.Delete(backFilePath);
                FeatherServerOperations.ResourcePackages().DeleteDirectory(tempFolderPath);
            }
        }
예제 #15
0
        public void ResourcePackage_ReplaceExistingPackage_VerifyNewTemplatesGenerated()
        {
            string packageName        = "Package1";
            string packageResource    = "Telerik.Sitefinity.Frontend.TestUtilities.Data.Package1.zip";
            string templateTitle      = "Package1.test-layout";
            string newPackageResource = "Telerik.Sitefinity.Frontend.TestUtilities.Data.ReplaceTest.Package1.zip";
            string newTemplateTitle   = "Package1.replace-test";
            string tempFolder         = "Temp";
            string packagesFolder     = "ResourcePackages";
            string sitefinityPath     = FeatherServerOperations.ResourcePackages().SfPath;

            PageManager pm = PageManager.GetManager();

            int templatesCount = pm.GetTemplates().Count();

            FeatherServerOperations.ResourcePackages().AddNewResourcePackage(packageResource);
            FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(templatesCount, 1);

            var template = pm.GetTemplates().FirstOrDefault(t => t.Name == templateTitle);

            Assert.IsNotNull(template, "Template was not found");

            var packagePath = Path.Combine(sitefinityPath, packagesFolder, packageName);

            string tempFolderPath = Path.Combine(sitefinityPath, tempFolder);

            if (!Directory.Exists(tempFolderPath))
            {
                Directory.CreateDirectory(tempFolderPath);
            }

            try
            {
                FeatherServerOperations.ResourcePackages().AddNewResourcePackage(newPackageResource, tempFolder);

                var tempPath = Path.Combine(sitefinityPath, tempFolder, packageName);

                DirectoryInfo originalPackage = new DirectoryInfo(packagePath);
                DirectoryInfo newPackage      = new DirectoryInfo(tempPath);

                MergeFolders(newPackage, originalPackage);

                FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(templatesCount, 2);
                Assert.IsTrue(pm.GetTemplates().Count().Equals(templatesCount + 2), "templates count is not correct");

                var newTemplate = pm.GetTemplates().FirstOrDefault(t => t.Name == newTemplateTitle);
                Assert.IsNotNull(newTemplate, "New template was not found");
            }
            finally
            {
                ServerOperations.Templates().DeletePageTemplate(templateTitle);
                ServerOperations.Templates().DeletePageTemplate(newTemplateTitle);
                FeatherServerOperations.ResourcePackages().DeleteDirectory(tempFolderPath);
                FeatherServerOperations.ResourcePackages().DeleteDirectory(packagePath);
            }
        }
        public void TemplateHierarchy_EditWidget_ShouldLogCompilation()
        {
            Guid templateId1 = default(Guid);
            Guid templateId2 = default(Guid);

            var    widgetName         = "News";
            var    widgetTemplateName = "List.NewsList.cshtml";
            var    widgetText         = @"<ul class=""list-unstyled"">";
            var    widgetTextEdited   = @"<ul class=""list-unstyled"">edited";
            string widgetFilePath     = FeatherServerOperations.ResourcePackages().GetResourcePackageMvcViewDestinationFilePath(ResourcePackages.Bootstrap, widgetName, widgetTemplateName);

            PageNode pageNode = null;

            try
            {
                pageNode = this.CreatePageTemplateHierarchy(ref templateId1, ref templateId2);
                var fullPageUrl = RouteHelper.GetAbsoluteUrl(pageNode.GetUrl());

                var viewPath     = "~/Frontend-Assembly/Telerik.Sitefinity.Frontend.News/Mvc/Views/News/List.NewsList.cshtml";
                var fullViewPath = string.Concat(viewPath, "#Bootstrap.cshtml");

                // Request page
                this.ClearData();
                this.ExecuteAuthenticatedRequest(fullPageUrl);
                this.FlushData();

                this.ClearData();
                FeatherServerOperations.ResourcePackages().EditLayoutFile(widgetFilePath, widgetText, widgetTextEdited);
                this.WaitForAspNetCacheToBeInvalidated(fullViewPath);

                this.ExecuteAuthenticatedRequest(fullPageUrl);
                this.FlushData();

                this.AssertWidgetExecutionCount(3);
                this.AssertViewCompilationCount(1);

                var rootOperationId = this.GetRequestLogRootOperationId(fullPageUrl);

                var widgetCompilationText = "Compile view \"List.NewsList.cshtml#Bootstrap.cshtml\" of controller \"" + typeof(NewsController).FullName + "\"";
                this.AssertViewCompilationParams(rootOperationId, viewPath, widgetCompilationText);

                this.ClearData();
                this.ExecuteAuthenticatedRequest(fullPageUrl);
                this.FlushData();

                this.AssertWidgetExecutionCount(3);
                this.AssertViewCompilationCount(0);
            }
            finally
            {
                FeatherServerOperations.ResourcePackages().EditLayoutFile(widgetFilePath, widgetTextEdited, widgetText);
                this.DeletePages(pageNode);
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Templates().DeletePageTemplate(templateId2);
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Templates().DeletePageTemplate(templateId1);
            }
        }
예제 #17
0
        private void CreateLayoutFolderAndCopyLayoutFile()
        {
            PageManager pageManager    = PageManager.GetManager();
            int         templatesCount = pageManager.GetTemplates().Count();

            string filePath = this.GetFilePath();

            FeatherServerOperations.ResourcePackages().AddNewResource(FileResource, filePath);
            FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(templatesCount, 1);
        }
        public void TearDown()
        {
            AuthenticationHelper.AuthenticateUser(AdminUserName, AdminPass, true);

            ServerOperations.Templates().DeletePageTemplate(TemplateTitle);

            string filePath = FeatherServerOperations.ResourcePackages().GetResourcePackageDestinationFilePath(PackageName, LayoutFileName);

            File.Delete(filePath);
        }
        public void SetUp()
        {
            string templateFileOriginal = FileInjectHelper.GetDestinationFilePath(this.layoutTemplatePath);
            string templateFileCopy     = FileInjectHelper.GetDestinationFilePath(this.newLayoutTemplatePath);

            PageManager pageManager    = PageManager.GetManager();
            int         templatesCount = pageManager.GetTemplates().Count();

            File.Copy(templateFileOriginal, templateFileCopy);
            FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(templatesCount, 1);
        }
예제 #20
0
        public void ResourcePackage_DeleteResourcePackage_VerifyTemplateAndPageNotBasedOnLayout()
        {
            string pageName        = "FeatherPage" + Guid.NewGuid().ToString();
            string packageName     = "Package1";
            string packageResource = "Telerik.Sitefinity.Frontend.TestUtilities.Data.Package1.zip";
            string templateTitle   = "Package1.test-layout";
            string layoutText      = "Package1 - test layout";
            string serverErrorMsg  = "Server Error";

            PageManager pm     = PageManager.GetManager();
            Guid        pageId = ServerOperations.Pages().CreatePage(pageName);

            int templatesCount = pm.GetTemplates().Count();

            FeatherServerOperations.ResourcePackages().AddNewResourcePackage(packageResource);
            FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(templatesCount, 1);

            var template = pm.GetTemplates().FirstOrDefault(t => t.Name == templateTitle);

            Assert.IsNotNull(template, "Template was not found");

            string path = FeatherServerOperations.ResourcePackages().GetResourcePackagesDestination(packageName);

            try
            {
                ServerOperations.Templates().SetTemplateToPage(pageId, template.Id);

                var content = FeatherServerOperations.Pages().GetPageContent(pageId);
                Assert.IsTrue(content.Contains(layoutText), "Template is not based on the layout file");

                FeatherServerOperations.ResourcePackages().DeleteDirectory(path);

                if (Directory.Exists(path))
                {
                    throw new ArgumentException("Directory was not deleted");
                }

                Thread.Sleep(1000);

                content = FeatherServerOperations.Pages().GetPageContent(pageId);
                Assert.IsFalse(content.Contains(serverErrorMsg), "Server Error was found on the page.");
                Assert.IsFalse(content.Contains(layoutText), "Template is still based on the layout file after package is deleted");
            }
            finally
            {
                ServerOperations.Pages().DeleteAllPages();
                ServerOperations.Templates().DeletePageTemplate(templateTitle);

                if (Directory.Exists(path))
                {
                    FeatherServerOperations.ResourcePackages().DeleteDirectory(path);
                }
            }
        }
예제 #21
0
        public void TearDown()
        {
            ServerOperations.Pages().DeleteAllPages();

            string filePath = FeatherServerOperations.ResourcePackages().GetResourcePackageMvcViewDestinationFilePath(PackageName, WidgetName, ViewFileName);

            FileInfo      fi = new FileInfo(filePath);
            DirectoryInfo di = fi.Directory;

            FeatherServerOperations.ResourcePackages().DeleteDirectory(di.FullName);
        }
예제 #22
0
        public void ResourcePackageLayoutFiles_DeleteLayoutFile_VerifyTemplateAndPageNotBasedToLayout()
        {
            int templatesCount = this.PageManager.GetTemplates().Count();

            try
            {
                FeatherServerOperations.ResourcePackages().AddNewResourcePackage(Constants.PackageResource);
                FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(templatesCount, 3);

                var template = this.PageManager.GetTemplates().Where(t => t.Title == Constants.TemplateTestLayout1).FirstOrDefault();

                if (template == null)
                {
                    throw new ArgumentException("template not found");
                }

                Guid pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, Constants.PageTitle, Constants.PageUrl);

                var page    = this.PageManager.GetPageNode(pageId);
                var pageUrl = page.GetFullUrl();
                pageUrl = RouteHelper.GetAbsoluteUrl(pageUrl);

                var pageContent = WebRequestHelper.GetPageWebContent(pageUrl);
                Assert.IsTrue(pageContent.Contains(Constants.TestLayout1TemplateText), "Layout template text was not found in the page content");

                string filePath = FeatherServerOperations.ResourcePackages().GetResourcePackageDestinationFilePath(Constants.TestPackageName, Constants.TestLayoutFileName);
                File.Delete(filePath);

                template = this.PageManager.GetTemplates().Where(t => t.Title == Constants.TemplateTestLayout1).FirstOrDefault();
                Assert.IsNotNull(template, "Template was not found after layout file was deleted.");

                this.PublishPage(page);
                pageContent = WebRequestHelper.GetPageWebContent(pageUrl);

                Assert.IsFalse(pageContent.Contains(Constants.ServerErrorMessage), "Page throws a server error message");
                Assert.IsFalse(pageContent.Contains(Constants.TestLayout1TemplateText), "Layout template text was found in the page content");
            }
            finally
            {
                string[] templates = new string[] { Constants.TemplateTestLayout1, Constants.TemplateTestLayout2, Constants.TemplateTestLayout3 };

                ServerOperations.Pages().DeletePage(Constants.PageTitle);

                foreach (var template in templates)
                {
                    ServerOperations.Templates().DeletePageTemplate(template);
                }

                string path = FeatherServerOperations.ResourcePackages().GetResourcePackagesDestination(Constants.TestPackageName);
                Directory.Delete(path, true);
            }
        }
예제 #23
0
        public void LayoutTemplates_EditLayoutFile_VerifyGeneratedTemplateAndCreatedPageContent()
        {
            PageManager pageManager    = PageManager.GetManager();
            int         templatesCount = pageManager.GetTemplates().Count();

            var folderPath = Path.Combine(this.SfPath, "MVC", "Views", "Layouts");

            try
            {
                if (!Directory.Exists(folderPath))
                {
                    Directory.CreateDirectory(folderPath);
                }

                string filePath = Path.Combine(folderPath, LayoutFileName);

                FeatherServerOperations.ResourcePackages().AddNewResource(LayoutFileResource, filePath);

                FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(templatesCount, 1);

                var template = pageManager.GetTemplates().Where(t => t.Title == TemplateTitle).FirstOrDefault();
                Assert.IsNotNull(template, "Template was not found");

                Guid pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, PageTitle, PageUrl);

                var page    = pageManager.GetPageNode(pageId);
                var pageUrl = page.GetFullUrl();
                pageUrl = RouteHelper.GetAbsoluteUrl(pageUrl);

                string pageContent = WebRequestHelper.GetPageWebContent(pageUrl);
                Assert.IsTrue(pageContent.Contains(LayoutTemplateText), "Layout template text was not found in the page content");

                string layoutFile = Path.Combine(folderPath, LayoutFileName);
                FeatherServerOperations.ResourcePackages().EditLayoutFile(layoutFile, TestLayoutTemplateText, TestLayoutTemplateTextEdited);

                Thread.Sleep(1000);

                pageContent = WebRequestHelper.GetPageWebContent(pageUrl);

                Assert.IsFalse(pageContent.Contains(ServerErrorMessage), "Page throws a server error message");
                Assert.IsFalse(pageContent.Contains(TestLayoutTemplateText), "Layout template text was found in the page content");
                Assert.IsTrue(pageContent.Contains(TestLayoutTemplateTextEdited), "New layout text was not found in the page content");
            }
            finally
            {
                ServerOperations.Pages().DeleteAllPages();
                ServerOperations.Templates().DeletePageTemplate(TemplateTitle);

                var filePath = Path.Combine(folderPath, LayoutFileName);
                File.Delete(filePath);
            }
        }
예제 #24
0
        private string GetFilePath()
        {
            string folderPath = Path.Combine(FeatherServerOperations.ResourcePackages().SfPath, "MVC", "Views", "Layouts");

            if (!Directory.Exists(folderPath))
            {
                Directory.CreateDirectory(folderPath);
            }

            string filePath = Path.Combine(folderPath, LayoutFileName);

            return(filePath);
        }
예제 #25
0
        public void SetUp()
        {
            for (int i = 0; i < 20; i++)
            {
                ServerOperations.News().CreatePublishedNewsItem(newsTitle: NewsItemTitle + i, newsContent: NewsItemContent + i, author: NewsItemAuthor + i);
            }

            Guid pageId = ServerOperations.Pages().CreatePage(PageName);

            FeatherServerOperations.ResourcePackages().ImportDataForSelectorsTests(FileResource, DesignerViewFileName, FileResourceJson, JsonFileName, ControllerFileResource, ControllerFileName);

            ServerOperations.Widgets().AddMvcWidgetToPage(pageId, typeof(DummyTextController).FullName, WidgetCaption);
        }
예제 #26
0
        public void SetUp()
        {
            for (int i = 0; i < TagsCount; i++)
            {
                ServerOperations.Taxonomies().CreateTag(TagTitle + i);
            }

            FeatherServerOperations.ResourcePackages().ImportDataForSelectorsTests(FileResource, DesignerViewFileName, FileResourceJson, JsonFileName, ControllerFileResource, ControllerFileName);

            Guid pageId = ServerOperations.Pages().CreatePage(PageName);

            MvcServerOperations.Widgets().AddMvcWidgetToPage(pageId, typeof(DummyTextController).FullName, WidgetCaption);
        }
예제 #27
0
        public void AddNewViewToLayoutsFolder()
        {
            var folderPath = Path.Combine(this.SfPath, "Mvc", "Views", WidgetName);

            if (!Directory.Exists(folderPath))
            {
                Directory.CreateDirectory(folderPath);
            }

            string filePath = Path.Combine(folderPath, ViewFileName);

            FeatherServerOperations.ResourcePackages().AddNewResource(LayoutFileResource, filePath);
        }
예제 #28
0
        public void ResourcePackageLayoutFiles_RenameTemplateBasedOnLayoutFile_VerifyTemplateAndPage()
        {
            int templatesCount = this.PageManager.GetTemplates().Count();

            try
            {
                FeatherServerOperations.ResourcePackages().AddNewResourcePackage(Constants.PackageResource);
                FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(templatesCount, 3);

                var template = this.PageManager.GetTemplates().Where(t => t.Title == Constants.TemplateTestLayout1).FirstOrDefault();

                if (template == null)
                {
                    throw new ArgumentException("template not found");
                }

                Guid pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, Constants.PageTitle, Constants.PageUrl);

                var page    = this.PageManager.GetPageNode(pageId);
                var pageUrl = page.GetFullUrl();
                pageUrl = RouteHelper.GetAbsoluteUrl(pageUrl);

                var pageContent = WebRequestHelper.GetPageWebContent(pageUrl);
                Assert.IsTrue(pageContent.Contains(Constants.TestLayout1TemplateText), "Layout template text was not found in the page content");

                template.Title = Constants.TemplateRenamed;
                template.Name  = Constants.TemplateRenamed;
                this.pageManager.SaveChanges();

                Thread.Sleep(1000);

                pageContent = WebRequestHelper.GetPageWebContent(pageUrl);

                Assert.IsFalse(pageContent.Contains(Constants.ServerErrorMessage), "Page throws a server error message");
                Assert.IsFalse(pageContent.Contains(Constants.TestLayout1TemplateText), "Layout template text was found in the page content");
            }
            finally
            {
                string[] templates = new string[] { Constants.TemplateRenamed, Constants.TemplateTestLayout2, Constants.TemplateTestLayout3 };

                ServerOperations.Pages().DeleteAllPages();

                foreach (var template in templates)
                {
                    ServerOperations.Templates().DeletePageTemplate(template);
                }

                string path = FeatherServerOperations.ResourcePackages().GetResourcePackagesDestination(Constants.TestPackageName);
                FeatherServerOperations.ResourcePackages().DeleteDirectory(path);
            }
        }
예제 #29
0
        public void GridWidget_EditGridWidgetOnPageTemplateFromFileSystem()
        {
            string templateTitle = "Bootstrap.defaultNew";

            PageManager pageManager = PageManager.GetManager();

            var gridVirtualPath     = "~/ResourcePackages/Bootstrap/GridSystem/Templates/grid-9+3.html";
            var gridTemplatePath    = Path.Combine(this.SfPath, "ResourcePackages", "Bootstrap", "GridSystem", "Templates", "grid-9+3.html");
            var newGridTemplatePath = Path.Combine(this.SfPath, "ResourcePackages", "Bootstrap", "GridSystem", "Templates", "grid-9+3-New.html");

            File.Copy(gridTemplatePath, newGridTemplatePath);

            int templatesCount = pageManager.GetTemplates().Count();

            var layoutTemplatePath    = Path.Combine(this.SfPath, "ResourcePackages", "Bootstrap", "MVC", "Views", "Layouts", "default.cshtml");
            var newLayoutTemplatePath = Path.Combine(this.SfPath, "ResourcePackages", "Bootstrap", "MVC", "Views", "Layouts", "defaultNew.cshtml");

            File.Copy(layoutTemplatePath, newLayoutTemplatePath);

            FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(templatesCount, 1);

            var template = pageManager.GetTemplates().Where(t => t.Title == templateTitle).FirstOrDefault();

            Assert.IsNotNull(template, "Template was not found");

            try
            {
                this.AddGridControlToPageTemplate(template.Id, gridVirtualPath, PlaceHolder, Caption);

                Guid pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, PageNamePrefix, UrlNamePrefix);

                using (StreamWriter output = File.AppendText(gridTemplatePath))
                {
                    output.WriteLine(GridTextEdited);
                }

                string pageContent = this.GetPageContent(pageId);

                Assert.IsTrue(pageContent.Contains(Row3), "Grid row not found in the page content");
                Assert.IsTrue(pageContent.Contains(Row9), "Grid row not found in the page content");
                Assert.IsTrue(pageContent.Contains(ParagraphText), "Grid row not found in the page content");
            }
            finally
            {
                File.Delete(gridTemplatePath);
                File.Move(newGridTemplatePath, gridTemplatePath);
                File.Delete(newLayoutTemplatePath);
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages();
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Templates().DeletePageTemplate(template.Id);
            }
        }
예제 #30
0
        public void TearDown()
        {
            ServerOperations.Pages().DeleteAllPages();
            ServerOperations.Templates().DeletePageTemplate(Template1Title);
            ServerOperations.Templates().DeletePageTemplate(Template2Title);

            string path1 = FeatherServerOperations.ResourcePackages().GetResourcePackagesDestination(Package1Name);

            FeatherServerOperations.ResourcePackages().DeleteDirectory(path1);

            string path2 = FeatherServerOperations.ResourcePackages().GetResourcePackagesDestination(Package2Name);

            FeatherServerOperations.ResourcePackages().DeleteDirectory(path2);
        }