コード例 #1
0
        public void RegisterScript_PureMvcPage_AddedOnce()
        {
            string testName  = "RegisterScript";
            string pageTitle = testName + "PureMvcPage";
            string urlName   = testName + "PureMvcPage";
            string pageUrl   = UrlPath.ResolveAbsoluteUrl("~/" + urlName);

            var pageManger = PageManager.GetManager();
            var template   = pageManger.GetTemplates().Where(t => t.Title == "Foundation.default").FirstOrDefault();

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

            this.AddDummyScriptControllerToPage(pageTitle, urlName, template, "Contentplaceholder1");

            WebRequestHelper.GetPageWebContent(pageUrl);

            Assert.AreEqual(2, ActionExecutionRegister.ExecutedActionInfos.Count, "The actions are not executed correctly.");

            var result1 = ActionExecutionRegister.ExecutedActionInfos[0].Result as ContentResult;

            Assert.IsTrue(Regex.IsMatch(result1.Content, "<script src=\".*\" type=\"text/javascript\"></script>"), "The script is not added.");

            var result2 = ActionExecutionRegister.ExecutedActionInfos[1].Result as ContentResult;

            Assert.IsTrue(string.IsNullOrEmpty(result2.Content), "The script should not be added twice.");
        }
コード例 #2
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);
            }
        }
コード例 #3
0
        public void CreatePageWithDescription_RenderPage_CheckDescription()
        {
            var    testName       = System.Reflection.MethodInfo.GetCurrentMethod().Name;
            var    pageName       = testName + "MvcPage";
            var    pageTitle      = testName + "Mvc Page";
            var    urlName        = testName + "mvc-page";
            var    description    = "customdescription1";
            var    descriptionTag = "<meta name=\"description\" content=\"customdescription1\" />";
            string url            = UrlPath.ResolveAbsoluteUrl("~/" + urlName);

            using (var contentGenerator = new PageContentGenerator())
            {
                var pageId      = contentGenerator.CreatePage(pageName, pageTitle, urlName);
                var pageManager = PageManager.GetManager();
                var page        = pageManager.GetPageNode(pageId);
                page.Description = description;
                page.GetPageData().Description = description;
                pageManager.SaveChanges();

                string responseContent = WebRequestHelper.GetPageWebContent(url);

                var responseContentDescriptionTagsCount = Regex.Matches(responseContent, descriptionTag).Count;
                Assert.IsTrue(responseContentDescriptionTagsCount == 1, "The response content does not contain description meta tag exactly once.");
            }
        }
コード例 #4
0
        public string GetPageContent(Guid pageId, bool authenticated, string suffixUrl)
        {
            PageManager pageManager = PageManager.GetManager();

            var page    = pageManager.GetPageNode(pageId);
            var pageUrl = page.GetFullUrl(SystemManager.CurrentContext.AppSettings.DefaultFrontendLanguage, true);

            pageUrl = RouteHelper.GetAbsoluteUrl(pageUrl);

            if (!string.IsNullOrWhiteSpace(suffixUrl))
            {
                pageUrl = Sitefinity.Web.Url.Combine(pageUrl, suffixUrl);
            }

            pageUrl = UrlTransformations.AppendParam(pageUrl, "t", Guid.NewGuid().ToString());

            string pageContent = WebRequestHelper.GetPageWebContent(
                pageUrl,
                null,
                (HttpClient client) =>
            {
                if (authenticated)
                {
                    client.DefaultHeaders["Authorization"] = HttpContext.Current.Request.Headers["Authorization"];
                    client.TransportSettings.Cookies       = new System.Net.CookieContainer();
                    client.TransportSettings.CachePolicy   = new System.Net.Cache.HttpRequestCachePolicy();
                }
            });

            return(pageContent);
        }
