public void ConvertGlobalVirtualPathToTreeVirtualPath_ReturnsExpectedValue_WhenTreeIsAtRoot()
 {
     using (var testTree = new TestSfsTree())
     {
         Assert.Equal("/sitecore/hello", testTree.ConvertGlobalPathToTreePathTest("/sitecore/hello"));
     }
 }
 public void ConvertGlobalVirtualPathToTreeVirtualPath_ReturnsExpectedValue_WhenTreeIsNested()
 {
     using (var testTree = new TestSfsTree("/sitecore/content/templates"))
     {
         Assert.Equal("/templates/User Defined", testTree.ConvertGlobalPathToTreePathTest("/sitecore/content/templates/User Defined"));
     }
 }
Пример #3
0
        private void CreateTestTree(string treePath, TestSfsTree tree)
        {
            var localPath = tree.ConvertGlobalPathToTreePathTest(treePath)
                .TrimStart('/')
                .Split('/');

            var contextPath = string.Empty;
            Guid currentParentId = default(Guid);

            foreach (var pathPiece in localPath)
            {
                // the first path piece will equal the last segment in the global root - don't double append
                if (pathPiece != localPath[0])
                    contextPath += "/" + pathPiece;

                var item = CreateTestItem(tree.GlobalRootItemPath + contextPath, currentParentId);

                currentParentId = item.Id;

                tree.Save(item);
            }
        }