// Tools /////////////////////////////////////////////////////////////////// private void SaveNewPersonalizationSettings(SNP.Page page, PageState pageState) { string newSharedDataString = pageState.Encode(); byte[] newSharedDataBlob = Convert.FromBase64String(newSharedDataString); page.PersonalizationSettings.SetStream(new MemoryStream(newSharedDataBlob)); page.Save(); }
public static Page CreateTestPage(string name) { Page page = null; page = Node.LoadNode(string.Concat("/Root/", name)) as Page; if (page == null) { page = new Page(Repository.Root); page.Name = name; page.Save(); } return page; }
//======================================================================== Helpers private Page CreateTestPage() { string testPagePath = RepositoryPath.Combine(_rootNodePath, Guid.NewGuid().ToString()); if (Node.Exists(testPagePath)) Node.ForceDelete(testPagePath); Page f = new Page(Node.LoadNode(_rootNodePath)); f.PageTemplateNode = PageTemplate.LoadNode(_pageTemplatePath) as PageTemplate; f.Save(); return f; }
public static Page CreatePage(string name, Node parent) { var page = Node.LoadNode(string.Concat(parent.Path, "/", name)) as Page; if (page != null) page.ForceDelete(); page = new Page(parent) { Name = name }; page.Save(); return page; }
public void GenericContent_KeepBinaryAfterPublish() { Page samplePage = new Page(TestRoot); samplePage.Name = "SamplePage"; samplePage.VersioningMode = ContentRepository.Versioning.VersioningType.MajorAndMinor; samplePage.ApprovingMode = ContentRepository.Versioning.ApprovingType.True; //set binaries BinaryData pageBinaryData = CreateBinaryDataFromString("Page Binary"); BinaryData psBinaryData = CreateBinaryDataFromString("Page PersonalizationSettings"); samplePage.Binary = pageBinaryData; samplePage.PersonalizationSettings = psBinaryData; //save page samplePage.Save(); samplePage.CheckOut(); samplePage.Publish(); //asserts //TODO: CheckBinariesInPageByString hosszutavon folosleges CheckBinariesInPageByString(samplePage, "Page Binary", "Page PersonalizationSettings"); CheckBinariesInPageByByte(samplePage,pageBinaryData.GetStream(),psBinaryData.GetStream()); }
public void GenericContent_KeepIconAfterUndocheckout() { Page samplePage = new Page(TestRoot); samplePage.Name = "SamplePage"; //set index string icon = "icon.ic"; samplePage.Icon = icon; samplePage.Save(); samplePage.CheckOut(); samplePage.UndoCheckOut(); //asserts Assert.AreEqual(icon, samplePage.Icon, "Icon property doesn't contain the expected value."); }
public void GenericContent_KeepIndexAfterUndocheckout() { Page samplePage = new Page(TestRoot); samplePage.Name = "SamplePage"; //set index int index = 15; samplePage.Index = index; samplePage.Save(); samplePage.CheckOut(); samplePage.UndoCheckOut(); //asserts Assert.AreEqual(index, samplePage.Index, "Index property doesn't contain the expected value."); }
public void GenericContent_KeepTextPropertyAfterUndocheckout() { Page samplePage = new Page(TestRoot); samplePage.Name = "SamplePage"; //set sample page string textProperty = "minta property"; samplePage.Keywords = textProperty; samplePage.Save(); samplePage.CheckOut(); samplePage.UndoCheckOut(); //asserts Assert.AreEqual(textProperty, samplePage.Keywords, "Keywords property doesn't contain the expected strings."); }
public void GenericContent_KeepReferenceAfterUndocheckout() { //create page template PageTemplate samplePageTemplate = new PageTemplate(TestRoot); samplePageTemplate.Name = "Sample Page Template"; samplePageTemplate.Binary = CreateBinaryDataFromString("<html><head></head><body></body></html>"); samplePageTemplate.Save(); Page samplePage = new Page(TestRoot); samplePage.Name = "SamplePage"; //set reference samplePage.PageTemplateNode = samplePageTemplate; samplePage.Save(); samplePage.CheckOut(); samplePage.UndoCheckOut(); //asserts CheckPageTemplateInPage(samplePage, samplePageTemplate.Id); }
public void GenericContent_KeepBinaryAfterUndocheckout() { Page samplePage = new Page(TestRoot); samplePage.Name = "SamplePage"; //set binaries BinaryData pageBinaryData = CreateBinaryDataFromString("Page Binary"); BinaryData psBinaryData = CreateBinaryDataFromString("Page PersonalizationSettings"); samplePage.Binary = pageBinaryData; samplePage.PersonalizationSettings = psBinaryData; //save page samplePage.Save(); samplePage.CheckOut(); samplePage.UndoCheckOut(); //asserts //TODO: CheckBinariesInPageByString hosszutavon folosleges CheckBinariesInPageByString(samplePage, "Page Binary", "Page PersonalizationSettings"); CheckBinariesInPageByByte(samplePage, pageBinaryData.GetStream(), psBinaryData.GetStream()); }
public static void CreateSandbox(TestContext testContext) { var site = Node.Load<Site>("/Root/TestSiteForAppModelTest"); if (site == null) { site = new Site(Repository.Root); site.Name = "TestSiteForAppModelTest"; var urlList = new Dictionary<string, string>(); urlList.Add("testhost", "Windows"); site.UrlList = urlList; site.Save(); } var homePage = EnsureSiteStartPage(site); var webContent = Node.Load<GenericContent>("/Root/TestSiteForAppModelTest/Home/WebContent1"); if (webContent == null) { webContent = new GenericContent(homePage, "WebContent"); webContent.Name = "WebContent1"; webContent.Save(); } var file = Node.Load<File>("/Root/TestSiteForAppModelTest/Home/File1"); if (file == null) { file = new File(homePage); file.Name = "File1"; file.GetBinary("Binary").SetStream(Tools.GetStreamFromString("File1 content")); file.Save(); } //---- Appmodel var siteAppsFolder = Node.Load<SystemFolder>("/Root/TestSiteForAppModelTest/(apps)"); if (siteAppsFolder == null) { siteAppsFolder = new SystemFolder(site); siteAppsFolder.Name = "(apps)"; siteAppsFolder.Save(); } var siteAppsPageFolder = Node.Load<Folder>("/Root/TestSiteForAppModelTest/(apps)/Page"); if (siteAppsPageFolder == null) { siteAppsPageFolder = new SystemFolder(siteAppsFolder); siteAppsPageFolder.Name = "Page"; siteAppsPageFolder.Save(); } var siteAppsPageBrowsePage = Node.Load<Page>("/Root/TestSiteForAppModelTest/(apps)/Page/Browse"); if (siteAppsPageBrowsePage == null) { siteAppsPageBrowsePage = new Page(siteAppsPageFolder); siteAppsPageBrowsePage.Name = "Browse"; siteAppsPageBrowsePage.GetBinary("Binary").SetStream(Tools.GetStreamFromString("<html><body><h1>Page Browse App</h1></body></html>")); siteAppsPageBrowsePage.Save(); } var siteAppsPageEditPage = Node.Load<Page>("/Root/TestSiteForAppModelTest/(apps)/Page/Edit"); if (siteAppsPageEditPage == null) { siteAppsPageEditPage = new Page(siteAppsPageFolder); siteAppsPageEditPage.Name = "Edit"; siteAppsPageEditPage.GetBinary("Binary").SetStream(Tools.GetStreamFromString("<html><body><h1>Page EditPage</h1></body></html>")); siteAppsPageEditPage.Save(); } var siteAppsGenericContentFolder = Node.Load<Folder>("/Root/TestSiteForAppModelTest/(apps)/GenericContent"); if (siteAppsGenericContentFolder == null) { siteAppsGenericContentFolder = new SystemFolder(siteAppsFolder); siteAppsGenericContentFolder.Name = "GenericContent"; siteAppsGenericContentFolder.Save(); } var siteAppsGenericContentBrowsePage = Node.Load<Page>("/Root/TestSiteForAppModelTest/(apps)/GenericContent/Browse"); if (siteAppsGenericContentBrowsePage == null) { siteAppsGenericContentBrowsePage = new Page(siteAppsGenericContentFolder); siteAppsGenericContentBrowsePage.Name = "Browse"; siteAppsGenericContentBrowsePage.GetBinary("Binary").SetStream(Tools.GetStreamFromString("<html><body><h1>GenericContent Browse App</h1></body></html>")); siteAppsGenericContentBrowsePage.Save(); } var siteAppsGenericContentEditPage = Node.Load<Page>("/Root/TestSiteForAppModelTest/(apps)/GenericContent/Edit"); if (siteAppsGenericContentEditPage == null) { siteAppsGenericContentEditPage = new Page(siteAppsGenericContentFolder); siteAppsGenericContentEditPage.Name = "Edit"; siteAppsGenericContentEditPage.GetBinary("Binary").SetStream(Tools.GetStreamFromString("<html><body><h1>GenericContent EditPage</h1></body></html>")); siteAppsGenericContentEditPage.Save(); } //---- SelfDispatcher node var selfDispatcherContent = Node.Load<GenericContent>("/Root/TestSiteForAppModelTest/Home/SelfDispatcherContent1"); if (selfDispatcherContent == null) { selfDispatcherContent = new GenericContent(homePage, "WebContent"); selfDispatcherContent.Name = "SelfDispatcherContent1"; selfDispatcherContent.BrowseApplication = Node.LoadNode("/Root/TestSiteForAppModelTest/(apps)/GenericContent/Edit"); selfDispatcherContent.Save(); } }
private static Page EnsureSiteStartPage(Site site) { var startPageName = "Home"; var homePage = Node.Load<Page>(RepositoryPath.Combine(site.Path, startPageName)); if (homePage == null) { homePage = new Page(site); homePage.Name = startPageName; homePage.GetBinary("Binary").SetStream(Tools.GetStreamFromString("<html><body><h1>TestPage</h1></body></html>")); homePage.Save(); site.StartPage = homePage; site.Save(); } else if(site.StartPage == null) { site.StartPage = homePage; site.Save(); } return homePage; }
// Creating test node private Page CreateTestPage() { string testPagePath = RepositoryPath.Combine(_rootNodePath, _pageName); if (Node.Exists(testPagePath)) Node.ForceDelete(testPagePath); //if (Node.Exists("/Root/TestPage")) // Node.DeletePhysical("/Root/TestPage"); Page f = new Page(Node.LoadNode(_rootNodePath)); f.Name = _pageName; f.PageTemplateNode = PageTemplate.LoadNode(_pageTemplatePath) as PageTemplate; f.Save(); return f; }
public void Storage2_Bug_PageCheckin() { //Assert.Inconclusive("Approving off, None: CheckedOut ==> Publish"); var binData1 = "PageBinaryData_original"; var persData1 = "PersonalizationSettingsBinaryData_original"; var binData2 = "PageBinaryData_edited"; var persData2 = "PersonalizationSettingsBinaryData_edited"; var page = new Page(TestRoot); page.Name = "TestPage"; page.Binary = new BinaryData() { ContentType = "text/plain", FileName = "a.aspx" }; page.PersonalizationSettings = new BinaryData() { ContentType = "text/plain", FileName = "a.PersonalizationSettings" }; page.Binary.SetStream(Tools.GetStreamFromString(binData1)); page.PersonalizationSettings.SetStream(Tools.GetStreamFromString(persData1)); page.Save(); var pageId = page.Id; page.CheckOut(); page = Node.Load<Page>(pageId); page.Binary.SetStream(Tools.GetStreamFromString(binData2 + "bad")); page.PersonalizationSettings.SetStream(Tools.GetStreamFromString(persData2 + "bad")); page.Save(); page = Node.Load<Page>(pageId); page.Binary.SetStream(Tools.GetStreamFromString(binData2)); page.PersonalizationSettings.SetStream(Tools.GetStreamFromString(persData2)); page.Save(); page.CheckIn(); page = Node.Load<Page>(pageId); var bin = Tools.GetStreamString(page.Binary.GetStream()); var pers = Tools.GetStreamString(page.PersonalizationSettings.GetStream()); Assert.IsTrue(bin == binData2, "#1"); Assert.IsTrue(pers == persData2, "#2"); }
private Page CreatePage(string name) { Page page = Node.LoadNode(string.Concat(this.TestRoot.Path, "/", name)) as Page; if (page == null) { page = new Page(this.TestRoot); page.Name = name; page.Save(); } return page; }