コード例 #5
0
        public void EventWidget_AllEvents_DisplayAll()
        {
            var methodName = MethodInfo.GetCurrentMethod().Name;

            try
            {
                this.BuildEvents(methodName);

                var eventController = new EventController();
                eventController.Model.DisplayMode   = ListDisplayMode.Paging;
                eventController.Model.SelectionMode = SelectionMode.AllItems;

                var mvcProxy = new MvcControllerProxy()
                {
                    Settings = new ControllerSettings(eventController), ControllerName = typeof(EventController).FullName
                };
                var containedEvents = new string[] { CurrentEventNameFormat, NextWeekEventNameFormat, NextMonthEventNameFormat, PreviousMonthEventNameFormat, PreviousWeekEventNameFormat }.Select(s => string.Format(CultureInfo.InvariantCulture, s, methodName));

                using (var generator = new PageContentGenerator())
                {
                    generator.CreatePageWithWidget(mvcProxy, null, methodName, methodName, methodName, 0);
                    var pageContent = WebRequestHelper.GetPageWebContent(RouteHelper.GetAbsoluteUrl("~/" + methodName + "0"));

                    foreach (var title in containedEvents)
                    {
                        Assert.Contains(pageContent, title, StringComparison.Ordinal);
                    }
                }
            }
            finally
            {
                ServerOperations.Events().DeleteAllEvents();
            }
        }
コード例 #6
0
        public void EventWidget_AllEvents_FilterByCalendar()
        {
            var methodName = MethodInfo.GetCurrentMethod().Name;
            var calendarId = ServerOperations.Events().CreateCalendar(Guid.NewGuid(), "custom_calendar");

            ServerOperations.Events().CreateEvent(methodName + "_fromdefault", "some content", false, DateTime.Now, DateTime.Now.AddHours(2), ServerOperations.Events().GetDefaultCalendarId());
            ServerOperations.Events().CreateEvent(methodName + "_fromcustom", "some content", false, DateTime.Now, DateTime.Now.AddHours(2), calendarId);

            try
            {
                var mvcProxy = new MvcControllerProxy();
                mvcProxy.ControllerName = typeof(EventController).FullName;
                var eventController = new EventController();

                eventController.Model.NarrowSelectionMode = Telerik.Sitefinity.Frontend.Mvc.Models.SelectionMode.FilteredItems;
                eventController.Model.SerializedNarrowSelectionFilters = this.GetNarrowSelectionSerializedQueryData("Calendars", "Parent.Id.ToString()", "Parent.Id", calendarId, "System.String");

                mvcProxy.Settings = new ControllerSettings(eventController);

                using (var generator = new PageContentGenerator())
                {
                    generator.CreatePageWithWidget(mvcProxy, null, methodName, methodName, methodName, 0);
                    var pageContent = WebRequestHelper.GetPageWebContent(RouteHelper.GetAbsoluteUrl("~/" + methodName + "0"));

                    Assert.Contains(pageContent, methodName + "_fromcustom", System.StringComparison.Ordinal);
                    Assert.DoesNotContain(pageContent, methodName + "_fromdefault", System.StringComparison.Ordinal);
                }
            }
            finally
            {
                ServerOperations.Events().DeleteAllEvents();
                ServerOperations.Events().DeleteCalendar(calendarId);
            }
        }
コード例 #7
0
            public string GetPageContent()
            {
                var page    = PageManager.GetManager().GetPageNode(this.pageId);
                var pageUrl = page.GetFullUrl();

                pageUrl = RouteHelper.GetAbsoluteUrl(pageUrl);

                return(WebRequestHelper.GetPageWebContent(pageUrl));
            }
コード例 #8
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);
            }
        }
コード例 #9
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);
            }
        }
コード例 #10
0
ファイル: GridWidgetsTests.cs プロジェクト: vmilev/feather
        private string GetPageContent(Guid pageId)
        {
            PageManager pageManager = PageManager.GetManager();

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

            pageUrl = RouteHelper.GetAbsoluteUrl(pageUrl);

            string pageContent = WebRequestHelper.GetPageWebContent(pageUrl);

            return(pageContent);
        }
コード例 #11
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);
            }
        }
コード例 #12
0
        /// <summary>
        /// Gets the public page content.
        /// </summary>
        /// <param name="pageId">The id of the page.</param>
        /// <returns>The page content.</returns>
        public string GetPageContent(Guid pageId)
        {
            PageManager pageManager = PageManager.GetManager();

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

            pageUrl = RouteHelper.GetAbsoluteUrl(pageUrl);
            pageUrl = UrlTransformations.AppendParam(pageUrl, "t", Guid.NewGuid().ToString());

            string pageContent = WebRequestHelper.GetPageWebContent(pageUrl);

            return(pageContent);
        }
