private void CreateForumsPage() { var result = SampleUtilities.CreatePage(new Guid(ForumsPageId), "Forum"); if (result) { SampleUtilities.SetTemplateToPage(new Guid(ForumsPageId), new Guid(SamplesTemplateId)); var templateKey = SampleUtilities.GetControlTemplateKey(typeof(ForumListView), "List of forums"); var forumControl = new ForumsView(); forumControl.MasterViewName = "ForumListView"; SampleUtilities.AddControlToPage(new Guid(ForumsPageId), forumControl, "Content", "Forum View"); } }
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); } }
private void CreateSample(object[] args) { SampleUtilities.RegisterTheme(SamplesThemeName, SamplesThemePath); SampleUtilities.RegisterTemplate(new Guid(SamplesTemplateId), SamplesTemplateName, SamplesTemplateName, SamplesTemplatePath, SamplesThemeName); this.CreateForums(); this.CreateBlogs(); var result = SampleUtilities.CreatePage(new Guid(HomePageId), "Home", true); if (result) { SampleUtilities.SetTemplateToPage(new Guid(HomePageId), new Guid(SamplesTemplateId)); ContentBlockBase cb = new ContentBlockBase(); cb.Html = "<h1>Akismet Integration</h1><p>This sample demonstrates how to integrate Akismet with Sitefinity using the EventHub mechanism. You can submit new Forum posts or Blog comments, which will be checked through Akismet for spam.</p>"; SampleUtilities.AddControlToPage(new Guid(HomePageId), cb, "Content", "Content Block"); } var result2 = SampleUtilities.CreatePage(new Guid(ForumsPageId), "Forum"); if (result2) { SampleUtilities.SetTemplateToPage(new Guid(ForumsPageId), new Guid(SamplesTemplateId)); ForumsView forums = new ForumsView(); SampleUtilities.AddControlToPage(new Guid(ForumsPageId), forums, "Content", "Forums"); } var result3 = SampleUtilities.CreatePage(new Guid(BlogPageId), "Blog"); if (result3) { SampleUtilities.SetTemplateToPage(new Guid(BlogPageId), new Guid(SamplesTemplateId)); BlogPostView blogs = new BlogPostView(); SampleUtilities.AddControlToPage(new Guid(BlogPageId), blogs, "Content", "Blog Posts"); } }
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); } }