public void DynamicWidgets_ChildWidget_DisplayHotelsFromCurrentlyOpenedCityWithoutCityWidget() { string hotelSuff; string citySuff; string url; string responseContent; try { var hotelsWidget = this.CreateMvcWidget(ResolveTypeHotel, WidgetNameHotels, ParentFilterMode.CurrentlyOpen, ResolveTypeCity); var controls = new List <System.Web.UI.Control>(); controls.Add(hotelsWidget); PageContentGenerator.AddControlsToPage(this.pageId, controls); for (int i = 1; i <= 3; i++) { citySuff = i.ToString(CultureInfo.InvariantCulture); url = UrlPath.ResolveAbsoluteUrl("~/" + PageName + "/country1/country1city" + citySuff); responseContent = PageInvoker.ExecuteWebRequest(url); for (int j = 1; j <= 3; j++) { hotelSuff = j.ToString(CultureInfo.InvariantCulture); Assert.IsTrue(responseContent.Contains("Country1City" + citySuff + "Hotel" + hotelSuff), "The dynamic item with this title was NOT found: Country1City" + citySuff + "Hotel" + hotelSuff); } } } finally { ServerOperations.Pages().DeleteAllPages(); } }
public void DynamicWidgets_HierarchicalWidgetsOnPage_DisplayHotelsFromCurrentlyOpenedCity() { string url; string responseContent; string suff; try { var countriesWidget = this.CreateMvcWidget(ResolveTypeCountry, WidgetNameCountries); var citiesWidget = this.CreateMvcWidget(ResolveTypeCity, WidgetNameCities, ParentFilterMode.CurrentlyOpen, ResolveTypeCountry); var hotelsWidget = this.CreateMvcWidget(ResolveTypeHotel, WidgetNameHotels, ParentFilterMode.CurrentlyOpen, ResolveTypeCity); var controls = new List <System.Web.UI.Control>(); controls.Add(countriesWidget); controls.Add(citiesWidget); controls.Add(hotelsWidget); PageContentGenerator.AddControlsToPage(this.pageId, controls); url = UrlPath.ResolveAbsoluteUrl("~/" + PageName + "/country1/country1city1"); responseContent = PageInvoker.ExecuteWebRequest(url); for (int i = 1; i <= 3; i++) { suff = i.ToString(CultureInfo.InvariantCulture); Assert.IsTrue(responseContent.Contains("Country1City1Hotel" + suff), "The dynamic item with this title was NOT found: Country1City1Hotel" + suff); Assert.IsFalse(responseContent.Contains("Country1City2Hotel" + suff), "The dynamic item with this title was found: Country1City2Hotel" + suff); Assert.IsFalse(responseContent.Contains("Country1City3Hotel" + suff), "The dynamic item with this title was found: Country1City3Hotel" + suff); } url = UrlPath.ResolveAbsoluteUrl("~/" + PageName + "/country1/country1city2"); responseContent = PageInvoker.ExecuteWebRequest(url); for (int i = 1; i <= 3; i++) { suff = i.ToString(CultureInfo.InvariantCulture); Assert.IsTrue(responseContent.Contains("Country1City2Hotel" + suff), "The dynamic item with this title was NOT found: Country1City2Hotel" + suff); Assert.IsFalse(responseContent.Contains("Country1City1Hotel" + suff), "The dynamic item with this title was found: Country1City1Hotel" + suff); Assert.IsFalse(responseContent.Contains("Country1City3Hotel" + suff), "The dynamic item with this title was found: Country1City3Hotel" + suff); } url = UrlPath.ResolveAbsoluteUrl("~/" + PageName + "/country2/country2city2"); responseContent = PageInvoker.ExecuteWebRequest(url); for (int i = 1; i <= 3; i++) { suff = i.ToString(CultureInfo.InvariantCulture); Assert.IsFalse(responseContent.Contains("Country2City1Hotel" + suff), "The dynamic item with this title was found: Country2City1Hotel" + suff); Assert.IsTrue(responseContent.Contains("Country2City2Hotel" + suff), "The dynamic item with this title was NOT found: Country2City2Hotel" + suff); Assert.IsFalse(responseContent.Contains("Country2City3Hotel" + suff), "The dynamic item with this title was found: Country2City3Hotel" + suff); } } finally { ServerOperations.Pages().DeleteAllPages(); } }
private void AddDummyScriptControllerToPage(string pageTitlePrefix, string urlNamePrefix, PageTemplate template, string placeHolder = "Body") { var controls = new List <System.Web.UI.Control>(); var mvcProxy1 = new MvcControllerProxy(); mvcProxy1.ControllerName = typeof(DummyScriptController).FullName; var newsController1 = new DummyScriptController(); mvcProxy1.Settings = new ControllerSettings(newsController1); controls.Add(mvcProxy1); var mvcProxy2 = new MvcControllerProxy(); mvcProxy2.ControllerName = typeof(DummyScriptController).FullName; var newsController2 = new DummyScriptController(); mvcProxy2.Settings = new ControllerSettings(newsController2); controls.Add(mvcProxy2); Guid pageId = FeatherServerOperations.Pages().CreatePageWithTemplate( template, pageTitlePrefix, urlNamePrefix); PageContentGenerator.AddControlsToPage(pageId, controls, placeHolder); }
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(); } }
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); Assert.IsTrue(responseContent.Contains(descriptionTag), "The response content doesn't contain description meta tag."); int descriptionTagCount = Regex.Matches(responseContent, Regex.Escape(descriptionTag)).Count; Assert.IsFalse(descriptionTagCount == 1, "The response content contains description meta tag more than once."); } }
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); } }
public void AddCalendarWidgetToPage(Guid pageId, string placeholder = "Body") { var mvcProxy = new MvcControllerProxy(); mvcProxy.ControllerName = typeof(EventSchedulerController).FullName; PageContentGenerator.AddControlToPage(pageId, mvcProxy, "Calendar", placeholder); }
public void StyleSheetWidget_RendersInHead() { var testName = MethodInfo.GetCurrentMethod().Name; string pageNamePrefix = testName; string pageTitlePrefix = testName; string urlNamePrefix = testName; string url = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix); var mvcProxy = new MvcControllerProxy(); mvcProxy.ControllerName = typeof(StyleSheetController).FullName; var controller = new StyleSheetController(); controller.Model.Mode = ResourceMode.Reference; controller.Model.ResourceUrl = "http://my-styles.com/styles.css"; controller.Model.MediaType = "screen"; mvcProxy.Settings = new ControllerSettings(controller); using (var generator = new PageContentGenerator()) { var pageId = generator.CreatePage(pageNamePrefix, pageTitlePrefix, urlNamePrefix); PageContentGenerator.AddControlToPage(pageId, mvcProxy, "CSS widget"); string responseContent = PageInvoker.ExecuteWebRequest(url); Assert.IsTrue(this.IsInHead(responseContent, @"<link href=""http://my-styles.com/styles.css"" media=""screen"" rel=""stylesheet"" type=""text/css"" />"), "The stylesheet reference was not found in the head."); } }
public void LanguageSelectorWidgetAndProductList_CurrentLanguageIncluded() { var languageSelectorControl = this.CreateLanguageSelectorControl(); var languageSelectorModel = languageSelectorControl.Settings.Controller.Model; languageSelectorControl.Settings.Controller.TemplateName = "DropDownMenu"; languageSelectorModel.IncludeCurrentLanguage = true; this.productOperations.CreatePublishedProduct(ProductTypeName, true, ProductName, ProductPrice); var controls = new List <System.Web.UI.Control>(); controls.Add(languageSelectorControl); var pageLanguages = new[] { this.sitefinityLanguages["English"] }; var createdPages = this.CreateLocalizedPage(PageName, pageLanguages); // Add language selector widget to the en-US page var currentPage = createdPages.First(); PageContentGenerator.AddControlsToPage(currentPage.Key, controls); ServerOperations.Widgets().AddProductListViewWithTemplate(currentPage.Key, EcommerceGlobals.placeholderId, EcommerceGlobals.captionProducts, ControlTypes.ProductDetailLayoutTemplateName, showWishlist: true); string url = UrlPath.ResolveAbsoluteUrl("~/" + PageName + currentPage.Value.Name); var pageContent = PageInvoker.ExecuteWebRequest(url); Assert.IsNotNull(pageContent); }
public void BlogsWidget_DisplayBlogsWithMoreThan_0_Posts() { string blog1Title = "Blog1"; string blog2Title = "Blog2"; string pageTitle = "PageWithBlogsWidget"; string blog1PostTitle = "Blog1_PublishedPost"; try { Guid blog1Id = ServerOperations.Blogs().CreateBlog(blog1Title); ServerOperations.Blogs().CreatePublishedBlogPost(blog1PostTitle, blog1Id); ServerOperations.Blogs().CreateBlog(blog2Title); Guid pageId = ServerOperations.Pages().CreatePage(pageTitle); var blogsWidget = this.CreateBlogsMvcWidgetFilteredSelectionMode(FilteredSelectionMode.MinPostsCount, minPostsCount: 0, maxPostsAge: 1); var controls = new List <System.Web.UI.Control>(); controls.Add(blogsWidget); PageContentGenerator.AddControlsToPage(pageId, controls); string url = UrlPath.ResolveAbsoluteUrl("~/" + pageTitle); string responseContent = PageInvoker.ExecuteWebRequest(url); Assert.IsTrue(responseContent.Contains(blog1Title), "The item with this title was NOT found " + blog1Title); Assert.IsFalse(responseContent.Contains(blog2Title), "The item with this title WAS found " + blog2Title); } finally { ServerOperations.Pages().DeleteAllPages(); ServerOperations.Blogs().DeleteAllBlogs(); } }
public void BlogPostsWidget_DisplaySelectedBlogPosts() { string blogTitle = "Blog"; string blogPost1Title = "BlogPost1"; string blogPost2Title = "BlogPost2"; string pageTitle = "PageWithBlogPostsWidget"; try { Guid blogId = ServerOperations.Blogs().CreateBlog(blogTitle); Guid post1Id = ServerOperations.Blogs().CreatePublishedBlogPost(blogPost1Title, blogId); Guid pageId = ServerOperations.Pages().CreatePage(pageTitle); var blogPostsWidget = this.CreateBlogPostsMvcWidget(default(Guid), ParentFilterMode.All, SelectionMode.SelectedItems, post1Id); var controls = new List <System.Web.UI.Control>(); controls.Add(blogPostsWidget); PageContentGenerator.AddControlsToPage(pageId, controls); string url = UrlPath.ResolveAbsoluteUrl("~/" + pageTitle); string responseContent = PageInvoker.ExecuteWebRequest(url); Assert.IsTrue(responseContent.Contains(blogPost1Title), "The item with this title was NOT found " + blogPost1Title); Assert.IsFalse(responseContent.Contains(blogPost2Title), "The item with this title WAS found " + blogPost2Title); } finally { ServerOperations.Pages().DeleteAllPages(); ServerOperations.Blogs().DeleteAllBlogs(); } }
public void BlogsWidget_UseLimit_OneItem() { string blog1Title = "Blog1"; string blog2Title = "Blog2"; string pageTitle = "PageWithBlogsWidget"; try { ServerOperations.Blogs().CreateBlog(blog1Title); ServerOperations.Blogs().CreateBlog(blog2Title); Guid pageId = ServerOperations.Pages().CreatePage(pageTitle); var blogsWidget = this.CreateBlogsMvcWidget(ListDisplayMode.Limit, itemsPerPage: 1); var controls = new List <System.Web.UI.Control>(); controls.Add(blogsWidget); PageContentGenerator.AddControlsToPage(pageId, controls); string url = UrlPath.ResolveAbsoluteUrl("~/" + pageTitle); string responseContent = PageInvoker.ExecuteWebRequest(url); Assert.IsTrue(responseContent.Contains(blog2Title), "The item with this title was NOT found " + blog2Title); Assert.IsFalse(responseContent.Contains(blog1Title), "The item with this title WAS found " + blog1Title); } finally { ServerOperations.Pages().DeleteAllPages(); ServerOperations.Blogs().DeleteAllBlogs(); } }
public void DynamicWidgets_ContentLocationService_VerifyDynamicItemLocationOnMoreThanOnePage() { int expectedLocationsCount; var page2Name = PageName + "2"; try { var countryId = ServerOperationsFeather.DynamicModuleBooking().CreateCountry(CountryName); Type countryType = TypeResolutionService.ResolveType(ResolveTypeCountry); DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(); var page1Id = ServerOperations.Pages().CreatePage(PageName); var page2Id = ServerOperations.Pages().CreatePage(page2Name); var countriesWidget = this.CreateMvcWidget(ResolveTypeCountry, WidgetNameCountries); var controls = new List <System.Web.UI.Control>(); controls.Add(countriesWidget); PageContentGenerator.AddControlsToPage(page1Id, controls); PageContentGenerator.AddControlsToPage(page2Id, controls); var locationsService = SystemManager.GetContentLocationService(); var dynamicItemLocations = locationsService.GetItemLocations(countryType, dynamicModuleManager.Provider.Name, countryId); expectedLocationsCount = 2; Assert.AreEqual(expectedLocationsCount, dynamicItemLocations.Count(), "Unexpected locations count"); } finally { ServerOperations.Pages().DeleteAllPages(); ServerOperationsFeather.DynamicModuleBooking().DeleteCountry(CountryName); } }
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."); } }
public void DynamicWidgets_ParentRelationType_DisplayRelatedItemsOnFrontend() { string url; string responseContent; string expectedContent; string pageName = "FeatherPage"; string pageUrl = "featherpage"; string item1 = "item1"; string item2 = "item2"; foreach (var color in this.colors) { ServerOperationsFeather.DynamicModule1Operations().CreateColor(color); } try { string[] item1RelatedColors = new string[] { this.colors[0], this.colors[1] }; ServerOperationsFeather.DynamicModule2Operations().CreateItem(item1, item1RelatedColors); string[] item2RelatedColors = new string[] { this.colors[2], this.colors[3] }; ServerOperationsFeather.DynamicModule2Operations().CreateItem(item2, item2RelatedColors); this.pageId = ServerOperations.Pages().CreatePage(pageName); var itemsWidget = this.CreateMvcWidget(ResolveTypeItem, WidgetNameItem, RelatedFieldName, ResolveTypeColor, RelationDirection.Parent); var colorsWidget = this.CreateMvcWidget(ResolveTypeColor, WidgetNameColor); var controls = new List <System.Web.UI.Control>(); controls.Add(itemsWidget); controls.Add(colorsWidget); PageContentGenerator.AddControlsToPage(this.pageId, controls); url = UrlPath.ResolveAbsoluteUrl("~/" + pageUrl + "/" + this.colors[0]); responseContent = PageInvoker.ExecuteWebRequest(url); expectedContent = UrlPath.ResolveAbsoluteUrl("~/" + pageUrl + "/" + item1); Assert.IsTrue(this.ContainsElement(responseContent, expectedContent), "Link to " + item1 + " was not found on the frontend"); expectedContent = UrlPath.ResolveAbsoluteUrl("~/" + pageUrl + "/" + item2); Assert.IsFalse(this.ContainsElement(responseContent, expectedContent), "Link to " + item2 + " was found on the frontend, but it shouldn't"); url = UrlPath.ResolveAbsoluteUrl("~/" + pageUrl + "/" + this.colors[3]); responseContent = PageInvoker.ExecuteWebRequest(url); expectedContent = UrlPath.ResolveAbsoluteUrl("~/" + pageUrl + "/" + item2); Assert.IsTrue(this.ContainsElement(responseContent, expectedContent), "Link to " + item2 + " was not found on the frontend"); expectedContent = UrlPath.ResolveAbsoluteUrl("~/" + pageUrl + "/" + item1); Assert.IsFalse(this.ContainsElement(responseContent, expectedContent), "Link to " + item1 + " was found on the frontend, but it shouldn't"); } finally { ServerOperations.Pages().DeleteAllPages(); } }
private void AddGridControlToPage(Guid pageId, string controlPath, string placeHolder, string caption) { var control = new GridControl(); control.Layout = controlPath; PageContentGenerator.AddControlToPage(pageId, control, caption, placeHolder); }
public void BlogsWidget_SortBlogs_ByTitle_ZA() { string blog1Title = "A_Blog"; string blog2Title = "Z_Blog"; string blog3Title = "B_Blog"; string pageTitle = "PageWithBlogsWidget"; string sortExpression = "Title DESC"; int limitCount = 1; Guid pageId = Guid.Empty; Guid blog1Id = Guid.Empty; Guid blog2Id = Guid.Empty; Guid blog3Id = Guid.Empty; try { blog1Id = ServerOperations.Blogs().CreateBlog(blog1Title); blog2Id = ServerOperations.Blogs().CreateBlog(blog2Title); blog3Id = ServerOperations.Blogs().CreateBlog(blog3Title); pageId = ServerOperations.Pages().CreatePage(pageTitle); var blogsWidget = this.CreateBlogsMvcWidget(ListDisplayMode.Limit, limitCount, sortExpression); var controls = new List <System.Web.UI.Control>(); controls.Add(blogsWidget); PageContentGenerator.AddControlsToPage(pageId, controls); string url = UrlPath.ResolveAbsoluteUrl("~/" + pageTitle); string responseContent = PageInvoker.ExecuteWebRequest(url); Assert.IsTrue(responseContent.Contains(blog2Title), "The item with this title was NOT found " + blog2Title); Assert.IsFalse(responseContent.Contains(blog3Title), "The item with this title WAS found " + blog3Title); } finally { if (pageId != Guid.Empty) { ServerOperations.Pages().DeletePage(pageId); } if (blog1Id != Guid.Empty) { ServerOperations.Blogs().DeleteBlog(blog1Id); } if (blog2Id != Guid.Empty) { ServerOperations.Blogs().DeleteBlog(blog2Id); } if (blog3Id != Guid.Empty) { ServerOperations.Blogs().DeleteBlog(blog3Id); } } }
public void LanguageSelectorWidget_DetailsViewOfNewsItemWithENTranslationOnly() { var languageSelectorControl = this.CreateLanguageSelectorControl(); var languageSelectorModel = languageSelectorControl.Settings.Controller.Model; languageSelectorModel.IncludeCurrentLanguage = true; var controls = new List <System.Web.UI.Control>(); controls.Add(languageSelectorControl); this.serverOperationsNews.CreateNewsItem("TestNewsItem"); var newsControl = this.CreateNewsControl(); controls.Add(newsControl); var pageLanguages = new[] { this.sitefinityLanguages["English"], this.sitefinityLanguages["Turkish"] }; var createdPages = this.CreateLocalizedPage(PageName, pageLanguages); // Add language selector widget to the en-US page var currentPage = createdPages.First(); PageContentGenerator.AddControlsToPage(currentPage.Key, controls); var items = newsControl.Settings.Controller.Model.CreateListViewModel(null, 1).Items.ToArray(); var expectedDetailNews = (NewsItem)items[0].DataItem; string url = UrlPath.ResolveAbsoluteUrl("~/" + PageName + currentPage.Value.Name); string detailNewsUrl = url + expectedDetailNews.ItemDefaultUrl; var pageContent = PageInvoker.ExecuteWebRequest(detailNewsUrl); Assert.IsNotNull(pageContent); var expectedLinks = new Dictionary <CultureInfo, string>() { { this.sitefinityLanguages["English"], this.GetPageUrl(PageName, this.sitefinityLanguages["English"], true) + expectedDetailNews.ItemDefaultUrl }, { this.sitefinityLanguages["Turkish"], this.GetPageUrl(PageName, this.sitefinityLanguages["Turkish"]) } }; var notExpectedLinks = new Dictionary <CultureInfo, string>() { { this.sitefinityLanguages["Arabic"], this.GetPageUrl(PageName, this.sitefinityLanguages["Arabic"]) }, { this.sitefinityLanguages["Serbian"], this.GetPageUrl(PageName, this.sitefinityLanguages["Serbian"]) }, { this.sitefinityLanguages["Bulgarian"], this.GetPageUrl(PageName, this.sitefinityLanguages["Bulgarian"]) }, { this.sitefinityLanguages["French"], this.GetPageUrl(PageName, this.sitefinityLanguages["French"]) }, { this.sitefinityLanguages["German"], this.GetPageUrl(PageName, this.sitefinityLanguages["German"]) } }; this.AssertLanguageLinks(pageContent, expectedLinks, notExpectedLinks); }
private string BuildPage() { var all = GasconadeUi.KnownLogTypes().ToList(); if (!all.Any()) { return(TagHttpPage(PageContentGenerator.EmptyLogsPage())); } return(TagHttpPage(PageContentGenerator.ListingDocument(all, GasconadeUi.ReturnLink, GasconadeUi.HeaderHtml))); }
public void BlogsWidget_UsePaging_OneItemPerPage() { string blog1Title = "Blog1"; string blog2Title = "Blog2"; string pageTitle = "PageWithBlogsWidget"; int firstPageIndex = 1; int secondPageIndex = 2; Guid pageId = Guid.Empty; Guid blog1Id = Guid.Empty; Guid blog2Id = Guid.Empty; try { blog1Id = ServerOperations.Blogs().CreateBlog(blog1Title); blog2Id = ServerOperations.Blogs().CreateBlog(blog2Title); pageId = ServerOperations.Pages().CreatePage(pageTitle); var blogsWidget = this.CreateBlogsMvcWidget(ListDisplayMode.Paging, itemsCount: 1); var controls = new List <System.Web.UI.Control>(); controls.Add(blogsWidget); PageContentGenerator.AddControlsToPage(pageId, controls); string url = UrlPath.ResolveAbsoluteUrl("~/" + pageTitle + "/" + firstPageIndex); string responseContent = PageInvoker.ExecuteWebRequest(url); Assert.IsTrue(responseContent.Contains(blog2Title), "The item with this title was NOT found " + blog2Title); Assert.IsFalse(responseContent.Contains(blog1Title), "The item with this title WAS found " + blog1Title); url = UrlPath.ResolveAbsoluteUrl("~/" + pageTitle + "/" + secondPageIndex); responseContent = PageInvoker.ExecuteWebRequest(url); Assert.IsTrue(responseContent.Contains(blog1Title), "The item with this title was NOT found " + blog1Title); Assert.IsFalse(responseContent.Contains(blog2Title), "The item with this title WAS found " + blog2Title); } finally { if (pageId != Guid.Empty) { ServerOperations.Pages().DeletePage(pageId); } if (blog1Id != Guid.Empty) { ServerOperations.Blogs().DeleteBlog(blog1Id); } if (blog2Id != Guid.Empty) { ServerOperations.Blogs().DeleteBlog(blog2Id); } } }
/// <summary> /// Core handler /// </summary> protected override Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { var all = GasconadeUi.KnownLogTypes().ToList(); if (!all.Any()) { return(TagHttpPage(PageContentGenerator.EmptyLogsPage())); } return(TagHttpPage(PageContentGenerator.ListingDocument(all, GasconadeUi.ReturnLink, GasconadeUi.HeaderHtml))); }
private void AddScriptControllerToPage(Guid pageId, string scriptSource = null, string sectionName = null) { var mvcProxy = new MvcControllerProxy(); mvcProxy.ControllerName = typeof(DummyScriptController).FullName; var controller = new DummyScriptController(); controller.ScriptSource = scriptSource; controller.SectionName = sectionName; mvcProxy.Settings = new ControllerSettings(controller); PageContentGenerator.AddControlToPage(pageId, mvcProxy, Guid.NewGuid().ToString("N"), "TestPlaceHolder"); }
public void AddFormControlToPage(Guid pageId, Guid formId, string formName = "TestForm", string placeholder = "Contentplaceholder1") { var mvcProxy = new MvcControllerProxy(); mvcProxy.ControllerName = typeof(FormController).FullName; var controller = new FormController(); controller.Model.FormId = formId; controller.Model.ViewMode = FormViewMode.Write; mvcProxy.Settings = new ControllerSettings(controller); PageContentGenerator.AddControlToPage(pageId, mvcProxy, formName, placeholder); }
public void Breadcrumb_DynamicWidget_VirtualNodes() { string dynamicTitle = "dynamic type title"; string dynamicUrl = "dynamic type title"; ServerOperationsFeather.DynamicModules().EnsureModuleIsImported(ModuleName, ModuleResource); ServerOperationsFeather.DynamicModulePressArticle().CreatePressArticleItem(dynamicTitle, dynamicUrl); var dynamicCollection = ServerOperationsFeather.DynamicModulePressArticle().RetrieveCollectionOfPressArticles(); string testName = System.Reflection.MethodInfo.GetCurrentMethod().Name; string pageNamePrefix = testName + "DynamicPage"; string pageTitlePrefix = testName + "Dynamic Page"; string urlNamePrefix = testName + "dynamic-page"; int pageIndex = 1; string pageTitle = pageTitlePrefix + pageIndex; Guid pageId = Guid.Empty; string pageUrl = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix + pageIndex); try { var mvcBreadcrumbWidget = this.CreateBreadcrumbMvcWidget(); pageId = this.pageOperations.CreatePageWithControl(mvcBreadcrumbWidget, pageNamePrefix, pageTitlePrefix, urlNamePrefix, pageIndex); var mvcProxy = this.CreateDynamicMvcWidget(); PageContentGenerator.AddControlsToPage(pageId, new List <System.Web.UI.Control>() { mvcProxy }); string detailsUrl = pageUrl + dynamicCollection[0].ItemDefaultUrl; string responseContent = PageInvoker.ExecuteWebRequest(detailsUrl); string relativeUrl = UrlPath.ResolveUrl("~/" + urlNamePrefix + pageIndex); string breadcrumbTemplate = @"<a[\w\s]{1,}href=(?<url>""/""|""" + relativeUrl + @""")>" + pageTitle + @"[\w\s]{1,}</a>[\w\s]{1,}<span>[\w\s]{1,}/[\w\s]{1,}</span>[\w\s]{1,}" + dynamicTitle; Match match = Regex.Match(responseContent, breadcrumbTemplate, RegexOptions.IgnorePatternWhitespace & RegexOptions.Multiline); Assert.IsTrue(match.Success, "Breadcrumb does not contain selected dynamic item as virtual node!"); } finally { if (pageId != Guid.Empty) { CommonOperationsContext.ServerOperations.Pages().DeletePage(pageId); } ServerOperationsFeather.DynamicModulePressArticle().DeleteDynamicItems(dynamicCollection); Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.ModuleBuilder().DeleteAllModules(string.Empty, TransactionName); } }
public Guid CreatePageWithControl(Control control, string pageNamePrefix, string pageTitlePrefix, string urlNamePrefix, int index) { var controls = new List <System.Web.UI.Control>(); controls.Add(control); this.locationGenerator = new PageContentGenerator(); var pageId = this.locationGenerator.CreatePage( string.Format(CultureInfo.InvariantCulture, "{0}{1}", pageNamePrefix, index.ToString(CultureInfo.InvariantCulture)), string.Format(CultureInfo.InvariantCulture, "{0}{1}", pageTitlePrefix, index.ToString(CultureInfo.InvariantCulture)), string.Format(CultureInfo.InvariantCulture, "{0}{1}", urlNamePrefix, index.ToString(CultureInfo.InvariantCulture))); PageContentGenerator.AddControlsToPage(pageId, controls); return(pageId); }
public void DynamicWidgets_ContentLocationService_MultipleItemsSelectedFromWidget() { int expectedLocationsCount; try { for (int i = 1; i <= 3; i++) { ServerOperationsFeather.DynamicModuleBooking().CreateCountry(CountryName + i.ToString(CultureInfo.InvariantCulture)); } Type countryType = TypeResolutionService.ResolveType(ResolveTypeCountry); DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(); var countryItem1Id = dynamicModuleManager.GetDataItems(countryType).Where("Title = \"" + CountryName + "1\"").First().Id; var countryItem2Id = dynamicModuleManager.GetDataItems(countryType).Where("Title = \"" + CountryName + "2\"").First().Id; string[] itemIds = new string[] { countryItem1Id.ToString(), countryItem2Id.ToString() }; var pageId = ServerOperations.Pages().CreatePage(PageName); var countriesWidget = this.CreateMvcWidget(ResolveTypeCountry, WidgetNameCountries, itemIds); var controls = new List <System.Web.UI.Control>(); controls.Add(countriesWidget); PageContentGenerator.AddControlsToPage(pageId, controls); var locationsService = SystemManager.GetContentLocationService(); var dynamicItemLocations = locationsService.GetItemLocations(countryType, dynamicModuleManager.Provider.Name, countryItem1Id); expectedLocationsCount = 1; Assert.AreEqual(expectedLocationsCount, dynamicItemLocations.Count(), "Unexpected locations count"); dynamicItemLocations = locationsService.GetItemLocations(countryType, dynamicModuleManager.Provider.Name, countryItem2Id); Assert.AreEqual(expectedLocationsCount, dynamicItemLocations.Count(), "Unexpected locations count"); } finally { ServerOperations.Pages().DeleteAllPages(); for (int i = 1; i <= 3; i++) { ServerOperationsFeather.DynamicModuleBooking().DeleteCountry(CountryName + i.ToString(CultureInfo.InvariantCulture)); } } }
public void LanguageSelectorWidget_CurrentLanguageIncluded() { var languageSelectorControl = this.CreateLanguageSelectorControl(); var languageSelectorModel = languageSelectorControl.Settings.Controller.Model; languageSelectorModel.IncludeCurrentLanguage = true; var controls = new List <System.Web.UI.Control>(); controls.Add(languageSelectorControl); var pageLanguages = new[] { this.sitefinityLanguages["English"], this.sitefinityLanguages["Turkish"] }; var createdPages = this.CreateLocalizedPage(PageName, pageLanguages); // Add language selector widget to the en-US page var currentPage = createdPages.First(); PageContentGenerator.AddControlsToPage(currentPage.Key, controls); string url = UrlPath.ResolveAbsoluteUrl("~/" + PageName + currentPage.Value.Name); var pageContent = PageInvoker.ExecuteWebRequest(url); Assert.IsNotNull(pageContent); var expectedLinks = new Dictionary <CultureInfo, string>() { { this.sitefinityLanguages["English"], this.GetPageUrl(PageName, this.sitefinityLanguages["English"], true) }, { this.sitefinityLanguages["Turkish"], this.GetPageUrl(PageName, this.sitefinityLanguages["Turkish"]) } }; var notExpectedLinks = new Dictionary <CultureInfo, string>() { { this.sitefinityLanguages["Arabic"], this.GetPageUrl(PageName, this.sitefinityLanguages["Arabic"]) }, { this.sitefinityLanguages["Serbian"], this.GetPageUrl(PageName, this.sitefinityLanguages["Serbian"]) }, { this.sitefinityLanguages["Bulgarian"], this.GetPageUrl(PageName, this.sitefinityLanguages["Bulgarian"]) }, { this.sitefinityLanguages["French"], this.GetPageUrl(PageName, this.sitefinityLanguages["French"]) }, { this.sitefinityLanguages["German"], this.GetPageUrl(PageName, this.sitefinityLanguages["German"]) } }; this.AssertLanguageLinks(pageContent, expectedLinks, notExpectedLinks); }
private Guid CreatePageWithControl(PageTemplateFramework framework, out string pageUrl) { var pageId = this.CreatePage(framework, out pageUrl); var mvcProxy = new MvcControllerProxy(); mvcProxy.ControllerName = typeof(ContentBlockController).FullName; var contentBlockController = new ContentBlockController(); contentBlockController.Content = ModuleUnloadTests.PageControlContent; mvcProxy.Settings = new ControllerSettings(contentBlockController); PageContentGenerator.AddControlsToPage(pageId, new Control[] { mvcProxy }, framework == PageTemplateFramework.Mvc ? "Contentplaceholder1" : "Body"); return(pageId); }
public void FormsWidget_SubmitFormWithForumWidgetOnPageBasedOnCustomHybridPage_NoExceptionIsThrown() { var testName = MethodInfo.GetCurrentMethod().Name; var templateName = testName + "template"; var pageName = testName + "page"; var submitButtonControl = new MvcWidgetProxy(); submitButtonControl.ControllerName = typeof(SubmitButtonController).FullName; submitButtonControl.Settings = new ControllerSettings(new SubmitButtonController()); var formId = ServerOperationsFeather.Forms().CreateFormWithWidget(submitButtonControl); var forumControl = new ForumsView(); var pageManager = PageManager.GetManager(); Guid templateId = Guid.Empty; Guid pageId = Guid.Empty; try { templateId = Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Templates().CreateHybridMVCPageTemplate(templateName); pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(pageManager.GetTemplate(templateId), pageName, pageName); ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId, "TestForm", "Body"); PageContentGenerator.AddControlToPage(pageId, forumControl, "TestForum", "Body"); var page = pageManager.GetPageNode(pageId); var pageUrl = page.GetFullUrl(); pageUrl = RouteHelper.GetAbsoluteUrl(pageUrl); var webRequest = (HttpWebRequest)WebRequest.Create(pageUrl); var dataString = "------WebKitFormBoundaryPIB6p73K1Y0L0ha5--"; var dataBytes = (new ASCIIEncoding()).GetBytes(dataString); webRequest.Method = "POST"; webRequest.ContentLength = dataBytes.Length; webRequest.ContentType = "multipart/form-data"; webRequest.Timeout = 120 * 1000; webRequest.GetRequestStream().Write(dataBytes, 0, dataBytes.Length); Assert.DoesNotThrow(() => webRequest.GetResponse(), "Submitting a form on custom hybrid page with a forum widget on it throws error"); } finally { Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeletePage(pageId); Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Templates().DeletePageTemplate(templateId); FormsModuleCodeSnippets.DeleteForm(formId); } }
public void Breadcrumb_DetailNewsItem_VirtualNodes() { Guid pageId = Guid.Empty; try { string testName = System.Reflection.MethodInfo.GetCurrentMethod().Name; string pageNamePrefix = testName + "NewsPage"; string pageTitlePrefix = testName + "News Page"; string urlNamePrefix = testName + "news-page"; int pageIndex = 1; string pageTitle = pageTitlePrefix + pageIndex; string pageUrl = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix + pageIndex); var mvcBreadcrumbWidget = this.CreateBreadcrumbMvcWidget(); pageId = this.pageOperations.CreatePageWithControl(mvcBreadcrumbWidget, pageNamePrefix, pageTitlePrefix, urlNamePrefix, pageIndex); var newsMvcWidget = this.CreateNewsMvcWidget(); PageContentGenerator.AddControlsToPage(pageId, new List <System.Web.UI.Control>() { newsMvcWidget }); CommonOperationsContext.ServerOperations.News().CreatePublishedNewsItem(newsTitle: NewsTitle, newsContent: NewsTitle); var items = ((NewsController)newsMvcWidget.Controller).Model.CreateListViewModel(null, 1).Items.ToArray(); var newsItem = (NewsItem)items[0].DataItem; string detailNewsUrl = pageUrl + newsItem.ItemDefaultUrl; var responseContent = PageInvoker.ExecuteWebRequest(detailNewsUrl); string relativeUrl = UrlPath.ResolveUrl("~/" + urlNamePrefix + pageIndex); string breadcrumbTemplate = @"<a[\w\s]{1,}href=(?<url>""/""|""" + relativeUrl + @""")>" + pageTitle + @"[\w\s]{1,}</a>[\w\s]{1,}<span>[\w\s]{1,}/[\w\s]{1,}</span>[\w\s]{1,}" + NewsTitle; Match match = Regex.Match(responseContent, breadcrumbTemplate, RegexOptions.IgnorePatternWhitespace & RegexOptions.Multiline); Assert.IsTrue(match.Success, "Breadcrumb does not contain selected news item as virtual node!"); } finally { if (pageId != Guid.Empty) { CommonOperationsContext.ServerOperations.Pages().DeletePage(pageId); } CommonOperationsContext.ServerOperations.News().DeleteNewsItem(NewsTitle); } }
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(); } } }
public void CreatePageWithNoOutputIndexingModeWidget_RenderPageInMemory_ResponseDoesNotContainWidget() { string testName = System.Reflection.MethodInfo.GetCurrentMethod().Name; string pageNamePrefix = testName + "MvcPage"; string pageTitlePrefix = testName + "Mvc Page"; string urlNamePrefix = testName + "mvc-page"; int index = 1; var mvcProxy = new MvcControllerProxy(); mvcProxy.ControllerName = typeof(DummyNoOutputInIndexingController).FullName; using (var contentGenerator = new PageContentGenerator()) { var pageId = contentGenerator.CreatePageWithWidget(mvcProxy, string.Empty, pageNamePrefix, pageTitlePrefix, urlNamePrefix, index); var pageNode = PageManager.GetManager().GetPageNode(pageId); var content = new InMemoryPageRender().RenderPage(pageNode); Assert.DoesNotContain(content, DummyNoOutputInIndexingController.Output, "The output of the widget that should not have been rendered was found!"); } }
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."); } }
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!"); } }
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); } } }
public Guid CreatePageWithControl(Control control, string pageNamePrefix, string pageTitlePrefix, string urlNamePrefix, int index) { var controls = new List<System.Web.UI.Control>(); controls.Add(control); this.locationGenerator = new PageContentGenerator(); var pageId = this.locationGenerator.CreatePage( string.Format(CultureInfo.InvariantCulture, "{0}{1}", pageNamePrefix, index.ToString(CultureInfo.InvariantCulture)), string.Format(CultureInfo.InvariantCulture, "{0}{1}", pageTitlePrefix, index.ToString(CultureInfo.InvariantCulture)), string.Format(CultureInfo.InvariantCulture, "{0}{1}", urlNamePrefix, index.ToString(CultureInfo.InvariantCulture))); PageContentGenerator.AddControlsToPage(pageId, controls); return pageId; }
public void Setup() { this.templateOperation = new TemplateOperations(); this.locationGenerator = new PageContentGenerator(); }