コード例 #13
0
ファイル: PagesOperations.cs プロジェクト: vassil/feather
        /// <summary>
        /// Gets the public page content.
        /// </summary>
        /// <param name="pageId">The id of the page.</param>
        /// <returns>The page content.</returns>
        public string GetPageContent(Guid pageId)
        {
            PageManager pageManager = PageManager.GetManager();

            var page    = pageManager.GetPageNode(pageId);
            var pageUrl = page.GetFullUrl(SystemManager.CurrentContext.AppSettings.DefaultFrontendLanguage, true);

            pageUrl = RouteHelper.GetAbsoluteUrl(pageUrl);
            pageUrl = UrlTransformations.AppendParam(pageUrl, "t", Guid.NewGuid().ToString());

            string pageContent = WebRequestHelper.GetPageWebContent(pageUrl);

            return(pageContent);
        }
コード例 #14
0
        public void FormsWidget_LoadingMvcForm_UnpublishPublish()
        {
            var  testName = MethodInfo.GetCurrentMethod().Name;
            var  pageName = testName + "page";
            Guid pageId   = Guid.Empty;
            var  formId   = Guid.Empty;

            try
            {
                var fields = new FeatherWidgets.TestUtilities.CommonOperations.Forms.FormFieldType[]
                {
                    FeatherWidgets.TestUtilities.CommonOperations.Forms.FormFieldType.TextField,
                    FeatherWidgets.TestUtilities.CommonOperations.Forms.FormFieldType.SubmitButton
                };

                formId = ServerOperationsFeather.Forms().CreateFormWithWidgets(fields, "NewForm");
                pageId = ServerOperations.Pages().CreatePage(pageName);
                string url = UrlPath.ResolveAbsoluteUrl("~/" + pageName);
                ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId, FeatherGlobals.FormName, "Body");

                var formManager = FormsManager.GetManager();
                var form        = formManager.GetForms().FirstOrDefault(f => f.Id == formId);

                Assert.IsFalse(form == null, "Testing form is missing");

                var errorMessage = new FormsResources().TheSpecifiedFormNoLongerExists;

                string publishFormPageContentFirst = WebRequestHelper.GetPageWebContent(url);
                Assert.IsFalse(publishFormPageContentFirst.Contains(errorMessage), string.Format(CultureInfo.InvariantCulture, "Unexpected message in page: {0}", errorMessage));

                formManager.UnpublishForm(formId);
                formManager.SaveChanges();
                string unpublishFormPageContent = WebRequestHelper.GetPageWebContent(url);
                Assert.IsTrue(unpublishFormPageContent.Contains(errorMessage), string.Format(CultureInfo.InvariantCulture, "Expected message in page: {0}", errorMessage));

                formManager.PublishForm(form);
                formManager.SaveChanges();
                string publishFormPageContentSecond = WebRequestHelper.GetPageWebContent(url);
                Assert.IsFalse(publishFormPageContentSecond.Contains(errorMessage), string.Format(CultureInfo.InvariantCulture, "Unexpected message in page: {0}", errorMessage));
            }
            finally
            {
                ServerOperations.Pages().DeletePage(pageId);
                FormsModuleCodeSnippets.DeleteForm(formId);
            }
        }
コード例 #15
0
        public void LoginStatus_OnDetailsPage_DoesNotThrowException()
        {
            const string LoginStatusCaption = "login status";
            Guid         newsItemId         = Guid.Parse("4785b751-ce3a-4e5e-ba81-138f8f2a8a09");
            string       testName           = System.Reflection.MethodInfo.GetCurrentMethod().Name;

            var mvcNewsProxy = new MvcControllerProxy();

            mvcNewsProxy.ControllerName = typeof(NewsController).FullName;
            var newsController = new NewsController();

            newsController.OpenInSamePage = true;
            mvcNewsProxy.Settings         = new ControllerSettings(newsController);

            var mvcLoginStatusProxy = new MvcControllerProxy();

            mvcLoginStatusProxy.ControllerName = typeof(LoginStatusController).FullName;

            using (var generator = new PageContentGenerator())
            {
                var pageId = generator.CreatePageWithWidget(mvcNewsProxy, null, testName, testName, testName, 0);
                PageContentGenerator.AddControlToPage(pageId, mvcLoginStatusProxy, LoginStatusCaption);

                string pageUrl     = UrlPath.ResolveAbsoluteUrl("~/" + testName + "0");
                var    newsManager = NewsManager.GetManager();
                try
                {
                    var newsItem = newsManager.CreateNewsItem(newsItemId);
                    newsItem.Title   = testName;
                    newsItem.UrlName = testName;
                    newsManager.Lifecycle.Publish(newsItem);
                    newsManager.SaveChanges();

                    string detailNewsUrl = pageUrl + newsItem.ItemDefaultUrl;
                    var    pageContent   = WebRequestHelper.GetPageWebContent(RouteHelper.GetAbsoluteUrl(detailNewsUrl));

                    Assert.DoesNotContain(pageContent, "Exception occured while executing the controller. Check error logs for details.", StringComparison.Ordinal);
                }
                finally
                {
                    newsManager.Delete(newsManager.GetNewsItem(newsItemId));
                    newsManager.SaveChanges();
                }
            }
        }
