public void Logger_Audit_Default() { Test(() => { // operations for a "content created" audit event var folder = new SystemFolder(Repository.Root) { Name = "Folder1" }; folder.Save(); var folderId = folder.Id; // operations for a "content modified" audit event folder = Node.Load <SystemFolder>(folderId); folder.Index++; folder.Save(); // operations for a "content deleted" audit event folder = Node.Load <SystemFolder>(folderId); folder.ForceDelete(); // load audit log entries var entries = DataStore.GetDataProviderExtension <ITestingDataProviderExtension>().LoadLastAuditLogEntries(10); var relatedEntries = entries.Where(e => e.ContentId == folderId).ToArray(); // assertions Assert.AreEqual(3, relatedEntries.Length); var messages = string.Join(", ", relatedEntries.Select(e => e.Message).ToArray()); Assert.AreEqual("ContentCreated, ContentUpdated, ContentDeleted", messages); }); }
public void InMemDb_Core_Create() { Node node; Test(() => { var lastNodeId = DataStore.GetDataProviderExtension <ITestingDataProviderExtension>().GetLastNodeIdAsync() .GetAwaiter().GetResult(); var root = Node.LoadNode(Identifiers.RootPath); node = new SystemFolder(root) { Name = "Node1", DisplayName = "Node 1" }; node.Save(); node = Node.Load <SystemFolder>(node.Id); Assert.AreEqual(lastNodeId + 1, node.Id); Assert.AreEqual("/Root/Node1", node.Path); }); }
public void SupplierIntegration_Save() { Test(() => { InstallSupplierContentType(); var root = new SystemFolder(Repository.Root); root.Save(); for (var i = 1; i < 10; i++) { var supplier = new Supplier(root) { Name = $"Supplier-{i}", Index = i, ContactName = $"Contact-{i}", ContactEmail = $"contact-{i}@example.com", ContactPhone = $"+36-20-12345{i:0#}", }; supplier.Save(); } var nodes = CreateSafeContentQuery("+TypeIs:Supplier +Index:>3 +Index:<8 .SORT:Name").Execute().Nodes; var allNames = string.Join(", ", nodes.Select(n => n.Name).ToArray()); Assert.AreEqual("Supplier-4, Supplier-5, Supplier-6, Supplier-7", allNames); }); }
public void ContentNaming_AutoIncrementOnDemand() { var root = new SystemFolder(TestRoot) { Name = Guid.NewGuid().ToString() }; root.Save(); var content1 = Content.CreateNew(ContentType_Car2Name, root, "ondemand"); content1.Save(); // take a non-autoincrement type, and save it with autoincrement bool typeNotAutoIncrement = false; var content2 = Content.CreateNew(ContentType_Car2Name, root, "ondemand"); try { content2.Save(); } catch (NodeAlreadyExistsException) { typeNotAutoIncrement = true; } Assert.IsTrue(typeNotAutoIncrement); // the type is non-autoincremental content2.ContentHandler.AllowIncrementalNaming = true; content2.Save(); Assert.AreEqual("ondemand(1)", content2.Name); // non-autoincremental type is saved autoincrementally }
public void ContentNaming_AllowIncrementalNaming_Disallowed() { Test(() => { var thrown = false; try { InstallContentTypes(); var testRoot = new SystemFolder(Repository.Root); testRoot.Save(); Content content1, content2; do { content1 = Content.CreateNew(ContentType_Car2Name, testRoot, null); content2 = Content.CreateNew(ContentType_Car2Name, testRoot, null); } while (content1.Name != content2.Name); content1.Save(); content2.Save(); } catch (NodeAlreadyExistsException) { thrown = true; } catch (AggregateException ae) { thrown = ae.InnerException is NodeAlreadyExistsException; } if (!thrown) { Assert.Fail("The expected NodeAlreadyExistsException was not thrown."); } }); }
public async Task L29_Query_MustShouldNot_Fulltext() { await L29Test(async() => { var indexPopulator = SearchManager.GetIndexPopulator(); using (new SystemAccount()) { var root = Repository.Root; await indexPopulator.RebuildIndexAsync(root, CancellationToken.None, false, IndexRebuildLevel.DatabaseAndIndex); var admin = User.Administrator; await indexPopulator.RebuildIndexAsync(admin, CancellationToken.None, false, IndexRebuildLevel.DatabaseAndIndex); var nameBase = "L29_Query_MustAndShould_Fulltext_"; var descriptions = new[] { "lucene", // 0 "dotnet", // 1 "jakarta", // 2 "lucene jakarta", // 3 "lucene dotnet", // 4 "dotnet jakarta", // 5 "lucene dotnet jakarta" // 6 }; var i = 0; foreach (var description in descriptions) { var node = new SystemFolder(root) { Name = $"{nameBase}{i++}", Description = description }; node.Save(); } string GetResult(string query) { var queryResult = CreateSafeContentQuery(query).Execute(); return(string.Join(", ", queryResult.Nodes.Select(x => x.Name.Last().ToString()).OrderBy(x => x))); } Assert.AreEqual("0, 3, 4, 6", GetResult("+lucene")); Assert.AreEqual("0, 3, 4, 6", GetResult("+lucene jakarta")); Assert.AreEqual("0, 3, 4, 6", GetResult("+lucene dotnet jakarta")); Assert.AreEqual("0, 1, 2, 3, 4, 5, 6", GetResult("lucene dotnet jakarta")); Assert.AreEqual("0, 3, 4, 6", GetResult("+lucene")); Assert.AreEqual("0, 4", GetResult("+lucene -jakarta")); Assert.AreEqual("0", GetResult("lucene -dotnet -jakarta")); Assert.AreEqual("4, 6", GetResult("+lucene +dotnet")); Assert.AreEqual("4", GetResult("+lucene +dotnet -jakarta")); Assert.AreEqual("0, 1, 3, 4, 5, 6", GetResult("lucene dotnet")); Assert.AreEqual("0, 1, 4", GetResult("lucene dotnet -jakarta")); } }); }
public void SystemFlag_OnFolderUnderSystemFolder() { IntegrationTest(() => { var root = new SystemFolder(Repository.Root) { Name = Guid.NewGuid().ToString() }; root.Save(); var folder = new Folder(root) { Name = Guid.NewGuid().ToString() }; folder.Save(); try { var x = Node.LoadNode(folder.Id); Assert.IsTrue(x.IsSystem); } finally { root.ForceDelete(); } }); }
private void SaveResources(string name, string xml) { var resNode = Node.Load <Resource>("/Root/Localization/" + name); if (resNode == null) { var parentNode = Node.LoadNode("/Root/Localization"); if (parentNode == null) { parentNode = new SystemFolder(Repository.Root, "Resources") { Name = "Localization" }; parentNode.Save(); } resNode = new Resource(parentNode) { Name = name }; } using (var stream = new MemoryStream()) { StreamWriter writer = new StreamWriter(stream, Encoding.UTF8); writer.Write(xml); writer.Flush(); resNode.Binary.SetStream(stream); resNode.Binary.FileName = "test"; resNode.Save(); } }
public void InMemDb_Create() { Node node; var result = Test(() => { var lastNodeId = ((InMemoryDataProvider)DataProvider.Current).LastNodeId; var root = Node.LoadNode(Identifiers.RootPath); node = new SystemFolder(root) { Name = "Node1", DisplayName = "Node 1" }; node.Save(); node = Node.Load <SystemFolder>(node.Id); return(new Tuple <int, Node>(lastNodeId, node)); }); var lastId = result.Item1; node = result.Item2; Assert.AreEqual(lastId + 1, node.Id); Assert.AreEqual("/Root/Node1", node.Path); }
/* ==================================================================================================== TOOLS */ private void MoveTest(Action <SystemFolder> callback) { try { Test(() => { if (ContentType.GetByName("Car") == null) { InstallCarContentType(); } var testRoot = new SystemFolder(Repository.Root) { Name = "MoveTest" }; testRoot.Save(); try { callback(testRoot); } finally { } }); } catch (AggregateException e) { if (e.InnerException == null) { throw; } throw e.InnerException; } }
public void Settings_WrongExtension() { var r = new SystemFolder(TestRoot) { Name = "R" }; r.Save(); try { var rS = new Folder(r) { Name = Settings.SETTINGSCONTAINERNAME }; rS.Save(); var rS1 = new Settings(rS) { Name = "Settings1" }; rS1.Binary.SetStream(Tools.GetStreamFromString("{x: 1, y: 2, z: 3}")); rS1.Save(); } finally { r.ForceDelete(); } }
public async Task L29_SaveAndQuery_ModificationDate() { await L29Test(async() => { var indexPopulator = SearchManager.GetIndexPopulator(); using (new SystemAccount()) { var root = Repository.Root; await indexPopulator.RebuildIndexAsync(root, CancellationToken.None, false, IndexRebuildLevel.DatabaseAndIndex); var admin = User.Administrator; await indexPopulator.RebuildIndexAsync(admin, CancellationToken.None, false, IndexRebuildLevel.DatabaseAndIndex); var nodeName = "L29_SaveAndQuery_ModificationDate"; var node = new SystemFolder(root) { Name = nodeName }; node.Save(); var date = node.ModificationDate.AddMinutes(-1.5); var value = date.ToString("yyyy-MM-dd HH:mm:ss"); var query = $"+Name:'{nodeName}' +ModificationDate:>'{value}' .TOP:5"; var queryResult = CreateSafeContentQuery(query).Execute(); Assert.IsTrue(1 <= queryResult.Count); } }); }
public void Indexing_ActivitySelector_Centralized_CSrv() { var searchEngine = new SearchEngineForActivityQueueSelectorTests(true); var indxManConsole = new StringWriter(); Test(builder => { var services = builder.Services; Configuration.Indexing.IsOuterSearchEngineEnabled = true; builder.UseSearchEngine(searchEngine); builder.SetConsole(indxManConsole); }, () => { searchEngine.ClearIndexingLog(); var nodeName = "Indexing_Centralized"; var node = new SystemFolder(Repository.Root) { Name = nodeName }; node.Save(); Assert.AreEqual("CENTRALIZED. deletions: 0, updates: 0, addition: 1\r\n", searchEngine.GetIndexingLog()); }); }
public void Indexing_ActivitySelector_Centralized() { var searchEngine = new SearchEngineForActivityQueueSelectorTests(true); var indxManConsole = new StringWriter(); Test(builder => { Configuration.Indexing.IsOuterSearchEngineEnabled = true; builder.UseSearchEngine(searchEngine); builder.SetConsole(indxManConsole); }, () => { using (new Swindler <SearchEngineSupport>(new SearchEngineSupport(), () => (SearchEngineSupport) new TypeAccessor(typeof(SearchManager)).GetStaticField( "_searchEngineSupport"), value => { new TypeAccessor(typeof(SearchManager)).SetStaticField("_searchEngineSupport", value); })) { searchEngine.ClearIndexingLog(); var nodeName = "Indexing_Centralized"; var node = new SystemFolder(Repository.Root) { Name = nodeName }; node.Save(); Assert.AreEqual("CENTRALIZED. deletions: 0, updates: 0, addition: 1\r\n", searchEngine.GetIndexingLog()); } }); }
public static void MyClassInitialize(TestContext testContext) { Folder f = new SystemFolder(Repository.Root); f.Save(); _rootNodePath = f.Path; CreateTestPageTemplate(); }
public void Indexing_Disallow() { Content content; ContentTypeInstaller.InstallContentType( @"<ContentType name=""NotIndexedCar"" parentType=""Car"" handler=""SenseNet.ContentRepository.GenericContent"" xmlns=""http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition""> <AllowIndexing>false</AllowIndexing><Fields><Field name=""SpecialData"" type=""ShortText"" /></Fields></ContentType>", @"<ContentType name=""NotIndexedSystemFolder"" parentType=""SystemFolder"" handler=""SenseNet.ContentRepository.GenericContent"" xmlns=""http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition""> <AllowedChildTypes>Car,NotIndexedCar</AllowedChildTypes> <AllowIndexing>false</AllowIndexing><Fields><Field name=""SpecialData"" type=""ShortText"" /></Fields></ContentType>"); var word = "SpecialWord"; var rootPath = TestRoot.Path + "/Indexing_RecoverStoredField"; if (Node.Exists(rootPath)) { Content.Delete(rootPath); } var root = new SystemFolder(TestRoot) { Name = "Indexing_RecoverStoredField" }; root.Save(); content = Content.CreateNew("Car", root, "Car1".ToString()); content["Description"] = word; content.Save(); var name1 = content.Name; content = Content.CreateNew("NotIndexedSystemFolder", root, "NotIndexedFolder1".ToString()); content["Description"] = word; content.Save(); var name2 = content.Name; var parent = content.ContentHandler; content = Content.CreateNew("NotIndexedCar", parent, "NotIndexedCar1".ToString()); content["Description"] = word; content.Save(); var name3 = content.Name; content = Content.CreateNew("Car", parent, "Car2".ToString()); content["Description"] = word; content.Save(); var name4 = content.Name; var expected = String.Join(", ", new[] { name1, name4 }); var actual = String.Join(", ", ContentQuery.Query("+InTree:'" + root.Path + "' +Description:" + word + " .AUTOFILTERS:OFF").Nodes.Select(n => n.Name)); Assert.AreEqual(expected, actual); Assert.IsNotNull(Node.LoadNode(root.Path + "/NotIndexedFolder1")); Assert.IsNotNull(Node.LoadNode(root.Path + "/NotIndexedFolder1/NotIndexedCar1")); Assert.IsNotNull(Node.LoadNode(root.Path + "/NotIndexedFolder1/Car2")); }
public async Task Test_WithRelatedContentType() { var contentTypeTemplate = @"<?xml version='1.0' encoding='utf-8'?> <ContentType name='{0}' parentType='{1}' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'> <AllowedChildTypes>{2}</AllowedChildTypes> </ContentType>"; await DeleteContentTypeTest(() => { // init var contentTypeCount = GetContentTypeCount(); InstallCarContentType(); ContentTypeInstaller.InstallContentType( string.Format(contentTypeTemplate, "Car1", "Car", ""), string.Format(contentTypeTemplate, "Car2", "Car", ""), string.Format(contentTypeTemplate, "Garage1", "GenericContent", "Car,Folder"), string.Format(contentTypeTemplate, "Garage2", "GenericContent", "Folder,Car2")); var root = new SystemFolder(Repository.Root) { Name = "TestRoot" + Guid.NewGuid() }; root.Save(); // test-1 var step = new DeleteContentType { Name = "Car", Delete = DeleteContentType.Mode.Force }; var dependencies = step.GetDependencies(new[] { "Car" }); Assert.AreEqual(0, dependencies.InstanceCount); Assert.AreEqual(2, dependencies.PermittingContentTypes.Length); Assert.AreEqual(0, dependencies.PermittingFieldSettings.Length); Assert.AreEqual(0, dependencies.PermittingContentCollection.Count); Assert.AreEqual(0, dependencies.Applications.Length); Assert.AreEqual(0, dependencies.ContentTemplates.Length); Assert.AreEqual(0, dependencies.ContentViews.Length); // test-2 step.Execute(GetExecutionContext()); Assert.IsNull(ContentType.GetByName("Car")); Assert.IsNull(ContentType.GetByName("Car1")); Assert.IsNull(ContentType.GetByName("Car2")); Assert.AreEqual(contentTypeCount + 2, GetContentTypeCount()); var names = new[] { "Car", "Car1", "Car2" }; var garage1 = ContentType.GetByName("Garage1"); Assert.IsFalse(garage1.AllowedChildTypeNames.Intersect(names).Any()); var garage2 = ContentType.GetByName("Garage2"); Assert.IsFalse(garage1.AllowedChildTypeNames.Intersect(names).Any()); return(Task.CompletedTask); }); }
private SystemFolder CreateTestRoot() { var node = new SystemFolder(Repository.Root) { Name = Guid.NewGuid().ToString() }; node.Save(); return(node); }
private SystemFolder CreateTestFolder() { var folder = new SystemFolder(Repository.Root) { Name = Guid.NewGuid().ToString() }; folder.Save(); return(folder); }
//UNDONE:<?IntT: Consider the instructions in the following block //public void IntegrationTest(Action callback) //{ // Cache.Reset(); // ContentTypeManager.Reset(); // //Providers.Instance.NodeTypeManeger = null; // var builder = _implementation.CreateRepositoryBuilder(); // Indexing.IsOuterSearchEngineEnabled = true; // Cache.Reset(); // ContentTypeManager.Reset(); // using (Repository.Start(builder)) // using (new SystemAccount()) // callback(); //} /* ==================================================================== */ protected SystemFolder CreateSandbox() { var sandbox = new SystemFolder(Repository.Root) { Name = Guid.NewGuid().ToString() }; sandbox.Save(); return(sandbox); }
protected static SystemFolder CreateTestRoot(Node parent, string name = null) { var systemFolder = new SystemFolder(parent ?? Repository.Root) { Name = name ?? Guid.NewGuid().ToString() }; systemFolder.Save(); return(systemFolder); }
/* ================================================================================== TOOLS */ protected Node CreateTestRoot() { var root = new SystemFolder(Repository.Root) { Name = Guid.NewGuid().ToString() }; root.Save(); return(root); }
private GenericContent CreateTestRoot() { var node = new SystemFolder(Repository.Root) { Name = "_IndexingTests" }; node.Save(); return(node); }
protected static SystemFolder CreateTestRoot(Node parent, string name = null, bool trashDisabled = false) { var systemFolder = new SystemFolder(parent ?? Repository.Root) { Name = name ?? Guid.NewGuid().ToString(), TrashDisabled = trashDisabled }; systemFolder.Save(); return(systemFolder); }
protected void CreateTestStructure() { CreateTestSite(); // root // sites // ODataTestSite // F0 // F00 // F000 // SF01(SYSTEM) // SF1(SYSTEM) // F10 var testSite = Node.Load <Site>(TestSitePath); var folder0 = new Folder(testSite) { Name = "F0" }; folder0.Save(); var folder00 = new Folder(folder0) { Name = "F00" }; folder00.Save(); var folder000 = new Folder(folder00) { Name = "F000" }; folder000.Save(); var systemFolder01 = new SystemFolder(folder0) { Name = "SF01" }; systemFolder01.Save(); var systemFolder1 = new SystemFolder(testSite) { Name = "SF1" }; systemFolder1.Save(); var folder10 = new Folder(systemFolder1) { Name = "F10" }; folder10.Save(); }
public static SystemFolder GetPortletFolder() { var parent = Node.LoadNode(PortletsFolderPath); if (parent == null) { // new portletsDir parent = new SystemFolder(Node.LoadNode("/Root")); parent.Name = "Portlets"; parent.Save(); } return(parent as SystemFolder); }
// ============================================================================================= private GenericContent CreateTestRoot(bool save = true) { var node = new SystemFolder(Repository.Root) { Name = "_AspectTests" }; if (save) { node.Save(); } return(node); }
protected GenericContent CreateTestRoot(bool save = true) { var node = new SystemFolder(Repository.Root) { Name = Guid.NewGuid().ToString() }; if (save) { node.Save(); } return(node); }
public void ContentNaming_IncrementNameSuffixOnSaveWithExtension() { var root = new SystemFolder(TestRoot) { Name = Guid.NewGuid().ToString() }; root.Save(); // increment check var content1 = Content.CreateNew(ContentType_Car1Name, root, "mycar.xml"); content1.Save(); var content2 = Content.CreateNew(ContentType_Car1Name, root, "mycar.xml"); content2.Save(); var content3 = Content.CreateNew(ContentType_Car1Name, root, "mycar.xml"); content3.Save(); Assert.AreEqual("mycar.xml", content1.Name); // if mycar does not exist, name does not change Assert.AreEqual("mycar(1).xml", content2.Name); // first increment Assert.AreEqual("mycar(2).xml", content3.Name); // second increment // 9 - 10 order problem: if mycar(9) and mycar(10) exists, mycar(11) is the next even though 10 is smaller than 9 if compared as strings Content.CreateNew(ContentType_Car1Name, root, "mycar(9).xml").Save(); Content.CreateNew(ContentType_Car1Name, root, "mycar(10).xml").Save(); var content4 = Content.CreateNew(ContentType_Car1Name, root, "mycar.xml"); content4.Save(); Assert.IsTrue(content4.Name == "mycar(11).xml"); // (string) suffix problem 1: string(test) should be incremented to string(test)(1) var content5 = Content.CreateNew(ContentType_Car1Name, root, "string(test).xml"); content5.Save(); var content6 = Content.CreateNew(ContentType_Car1Name, root, "string(test).xml"); content6.Save(); Assert.AreEqual("string(test).xml", content5.Name); // if string(test) does not exist, name does not change Assert.AreEqual("string(test)(1).xml", content6.Name); // first increment // (string) suffix problem 2: string should be incremented to string(guid), since string(test) already exists var content7 = Content.CreateNew(ContentType_Car1Name, root, "string.xml"); content7.Save(); var content8 = Content.CreateNew(ContentType_Car1Name, root, "string.xml"); content8.Save(); Assert.AreEqual("string.xml", content7.Name); Assert.AreEqual("string(1).xml", content8.Name); }
private void DeletionPolicy_TheTest() { using (new SystemAccount()) { // Create a small subtree var root = new SystemFolder(Repository.Root) { Name = "TestRoot" }; root.Save(); var f1 = new SystemFolder(root) { Name = "F1" }; f1.Save(); for (int i = 0; i < 5; i++) { var f2 = new File(root) { Name = $"F2-{i}" }; f2.Binary.SetStream(RepositoryTools.GetStreamFromString("filecontent")); f2.Save(); } var f3 = new SystemFolder(f1) { Name = "F3" }; f3.Save(); for (int i = 0; i < 5; i++) { var f4 = new File(root) { Name = $"F4-{i}" }; f4.Binary.SetStream(RepositoryTools.GetStreamFromString("filecontent")); f4.Save(); } // ACTION Node.ForceDelete(root.Path); // ASSERT //Assert.IsNull(Node.Load<SystemFolder>(root.Id)); //Assert.IsNull(Node.Load<SystemFolder>(f1.Id)); //Assert.IsNull(Node.Load<File>(f2.Id)); //Assert.IsNull(Node.Load<SystemFolder>(f3.Id)); //Assert.IsNull(Node.Load<File>(f4.Id)); } }
public static Folder CreateFolder(string name, Folder parent) { Folder folder = null; string path = RepositoryPath.Combine(parent.Path, name); folder = Node.LoadNode(path) as Folder; if (folder == null) { folder = new SystemFolder(parent); folder.Name = name; folder.Save(); AddPathToDelete(path); } return folder; }
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 void CreatePlayGround() { DestroyPlayground(); // /Root // | // +-ContentTemplates // | | // | +-File // | | | // | | +-file1.txt // | | // | +-ContentList // | | // | +-list1 // | // +-CTemplateTests // | // +-CtSite // | | // | +-ContentTemplates // | | | // | | +-File // | | | // | | +-file1.txt // | | // | +-CtWorkspace1 // | | | // | | +-ContentTemplates // | | | | // | | | +-ContentList // | | | | // | | | +-list1 // | | +-CtList1 // | | | | // | | | +-ContentTemplates // | | | | // | | | +-File // | | | | // | | | +-file1.txt // | | +-CtList2 // | | // | +-CtWorkspace2 // | // +-CtWorkspace3 //global template folder var ctfGlobal = Node.LoadNode(Repository.ContentTemplateFolderPath); if (ctfGlobal == null) { ctfGlobal = new SystemFolder(Node.LoadNode("/Root")) {Name = Repository.ContentTemplatesFolderName}; ctfGlobal.Save(); } //create GLOBAL content template type folders var folderGlobalCtFile1 = Node.Load<Folder>(RepositoryPath.Combine(ctfGlobal.Path, "File")); if (folderGlobalCtFile1 == null) { folderGlobalCtFile1 = new Folder(ctfGlobal) { Name = "File" }; folderGlobalCtFile1.Save(); } var folderGlobalCtList1 = Node.Load<Folder>(RepositoryPath.Combine(ctfGlobal.Path, "ContentList")); if (folderGlobalCtList1 == null) { folderGlobalCtList1 = new Folder(ctfGlobal) { Name = "ContentList" }; folderGlobalCtList1.Save(); } //create GLOBAL content templates _fileGlobalTemplate1 = Node.Load<File>(RepositoryPath.Combine(folderGlobalCtFile1.Path, _testFileName)); if (_fileGlobalTemplate1 == null) { _fileGlobalTemplate1 = new File(folderGlobalCtFile1) { Name = _testFileName, Index = 30 }; _fileGlobalTemplate1.Save(); } _listGlobalTemplate1 = Node.Load<ContentList>(RepositoryPath.Combine(folderGlobalCtList1.Path, _testListTemplateName)); if (_listGlobalTemplate1 == null) { _listGlobalTemplate1 = new ContentList(folderGlobalCtList1) { Name = _testListTemplateName, Index = 30 }; _listGlobalTemplate1.Save(); } //create site, workspace and list var site = new Site(TestRoot) {Name = "CtSite"}; site.UrlList.Add("mytemplatetestinterneturl", "Forms"); site.Save(); var ws = new Workspace(site) { Name = "CtWorkspace2", AllowedChildTypes = new List<ContentType> { ContentType.GetByName("ContentList"), ContentType.GetByName("Workspace"), ContentType.GetByName("File") } }; ws.Save(); ws = new Workspace(TestRoot) { Name = "CtWorkspace3", AllowedChildTypes = new List<ContentType> { ContentType.GetByName("ContentList"), ContentType.GetByName("Workspace"), ContentType.GetByName("File") } }; ws.Save(); ws = new Workspace(site) { Name = "CtWorkspace1", AllowedChildTypes = new List<ContentType> { ContentType.GetByName("ContentList"), ContentType.GetByName("Workspace") } }; ws.Save(); _list1 = new ContentList(TestWorkspace) { Name = "CtList1", AllowedChildTypes = new List<ContentType> { ContentType.GetByName("File") } }; _list1.Save(); _list2 = new ContentList(TestWorkspace) { Name = "CtList2", AllowedChildTypes = new List<ContentType> { ContentType.GetByName("File") } }; _list2.Save(); //create content template folders var ctfSite = new SystemFolder(site) {Name = Repository.ContentTemplatesFolderName}; ctfSite.Save(); var ctfWs = new SystemFolder(TestWorkspace) { Name = Repository.ContentTemplatesFolderName }; ctfWs.Save(); var ctfList = new SystemFolder(_list1) { Name = Repository.ContentTemplatesFolderName }; ctfList.Save(); //create content template type folders var folderCtFile1 = new Folder(ctfSite) {Name = "File"}; folderCtFile1.Save(); var folderCtL1 = new Folder(ctfWs) { Name = "ContentList" }; folderCtL1.Save(); var folderCtFile2 = new Folder(ctfList) { Name = "File" }; folderCtFile2.Save(); //create content templates _fileTemplate1 = new File(folderCtFile1) {Name = _testFileName, Index = 10 }; _fileTemplate1.Save(); _fileTemplate2 = new File(folderCtFile2) { Name = _testFileName, Index = 20 }; _fileTemplate2.Save(); _listTemplate1 = new ContentList(folderCtL1) { Name = _testListTemplateName, Index = 10 }; _listTemplate1.Save(); }
//======================================================================== tools private static void CreateResourceFile() { // /Root/Localization/MessageTemplateResources.xml var locFolder = Node.LoadNode("/Root/Localization"); if (locFolder == null) { locFolder = new SystemFolder(Repository.Root); locFolder.Name = "Localization"; locFolder.Save(); } var resFile = new SenseNet.ContentRepository.i18n.Resource(locFolder); resFile.Name = "MessageTemplateResources.xml"; var binData = new BinaryData(); binData.SetStream(Tools.GetStreamFromString(_resFileSrc)); resFile.SetBinary("Binary", binData); resFile.Save(); }
public static void CreateSandbox(TestContext testContext) { var site = new Site(Repository.Root); site.Name = "TestSiteForActionFramework"; var urlList = new Dictionary<string, string>(); urlList.Add("newtesthost", "Windows"); site.UrlList = urlList; site.Save(); //---- Appmodel //------------- //Root/TestRoot/(apps) var siteAppsFolder = new SystemFolder(site); siteAppsFolder.Name = "(apps)"; siteAppsFolder.Save(); //---- Folder //----------- // /TestRoot/(apps)/Folder var siteAppsFolderFolder = new SystemFolder(siteAppsFolder); siteAppsFolderFolder.Name = "Folder"; siteAppsFolderFolder.Save(); // /TestRoot/(apps)/Folder/App1 var siteAppsApp1 = new Application(siteAppsFolderFolder); siteAppsApp1.Name = "App1"; siteAppsApp1.Scenario = "sc1,sc4,sc5"; siteAppsApp1.Save(); // /TestRoot/(apps)/Folder/App2 var siteAppsApp2 = new Application(siteAppsFolderFolder); siteAppsApp2.Name = "App2"; siteAppsApp2.Scenario = "sc1,Settings"; siteAppsApp2.Save(); // TestRoot/(apps)/Folder/App3 var siteAppsApp3 = new Application(siteAppsFolderFolder); siteAppsApp3.Name = "App3"; siteAppsApp3.Scenario = "sc1,sc2,sc7,sc10"; siteAppsApp3.RequiredPermissions = "5"; siteAppsApp3.Save(); // TestRoot/(apps)/Folder/App4 var siteAppsApp4 = new Application(siteAppsFolderFolder); siteAppsApp4.Name = "App4"; siteAppsApp4.Scenario = "sc2,sc6,sc10"; siteAppsApp4.RequiredPermissions = "5"; siteAppsApp4.Save(); //Root/TestRoot/(apps)/Folder/App5 var siteAppsApp5 = new Application(siteAppsFolderFolder); siteAppsApp5.Name = "App5"; siteAppsApp5.Scenario = "sc11"; siteAppsApp5.RequiredPermissions = "5;10;11"; siteAppsApp5.Save(); //Root/TestRoot/(apps)/Folder/App6 var siteAppsApp6 = new Application(siteAppsFolderFolder); siteAppsApp6.Name = "App6"; siteAppsApp6.Scenario = "sc12"; siteAppsApp6.Save(); //Root/TestRoot/(apps)/Folder/App12 var siteSampleAppsApp12 = new Application(siteAppsFolderFolder); siteSampleAppsApp12.Name = "App12"; siteSampleAppsApp12.Scenario = "sc20"; siteSampleAppsApp12.Save(); //Root/TestRoot/(apps)/Folder/App21 var siteSampleAppsApp21 = new Application(siteAppsFolderFolder); siteSampleAppsApp21.Name = "App21"; siteSampleAppsApp21.Scenario = "sc21"; siteSampleAppsApp21.Save(); //Root/TestRoot/(apps)/Folder/App22 var siteSampleAppsApp22 = new Application(siteAppsFolderFolder); siteSampleAppsApp22.Name = "App22"; siteSampleAppsApp22.Scenario = "sc22"; siteSampleAppsApp22.Save(); //Root/TestRoot/(apps)/Folder/App23 var siteSampleAppsApp23 = new Application(siteAppsFolderFolder); siteSampleAppsApp23.Name = "App23"; siteSampleAppsApp23.Scenario = "sc23"; siteSampleAppsApp23.Disabled = true; siteSampleAppsApp23.Save(); //Root/TestRoot/(apps)/Folder/App24 var siteSampleAppsApp24 = new Application(siteAppsFolderFolder); siteSampleAppsApp24.Name = "App24"; siteSampleAppsApp24.Scenario = "sc24"; siteSampleAppsApp24.Disabled = true; siteSampleAppsApp24.Clear = true; siteSampleAppsApp24.Save(); //Root/TestRoot/(apps)/Folder/App25 var siteSampleAppsApp25 = new Application(siteAppsFolderFolder); siteSampleAppsApp25.Name = "App25"; siteSampleAppsApp25.Scenario = "sc25"; siteSampleAppsApp25.Save(); //Root/TestRoot/Sample var siteSample = new SystemFolder(site); siteSample.Name = "Sample"; siteSample.Save(); //---- ContentList //---------------- //Root/TestRoot/(apps)/ContentList var siteAppsFolderContentList = new SystemFolder(siteAppsFolder); siteAppsFolderContentList.Name = "ContentList"; siteAppsFolderContentList.Save(); //Root/TestRoot/Sample2 var siteSample2 = new ContentList(site); siteSample2.Name = "Sample2"; siteSample2.Save(); //Root/TestRoot/(apps)/ContentList/App1 var siteAppsContentListOverrideApp1 = new Application(siteAppsFolderContentList); siteAppsContentListOverrideApp1.Name = "App1"; siteAppsContentListOverrideApp1.Scenario = "sc4,sc5"; siteAppsContentListOverrideApp1.Save(); //Root/TestRoot/(apps)/ContentList/ContentListApp1 var siteAppsContentListApp1 = new Application(siteAppsFolderContentList); siteAppsContentListApp1.Name = "ContentListApp1"; siteAppsContentListApp1.Scenario = "sc2,sc10"; siteAppsContentListApp1.Save(); //Root/TestRoot/Apps/ContentList/ContentListApp2 var siteAppsContentListApp2 = new Application(siteAppsFolderContentList); siteAppsContentListApp2.Name = "ContentListApp2"; siteAppsContentListApp2.Scenario = "sc1"; siteAppsContentListApp2.Save(); //Root/TestRoot/(apps)/ContentList/ContentListApp3 var siteAppsContentListApp3 = new Application(siteAppsFolderContentList); siteAppsContentListApp3.Name = "ContentListApp3"; siteAppsContentListApp3.Scenario = "sc1,sc2,sc3,mySettings"; siteAppsContentListApp3.Save(); //Root/TestRoot/(apps)/ContentList/App6 var siteAppsContentListOverrideApp6 = new Application(siteAppsFolderContentList); siteAppsContentListOverrideApp6.Name = "App6"; siteAppsContentListOverrideApp6.Scenario = "sc12"; siteAppsContentListOverrideApp6.RequiredPermissions = "11"; siteAppsContentListOverrideApp6.Save(); //---- This structure under Sample //-------------------------------- //Root/TestRoot/Sample/(apps) var siteSampleApps = new SystemFolder(siteSample); siteSampleApps.Name = "(apps)"; siteSampleApps.Save(); //Root/TestRoot/Sample/(apps)/This var siteSampleAppsThis = new SystemFolder(siteSampleApps); siteSampleAppsThis.Name = "This"; siteSampleAppsThis.Save(); //Root/TestRoot/Sample/(apps)/This/App12 var siteSampleAppsThisApp12 = new Application(siteSampleAppsThis); siteSampleAppsThisApp12.Name = "App12"; siteSampleAppsThisApp12.Scenario = "sc20"; siteSampleAppsThisApp12.Save(); //Root/TestRoot/Sample/(apps)/Folder var siteSampleAppsFolder = new SystemFolder(siteSampleApps); siteSampleAppsFolder.Name = "Folder"; siteSampleAppsFolder.Save(); //Root/TestRoot/Sample/(apps)/Folder/App21 var siteSampleAppsFolderApp21 = new Application(siteSampleAppsFolder); siteSampleAppsFolderApp21.Name = "App21"; siteSampleAppsFolderApp21.Scenario = "sc21"; siteSampleAppsFolderApp21.Save(); //Root/TestRoot/Sample/(apps)/Folder/App22 var siteSampleAppsFolderApp22 = new Application(siteSampleAppsFolder); siteSampleAppsFolderApp22.Name = "App22"; siteSampleAppsFolderApp22.Scenario = "sc22"; siteSampleAppsFolderApp22.Disabled = true; siteSampleAppsFolderApp22.Save(); //Root/TestRoot/Sample/(apps)/Folder/App23 var siteSampleAppsFolderApp23 = new Application(siteSampleAppsFolder); siteSampleAppsFolderApp23.Name = "App23"; siteSampleAppsFolderApp23.Scenario = "sc23"; siteSampleAppsFolderApp23.Disabled = true; siteSampleAppsFolderApp23.Save(); //Root/TestRoot/Sample/(apps)/Folder/App24 var siteSampleAppsFolderApp24 = new Application(siteSampleAppsFolder); siteSampleAppsFolderApp24.Name = "App24"; siteSampleAppsFolderApp24.Scenario = "sc24"; siteSampleAppsFolderApp24.RequiredPermissions = "5"; siteSampleAppsFolderApp24.Save(); //Root/TestRoot/Sample/(apps)/Folder/App25 var siteSampleAppsFolderApp25 = new Application(siteSampleAppsFolder); siteSampleAppsFolderApp25.Name = "App25"; siteSampleAppsFolderApp25.Scenario = "sc25"; siteSampleAppsFolderApp25.Clear = true; siteSampleAppsFolderApp25.Save(); // ---- Subfolder // -------------- //Root/TestRoot/Sample/SubFolder var siteSampleSubFolder = new SystemFolder(siteSample); siteSampleSubFolder.Name = "SubFolder"; siteSampleSubFolder.Save(); //Root/TestRoot/Sample/SubFolder/(apps) var siteSampleSubFolderApps = new SystemFolder(siteSampleSubFolder); siteSampleSubFolderApps.Name = "(apps)"; siteSampleSubFolderApps.Save(); //Root/TestRoot/Sample/SubFolder/(apps)/This var siteSampleSubFolderAppsThis = new SystemFolder(siteSampleSubFolderApps); siteSampleSubFolderAppsThis.Name = "This"; siteSampleSubFolderAppsThis.Save(); //Root/TestRoot/Sample/SubFolder/(apps)/This/App24 var siteSampleSubFolderAppsThisApp24 = new Application(siteSampleSubFolderAppsThis); siteSampleSubFolderAppsThisApp24.Name = "App24"; siteSampleSubFolderAppsThisApp24.Scenario = "sc24"; siteSampleSubFolderAppsThisApp24.Disabled = true; siteSampleSubFolderAppsThisApp24.Save(); }