コード例 #16
0
        public void EventWidget_AllEvents_FilterByCustomHierarchicalCategories()
        {
            var methodName = MethodInfo.GetCurrentMethod().Name;

            ServerOperations.Events().CreateEvent(methodName + "_notclassified");
            var eventId = ServerOperations.Events().CreateEvent(methodName + "_classified");

            ServerOperations.Taxonomies().CreateHierarchicalTaxonomy("Custom");
            ServerOperations.Taxonomies().CreateHierarchicalTaxon("parent", null, "Custom");
            ServerOperations.Taxonomies().CreateHierarchicalTaxon("child", "parent", "Custom");
            var taxonId = ServerOperations.Taxonomies().CreateHierarchicalTaxon(methodName, "child", "Custom");

            ServerOperations.Events().AssignTaxonToEventItem(eventId, "Category", taxonId);

            try
            {
                var mvcProxy = new MvcControllerProxy();
                mvcProxy.ControllerName = typeof(EventController).FullName;
                var eventController = new EventController();

                eventController.Model.NarrowSelectionMode = Telerik.Sitefinity.Frontend.Mvc.Models.SelectionMode.FilteredItems;
                eventController.Model.SerializedNarrowSelectionFilters = this.GetNarrowSelectionSerializedQueryData("Category", "Category", methodName, taxonId);

                mvcProxy.Settings = new ControllerSettings(eventController);

                using (var generator = new PageContentGenerator())
                {
                    generator.CreatePageWithWidget(mvcProxy, null, methodName, methodName, methodName, 0);
                    var pageContent = WebRequestHelper.GetPageWebContent(RouteHelper.GetAbsoluteUrl("~/" + methodName + "0"));

                    Assert.Contains(pageContent, methodName + "_classified", System.StringComparison.Ordinal);
                    Assert.DoesNotContain(pageContent, methodName + "_notclassified", System.StringComparison.Ordinal);
                }
            }
            finally
            {
                ServerOperations.Events().DeleteAllEvents();
                ServerOperations.Taxonomies().DeleteCategories(methodName, "child", "parent");
                ServerOperations.Taxonomies().DeleteHierarchicalTaxonomy("Custom");
            }
        }
コード例 #17
0
ファイル: ResourceHelperTests.cs プロジェクト: virajs/feather
        public void RegisterScript_PureMvcPage_AddedOnce()
        {
            string testName  = "RegisterScript";
            string pageTitle = testName + "PureMvcPage";
            string urlName   = testName + "PureMvcPage";
            string pageUrl   = UrlPath.ResolveAbsoluteUrl("~/" + urlName);

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

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

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

                this.AddDummyScriptControllerToPage(pageTitle, urlName, template, "TestPlaceHolder");

                WebRequestHelper.GetPageWebContent(pageUrl);

                Assert.AreEqual(2, ActionExecutionRegister.ExecutedActionInfos.Count, "The actions are not executed correctly.");

                var result1 = ActionExecutionRegister.ExecutedActionInfos[0].Result as ContentResult;
                Assert.IsTrue(Regex.IsMatch(result1.Content, "<script src=\".*\" type=\"text/javascript\"></script>"), "The script is not added.");

                var result2 = ActionExecutionRegister.ExecutedActionInfos[1].Result as ContentResult;
                Assert.IsTrue(string.IsNullOrEmpty(result2.Content), "The script should not be added twice.");
            }
            finally
            {
                ServerOperations.Pages().DeleteAllPages();
                ServerOperations.Templates().DeletePageTemplate(ResourcePackages.Constants.TemplateTitle);

                string filePath = FeatherServerOperations.ResourcePackages().GetResourcePackageDestinationFilePath(ResourcePackages.Constants.PackageName, ResourcePackages.Constants.LayoutFileName);
                File.Delete(filePath);
            }
        }
コード例 #18
0
ファイル: RoutingTests.cs プロジェクト: vicjgg/feather
        public void RequestPage_WithAttributeRoutedWidget_RoutedCorrectly()
        {
            using (var contentGenerator = new PageContentGenerator())
            {
                var testName        = MethodInfo.GetCurrentMethod().Name;
                var pageNamePrefix  = testName + "MvcPage";
                var pageTitlePrefix = testName + "Mvc Page";
                var urlNamePrefix   = testName + "mvc-page";
                var index           = 1;

                var mvcProxy = new MvcControllerProxy();
                mvcProxy.ControllerName = typeof(AttributeRoutingTestController).FullName;

                contentGenerator.CreatePageWithWidget(mvcProxy, string.Empty, pageNamePrefix, pageTitlePrefix, urlNamePrefix, 1);

                string url     = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix + index + "/" + AttributeRoutingTestController.RoutePrefix + "/" + AttributeRoutingTestController.RelativeRoute);
                string content = string.Empty;

                Assert.DoesNotThrow(() => content = WebRequestHelper.GetPageWebContent(url), "Could not get the page successfully.");
                Assert.Contains(content, AttributeRoutingTestController.Content, "The correct action was not rendered.");
            }
        }
コード例 #19
0
        private void TestFilterByDate(string methodName, string serializedAdditionalFilters, IEnumerable <string> containedEvents, IEnumerable <string> notContainedEvents)
        {
            try
            {
                this.BuildEvents(methodName);

                var eventController = new EventController();
                eventController.Model.DisplayMode                 = ListDisplayMode.Paging;
                eventController.Model.SelectionMode               = SelectionMode.FilteredItems;
                eventController.Model.NarrowSelectionMode         = SelectionMode.AllItems;
                eventController.Model.SerializedAdditionalFilters = serializedAdditionalFilters;

                var mvcProxy = new MvcControllerProxy()
                {
                    Settings = new ControllerSettings(eventController), ControllerName = typeof(EventController).FullName
                };

                using (var generator = new PageContentGenerator())
                {
                    generator.CreatePageWithWidget(mvcProxy, null, methodName, methodName, methodName, 0);
                    var pageContent = WebRequestHelper.GetPageWebContent(RouteHelper.GetAbsoluteUrl("~/" + methodName + "0"));

                    foreach (var title in containedEvents)
                    {
                        Assert.Contains(pageContent, title, StringComparison.Ordinal);
                    }

                    foreach (var title in notContainedEvents)
                    {
                        Assert.DoesNotContain(pageContent, title, StringComparison.Ordinal);
                    }
                }
            }
            finally
            {
                ServerOperations.Events().DeleteAllEvents();
            }
        }
コード例 #20
0
        public void NavigationWidgetOnPageTemplate_JQueryExist_Navigation_Pills()
        {
            Guid templateId = default(Guid);
            Guid pageId     = Guid.Empty;

            FeatherServerOperations.FeatherModule().EnsureFeatherEnabled();

            try
            {
                templateId = this.templateOperation.DuplicatePageTemplate(OldTemplateName, TemplateName);
                string url      = UrlPath.ResolveAbsoluteUrl("~/" + UrlNamePrefix);
                var    mvcProxy = CreateNavigationController();

                this.templateOperation.AddControlToTemplate(templateId, mvcProxy, PlaceHolder, CaptionNavigation);
                pageId = this.locationGenerator.CreatePage(PageNamePrefix, PageTitlePrefix, UrlNamePrefix, null, null);
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Templates().SetTemplateToPage(pageId, templateId);

                string responseContent = WebRequestHelper.GetPageWebContent(url);

                var httpContextWrapper = GetHttpContextWrapper(url);
                var htmlHelper         = GetHtmlHelper(httpContextWrapper);
                var scriptHtml         = ResourceHelper.Script(htmlHelper, ScriptRef.JQuery, "top", true).ToHtmlString();

                Assert.IsFalse(!responseContent.Contains(scriptHtml), "The jquery not found!");
            }
            finally
            {
                if (pageId != Guid.Empty)
                {
                    Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeletePage(pageId);
                }

                if (templateId != Guid.Empty)
                {
                    Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Templates().DeletePageTemplate(templateId);
                }
            }
        }
コード例 #21
0
ファイル: ResourceHelperTests.cs プロジェクト: virajs/feather
        public void RegisterScript_HybridPage_AddedInScriptManagerOnly()
        {
            string testName  = "RegisterScript";
            string pageTitle = testName + "WebFormsPage";
            string urlName   = testName + "WebFormsPage";
            string pageUrl   = UrlPath.ResolveAbsoluteUrl("~/" + urlName);

            this.AddDummyScriptControllerToPage(pageTitle, urlName, null);

            WebRequestHelper.GetPageWebContent(pageUrl);

            Assert.AreEqual(2, ActionExecutionRegister.ExecutedActionInfos.Count, "The actions are not executed correctly.");

            for (int i = 0; i < 2; i++)
            {
                var result = ActionExecutionRegister.ExecutedActionInfos[i].Result as ContentResult;
                Assert.IsTrue(string.IsNullOrEmpty(result.Content), "The script should not be added outside of ScriptManager.");

                var httpContext          = ActionExecutionRegister.ExecutedActionInfos[i].CurrentHttpContext;
                var scriptManagerScripts = System.Web.UI.ScriptManager.GetCurrent(httpContext.Handler as System.Web.UI.Page).Scripts;
                Assert.AreEqual(2, scriptManagerScripts.Count(), "The script is not added correctly");
            }
        }
コード例 #22
0
        public void CreatePageWithFailingWidget_RenderPage_ResponseContainsErrorMessage()
        {
            string testName        = System.Reflection.MethodInfo.GetCurrentMethod().Name;
            string pageNamePrefix  = testName + "MvcPage";
            string pageTitlePrefix = testName + "Mvc Page";
            string urlNamePrefix   = testName + "mvc-page";
            int    index           = 1;
            string url             = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix + index);

            var mvcProxy = new MvcControllerProxy();

            mvcProxy.ControllerName = typeof(DummyFailingController).FullName;

            using (var contentGenerator = new PageContentGenerator())
            {
                contentGenerator.CreatePageWithWidget(mvcProxy, string.Empty, pageNamePrefix, pageTitlePrefix, urlNamePrefix, index);

                string responseContent = WebRequestHelper.GetPageWebContent(url);
                string expectedResult  = Res.Get <InfrastructureResources>().ErrorExecutingController;

                Assert.Contains(responseContent, expectedResult, "The expected error message was not found on the page!");
            }
        }
コード例 #23
0
        public void RequestDetailsPage_WithNewsWidgetAndContentBlock_ResponseOk()
        {
            using (var contentGenerator = new PageContentGenerator())
            {
                var testName        = MethodInfo.GetCurrentMethod().Name;
                var pageNamePrefix  = testName + "MvcPage";
                var pageTitlePrefix = testName + "Mvc Page";
                var urlNamePrefix   = testName + "mvc-page";
                var newsItemName    = testName + "-news";
                var index           = 1;

                var mvcProxy = new MvcControllerProxy();
                mvcProxy.ControllerName = typeof(RoutingTests.NewsController).FullName;

                var pageId = contentGenerator.CreatePageWithWidget(mvcProxy, string.Empty, pageNamePrefix, pageTitlePrefix, urlNamePrefix, 1);

                mvcProxy = new MvcControllerProxy();
                mvcProxy.ControllerName = typeof(RoutingTests.ContentBlockController).FullName;

                PageContentGenerator.AddControlToPage(pageId, mvcProxy, typeof(RoutingTests.ContentBlockController).Name);

                try
                {
                    var newsItemId  = ServerOperations.News().CreatePublishedNewsItem(newsItemName);
                    var newsItemUrl = App.WorkWith().NewsItem(newsItemId).Get().ItemDefaultUrl;

                    string url = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix + index + "/" + newsItemUrl);

                    Assert.DoesNotThrow(() => WebRequestHelper.GetPageWebContent(url), "Could not get the page successfully.");
                }
                finally
                {
                    ServerOperations.News().DeleteNewsItem(newsItemName);
                }
            }
        }