Exemplo n.º 1
0
 public void ContainsPath_ReturnsFalse_WhenNotIncludedPath()
 {
     using (var testTree = new TestSfsTree())
     {
         Assert.False(testTree.ContainsPath("/umbraco/aem"));
     }
 }
Exemplo n.º 2
0
        public void Save_WritesItem_WhenPathRequiresDoubleLoopbackFolder()
        {
            using (var testTree = new TestSfsTree())
            {
                // force the tree to loopback after only 10 chars after the root path
                // this also means that double loopback occurs each time because the loopback ID is 35 chars
                testTree.MaxPathLengthForTests = 10;

                testTree.CreateTestTree("/sitecore/content/hello");

                var rootItem = testTree.GetRootItem();

                var loopedItem = testTree.GetChildren(rootItem).First();

                var secondLoopedItem = testTree.GetChildren(loopedItem).First();

                Assert.Equal("/sitecore/content", loopedItem.Path);
                // loopback path will have root item ID in it
                Assert.True(loopedItem.SerializedItemId.Contains(rootItem.Id.ToString()));

                Assert.Equal("/sitecore/content/hello", secondLoopedItem.Path);
                // loopback path will have root item ID in it
                Assert.True(secondLoopedItem.SerializedItemId.Contains(loopedItem.Id.ToString()));
            }
        }
Exemplo n.º 3
0
        public void GetChildren_ReturnsExpectedItems_WhenMultipleMatchesExist_ThroughSeparateParents()
        {
            using (var testTree = new TestSfsTree())
            {
                const string treePath = "/sitecore/templates/User Defined";

                testTree.CreateTestTree(treePath);

                var testItem = testTree.GetItemsByPath("/sitecore/templates");

                var templates1 = testItem.First();

                // add a second Templates item
                var templates2 = "/sitecore/templates".AsTestItem(templates1.ParentId);
                testTree.Save(templates2);

                // add a child under the second templates item, giving us '/sitecore/templates/User Defined' under templates1, and '/sitecore/templates/Evil' under templates2
                // P.S. don't actually do this in real life. Please? But I'm testing it, because I'm an effing pedant :)
                testTree.Save("/sitecore/templates/Evil".AsTestItem(templates2.Id));

                // get the children of templates1, which should NOT include templates2's child
                var results = testTree.GetChildren(templates1).ToArray();

                Assert.Equal(1, results.Length);
                Assert.Equal("User Defined", results[0].Name);
            }
        }
Exemplo n.º 4
0
        public void GetChildren_ReturnsExpectedItems_WhenNameTruncationCausesSimilarNames()
        {
            using (var testTree = new TestSfsTree())
            {
                testTree.MaxFileNameLengthForTests = 10;

                const string treePath = "/sitecore/templates";
                testTree.CreateTestTree(treePath);

                var testItem = testTree.GetItemsByPath(treePath).First();

                var multilist           = "/sitecore/templates/Multilist".AsTestItem(testItem.Id);
                var multilistWithSearch = "/sitecore/templates/Multilist with Search".AsTestItem(testItem.Id);

                var multilistChild           = "/sitecore/templates/Multilist/Menu".AsTestItem(multilist.Id);
                var multilistWithSearchChild = "/sitecore/templates/Multilist with Search/Menu".AsTestItem(multilistWithSearch.Id);

                testTree.Save(multilist);
                testTree.Save(multilistWithSearch);
                testTree.Save(multilistChild);
                testTree.Save(multilistWithSearchChild);

                // now we'll have "Multilist.yml" and "Multilist .yml" - make sure we get the right children from each

                // get the children of the root, which should include the two same named items
                var multilistChildren           = testTree.GetChildren(multilist).ToArray();
                var multilistWithSearchChildren = testTree.GetChildren(multilistWithSearch).ToArray();

                Assert.Equal(1, multilistChildren.Length);
                Assert.Equal(multilistChild.Id, multilistChildren.First().Id);
                Assert.Equal(1, multilistWithSearchChildren.Length);
                Assert.Equal(multilistWithSearchChild.Id, multilistWithSearchChildren.First().Id);
            }
        }
Exemplo n.º 5
0
 public void ContainsPath_ReturnsTrue_WhenExpectedPath_ContainingInvalidFileSystemChars()
 {
     using (var testTree = new TestSfsTree("/sitecore/content"))
     {
         Assert.True(testTree.ContainsPath("/sitecore/content/$he\\llo%<html>"));
     }
 }
Exemplo n.º 6
0
 public void ContainsPath_ReturnsTrue_WhenPathIsRoot()
 {
     using (var testTree = new TestSfsTree())
     {
         Assert.True(testTree.ContainsPath("/sitecore/content"));
     }
 }
		public void ContainsPath_ReturnsTrue_WhenPathIsRoot()
		{
			using (var testTree = new TestSfsTree())
			{
				Assert.True(testTree.ContainsPath("/sitecore/content"));
			}
		}
Exemplo n.º 8
0
 public void ContainsPath_ReturnsTrue_WhenExpectedPath()
 {
     using (var testTree = new TestSfsTree("/sitecore/content"))
     {
         Assert.True(testTree.ContainsPath("/sitecore/content/hello"));
     }
 }
Exemplo n.º 9
0
 public void ConvertGlobalVirtualPathToTreeVirtualPath_ReturnsExpectedValue_WhenTreeIsAtRoot()
 {
     using (var testTree = new TestSfsTree())
     {
         Assert.Equal("/sitecore/hello", testTree.ConvertGlobalVirtualPathToTreeVirtualPath("/sitecore/hello"));
     }
 }
 public void PrepareItemNameForFileSystem_FiltersIllegalCharacters(string input, string expectedOutput)
 {
     using (var testTree = new TestSfsTree())
     {
         Assert.Equal(expectedOutput, testTree.PrepareItemNameForFileSystemTest(input));
     }
 }
		public void ConvertGlobalVirtualPathToTreeVirtualPath_ReturnsExpectedValue_WhenTreeIsNested()
		{
			using (var testTree = new TestSfsTree("/sitecore/content/templates"))
			{
				Assert.Equal("/templates/User Defined", testTree.ConvertGlobalVirtualPathToTreeVirtualPath("/sitecore/content/templates/User Defined"));
			}
		}
Exemplo n.º 12
0
 public void ConvertGlobalVirtualPathToTreeVirtualPath_ReturnsExpectedValue_WhenTreeIsNested()
 {
     using (var testTree = new TestSfsTree("/sitecore/content/templates"))
     {
         Assert.Equal("/templates/User Defined", testTree.ConvertGlobalVirtualPathToTreeVirtualPath("/sitecore/content/templates/User Defined"));
     }
 }
 public void PrepareItemNameForFileSystem_FiltersIllegalCharacters(string input, string expectedOutput)
 {
     using (var testTree = new TestSfsTree())
     {
         Assert.Equal(expectedOutput, testTree.PrepareItemNameForFileSystemTest(input));
     }
 }
		public void ConvertGlobalVirtualPathToTreeVirtualPath_ReturnsExpectedValue_WhenTreeIsAtRoot()
		{
			using (var testTree = new TestSfsTree())
			{
				Assert.Equal("/sitecore/hello", testTree.ConvertGlobalVirtualPathToTreeVirtualPath("/sitecore/hello"));
			}
		}
Exemplo n.º 15
0
        public void GetChildren_ReturnsExpectedItems_WhenMultipleMatchesExist_ThroughSeparateParents()
        {
            using (var testTree = new TestSfsTree())
            {
                const string treePath = "/sitecore/templates/User Defined";

                CreateTestTree(treePath, testTree);

                var testItem = testTree.GetItemsByPath("/sitecore/templates");

                var templates1 = testItem.First();

                // add a second Templates item
                var templates2 = CreateTestItem("/sitecore/templates", templates1.ParentId);
                testTree.Save(templates2);

                // add a child under the second templates item, giving us '/sitecore/templates/User Defined' under templates1, and '/sitecore/templates/Evil' under templates2
                // P.S. don't actually do this in real life. Please? But I'm testing it, because I'm an effing pedant :)
                testTree.Save(CreateTestItem("/sitecore/templates/Evil", templates2.Id));

                // get the children of templates1, which should NOT include templates2's child
                var results = testTree.GetChildren(templates1).ToArray();

                Assert.Equal(1, results.Length);
                Assert.Equal("User Defined", results[0].Name);
            }
        }
        public void GetItemsByPath_ReturnsExpectedItems_WhenChildPathIsRequested_AndMultipleMatchesExist_ThroughSeparateParents()
        {
            using (var testTree = new TestSfsTree())
            {
                const string treePath = "/sitecore/templates/User Defined";

                testTree.CreateTestTree(treePath);

                var testItem = testTree.GetItemsByPath("/sitecore/templates");

                var templates1 = testItem.First();

                // add a second Templates item
                var templates2 = "/sitecore/templates".AsTestItem(templates1.ParentId);
                testTree.Save(templates2);

                // add a child under the second templates item, giving us '/sitecore/templates/User Defined' under templates1, and '/sitecore/templates/Evil' under templates2
                // P.S. don't actually do this in real life. Please? But I'm testing it, because I'm an effing pedant :)
                testTree.Save("/sitecore/templates/Evil".AsTestItem(templates2.Id));

                var results = testTree.GetItemsByPath("/sitecore/templates").ToArray();

                Assert.Equal(2, results.Length);
                Assert.NotEqual(results[0].Id, results[1].Id);
                Assert.NotEqual(results[0].SerializedItemId, results[1].SerializedItemId);
                Assert.True(results.Any(result => result.Id == templates1.Id));
                Assert.True(results.Any(result => result.Id == templates2.Id));
            }
        }
Exemplo n.º 17
0
		public void ContainsPath_ReturnsFalse_WhenNotIncludedPath()
		{
			using (var testTree = new TestSfsTree())
			{
				Assert.False(testTree.ContainsPath("/umbraco/aem"));
			}
		}
 public void PrepareItemNameForFileSystem_TruncatesLongFileNames(string input, string expectedOutput)
 {
     using (var testTree = new TestSfsTree())
     {
         testTree.MaxFileNameLengthForTests = 10;
         Assert.Equal(expectedOutput, testTree.PrepareItemNameForFileSystemTest(input));
     }
 }
Exemplo n.º 19
0
		public void ContainsPath_ReturnsTrue_WhenExpectedPath_ContainingInvalidFileSystemChars()
		{
			using (var testTree = new TestSfsTree("/sitecore/content"))
			{

				Assert.True(testTree.ContainsPath("/sitecore/content/$he\\llo%<html>"));
			}
		}
Exemplo n.º 20
0
		public void ContainsPath_ReturnsTrue_WhenExpectedPath()
		{
			using (var testTree = new TestSfsTree("/sitecore/content"))
			{

				Assert.True(testTree.ContainsPath("/sitecore/content/hello"));
			}
		}
 public void PrepareItemNameForFileSystem_TruncatesLongFileNames(string input, string expectedOutput)
 {
     using (var testTree = new TestSfsTree())
     {
         testTree.MaxFileNameLengthForTests = 10;
         Assert.Equal(expectedOutput, testTree.PrepareItemNameForFileSystemTest(input));
     }
 }
Exemplo n.º 22
0
		public void Save_WritesItem_WhenItemIsNested_AndTreeIsNested()
		{
			using (var testTree = new TestSfsTree("/sitecore/templates"))
			{
				testTree.CreateTestTree("/sitecore/templates/hello");

				Assert.True(File.Exists(Path.Combine(testTree.PhysicalRootPath, "templates", "hello.yml")));
			}
		}
        [InlineData("trolls like to troll", "____________________", "trolikes ")] // lulz
        public void PrepareItemNameForFileSystem_FiltersIllegalCharacters_AddedFromConfiguration(string input, string expectedOutput, string invalidChars)
        {
            using (var testTree = new TestSfsTree())
            {
                testTree.SetExtraInvalidNameChars(invalidChars.ToCharArray());

                Assert.Equal(expectedOutput, testTree.PrepareItemNameForFileSystemTest(input));
            }
        }
Exemplo n.º 24
0
		public void Save_WritesItem_WhenItemIsRoot_AndTreeIsAtRoot()
		{
			using (var testTree = new TestSfsTree())
			{
				testTree.CreateTestTree("/sitecore");

				Assert.True(File.Exists(Path.Combine(testTree.PhysicalRootPath, "sitecore.yml")));
			}
		}
Exemplo n.º 25
0
        public void Save_WritesItem_WhenItemIsNested_AndTreeIsAtRoot()
        {
            using (var testTree = new TestSfsTree())
            {
                CreateTestTree("/sitecore/hello", testTree);

                Assert.True(File.Exists(Path.Combine(testTree.PhysicalRootPathTest, "sitecore", "hello.yml")));
            }
        }
        public void PrepareItemNameForFileSystem_FiltersIllegalCharacters_AddedFromConfiguration(string input, string expectedOutput, string invalidChars)
        {
            using (var testTree = new TestSfsTree())
            {
                testTree.SetExtraInvalidNameChars(invalidChars.ToCharArray());

                Assert.Equal(expectedOutput, testTree.PrepareItemNameForFileSystemTest(input));
            }
        }
Exemplo n.º 27
0
        public void Save_WritesItem_WhenItemIsNested_AndTreeIsNested()
        {
            using (var testTree = new TestSfsTree("/sitecore/templates"))
            {
                testTree.CreateTestTree("/sitecore/templates/hello");

                Assert.True(File.Exists(Path.Combine(testTree.PhysicalRootPath, "templates", "hello.yml")));
            }
        }
Exemplo n.º 28
0
        public void Save_WritesItem_WhenItemIsRoot_AndTreeIsAtRoot()
        {
            using (var testTree = new TestSfsTree())
            {
                testTree.CreateTestTree("/sitecore");

                Assert.True(File.Exists(Path.Combine(testTree.PhysicalRootPath, "sitecore.yml")));
            }
        }
Exemplo n.º 29
0
        public void Save_SetsSerializedItemId_WhenUsingDataCache()
        {
            using (var testTree = new TestSfsTree(useDataCache: true))
            {
                testTree.CreateTestTree("/sitecore");

                var item = testTree.GetItemsByPath("/sitecore").First();

                Assert.Equal(item.SerializedItemId, Path.Combine(testTree.PhysicalRootPath, "sitecore.yml"));
            }
        }
        public void GetRootItem_ReturnsExpectedItem_WhenNameHasInvalidChars()
        {
            using (var testTree = new TestSfsTree("/<h\\tml>"))
            {
                testTree.CreateTestTree("/<h\\tml>");

                var root = testTree.GetRootItem();

                Assert.NotNull(root);
                Assert.Equal(root.Name, "<h\\tml>");
            }
        }
Exemplo n.º 31
0
        public void GetRootItem_ReturnsExpectedItem_WhenTreeIsAtRoot()
        {
            using (var testTree = new TestSfsTree())
            {
                CreateTestTree("/sitecore", testTree);

                var root = testTree.GetRootItem();

                Assert.NotNull(root);
                Assert.Equal(root.Name, "sitecore");
            }
        }
Exemplo n.º 32
0
        public void GetRootItem_ReturnsExpectedItem_WhenTreeIsNested()
        {
            using (var testTree = new TestSfsTree("/sitecore/templates/User Defined"))
            {
                CreateTestTree("/sitecore/templates/User Defined", testTree);

                var root = testTree.GetRootItem();

                Assert.NotNull(root);
                Assert.Equal(root.Name, "User Defined");
            }
        }
Exemplo n.º 33
0
        public void GetRootItem_ReturnsExpectedItem_WhenNameHasInvalidChars()
        {
            using (var testTree = new TestSfsTree("/<h\\tml>"))
            {
                CreateTestTree("/<h\\tml>", testTree);

                var root = testTree.GetRootItem();

                Assert.NotNull(root);
                Assert.Equal(root.Name, "<h\\tml>");
            }
        }
        public void GetRootItem_ReturnsExpectedItem_WhenTreeIsNested()
        {
            using (var testTree = new TestSfsTree("/sitecore/templates/User Defined"))
            {
                testTree.CreateTestTree("/sitecore/templates/User Defined");

                var root = testTree.GetRootItem();

                Assert.NotNull(root);
                Assert.Equal(root.Name, "User Defined");
            }
        }
        public void GetRootItem_ReturnsExpectedItem_WhenTreeIsAtRoot()
        {
            using (var testTree = new TestSfsTree())
            {
                testTree.CreateTestTree("/sitecore");

                var root = testTree.GetRootItem();

                Assert.NotNull(root);
                Assert.Equal(root.Name, "sitecore");
            }
        }
        public void GetItemsByPath_ReturnsExpectedItem_WhenChildPathIsRequested_AndTreeIsNested()
        {
            using (var testTree = new TestSfsTree("/sitecore/templates"))
            {
                testTree.CreateTestTree("/sitecore/templates/User Defined");

                var root = testTree.GetItemsByPath("/sitecore/templates/User Defined").ToArray();

                Assert.NotNull(root);
                Assert.NotEmpty(root);
                Assert.Equal(root.First().Name, "User Defined");
            }
        }
Exemplo n.º 37
0
        public void GetChildren_ReturnsEmptyEnumerable_WhenNoChildrenExist()
        {
            using (var testTree = new TestSfsTree())
            {
                CreateTestTree("/sitecore", testTree);

                // get the children of the root, which be empty
                var results = testTree.GetChildren(testTree.GetRootItem());

                Assert.NotNull(results);
                Assert.Empty(results);
            }
        }
Exemplo n.º 38
0
        public void Save_WritesItem_WhenItemNameIsFullOfInvalidChars()
        {
            using (var testTree = new TestSfsTree())
            {
                testTree.CreateTestTree("/sitecore/%<html>?*");

                var rootItem = testTree.GetRootItem();

                var charsItem = testTree.GetChildren(rootItem).First();

                Assert.Equal("/sitecore/%<html>?*", charsItem.Path);
            }
        }
        public void GetItemsByPath_ReturnsExpectedItem_WhenRootPathIsRequested_AndTreeIsAtRoot()
        {
            using (var testTree = new TestSfsTree())
            {
                testTree.CreateTestTree("/sitecore");

                var root = testTree.GetItemsByPath("/sitecore").ToArray();

                Assert.NotNull(root);
                Assert.NotEmpty(root);
                Assert.Equal(root.First().Name, "sitecore");
            }
        }
		public void GetItemsByPath_ReturnsExpectedItem_WhenRootPathIsRequested_AndTreeIsAtRoot()
		{
			using (var testTree = new TestSfsTree())
			{
				testTree.CreateTestTree("/sitecore");

				var root = testTree.GetItemsByPath("/sitecore").ToArray();

				Assert.NotNull(root);
				Assert.NotEmpty(root);
				Assert.Equal(root.First().Name, "sitecore");
			}
		}
Exemplo n.º 41
0
        public void GetChildren_ReturnsEmptyEnumerable_WhenNoChildrenExist()
        {
            using (var testTree = new TestSfsTree())
            {
                testTree.CreateTestTree("/sitecore");

                // get the children of the root, which be empty
                var results = testTree.GetChildren(testTree.GetRootItem());

                Assert.NotNull(results);
                Assert.Empty(results);
            }
        }
		public void GetItemsByPath_ReturnsExpectedItem_WhenChildPathIsRequested_AndTreeIsNested()
		{
			using (var testTree = new TestSfsTree("/sitecore/templates"))
			{
				testTree.CreateTestTree("/sitecore/templates/User Defined");

				var root = testTree.GetItemsByPath("/sitecore/templates/User Defined").ToArray();

				Assert.NotNull(root);
				Assert.NotEmpty(root);
				Assert.Equal(root.First().Name, "User Defined");
			}
		}
        public void GetItemsByPath_ReturnsExpectedItem_WhenChildPathIsRequested_AndNamesContainInvalidPathChars()
        {
            using (var testTree = new TestSfsTree("/?hello*"))
            {
                testTree.CreateTestTree("/?hello*/%there%");

                var root = testTree.GetItemsByPath("/?hello*/%there%").ToArray();

                Assert.NotNull(root);
                Assert.NotEmpty(root);
                Assert.Equal(root.First().Name, "%there%");
            }
        }
        public void GetItemById_ResolvesItem_WhenItemIsRoot()
        {
            using (var testTree = new TestSfsTree())
            {
                testTree.CreateTestTree("/sitecore");

                var root = testTree.GetRootItem();

                var byId = testTree.GetItemById(root.Id);

                Assert.NotNull(byId);
                Assert.Equal(root.Id, byId.Id);
            }
        }
        public void GetItemById_ResolvesItem_WhenItemIsChild()
        {
            using (var testTree = new TestSfsTree())
            {
                testTree.CreateTestTree("/sitecore/content/foo");

                var item = testTree.GetItemsByPath("/sitecore/content/foo").First();

                var byId = testTree.GetItemById(item.Id);

                Assert.NotNull(byId);
                Assert.Equal(item.Id, byId.Id);
            }
        }
Exemplo n.º 46
0
		public void GetItemById_ResolvesItem_WhenItemIsRoot()
		{
			using (var testTree = new TestSfsTree())
			{
				testTree.CreateTestTree("/sitecore");

				var root = testTree.GetRootItem();

				var byId = testTree.GetItemById(root.Id);

				Assert.NotNull(byId);
				Assert.Equal(root.Id, byId.Id);
			}
		}
Exemplo n.º 47
0
        public void Remove_DeletesItem_WhenItemHasChildren()
        {
            using (var testTree = new TestSfsTree())
            {
                CreateTestTree("/sitecore/content/foo/bar/baz/boing", testTree);

                var item = testTree.GetItemsByPath("/sitecore/content").First();

                testTree.Remove(item);

                Assert.Empty(Directory.GetFileSystemEntries(Path.GetDirectoryName(item.SerializedItemId)));
                Assert.Empty(testTree.GetItemsByPath("/sitecore/content"));
            }
        }
Exemplo n.º 48
0
        public void Remove_DeletesItem_WhenItemHasChildren()
        {
            using (var testTree = new TestSfsTree())
            {
                testTree.CreateTestTree("/sitecore/content/foo/bar/baz/boing");

                var item = testTree.GetItemsByPath("/sitecore/content").First();

                testTree.Remove(item);

                Assert.Empty(Directory.GetFileSystemEntries(Path.GetDirectoryName(item.SerializedItemId)));
                Assert.Empty(testTree.GetItemsByPath("/sitecore/content"));
            }
        }
Exemplo n.º 49
0
		public void GetItemById_ResolvesItem_WhenItemIsChild()
		{
			using (var testTree = new TestSfsTree())
			{
				testTree.CreateTestTree("/sitecore/content/foo");

				var item = testTree.GetItemsByPath("/sitecore/content/foo").First();

				var byId = testTree.GetItemById(item.Id);

				Assert.NotNull(byId);
				Assert.Equal(item.Id, byId.Id);
			}
		}
Exemplo n.º 50
0
        public void Save_WritesItem_WhenRootPathIsRelative()
        {
            using (var testTree = new TestSfsTree("/../../Items", "/sitecore"))
            {
                testTree.CreateTestTree("/sitecore/hello");

                var rootItem = testTree.GetRootItem();

                var childItem = testTree.GetChildren(rootItem).First();

                Assert.Equal("/sitecore/hello", childItem.Path);
                Assert.EndsWith("\\Items\\sitecore\\hello.yml", childItem.SerializedItemId);
                Assert.False(childItem.SerializedItemId.Contains(".."));
            }
        }
Exemplo n.º 51
0
		public void Remove_DeletesItem_WhenItemIsRoot()
		{
			using (var testTree = new TestSfsTree())
			{
				testTree.CreateTestTree("/sitecore");

				testTree.Remove(testTree.GetRootItem());

				Assert.Empty(Directory.GetFileSystemEntries(testTree.PhysicalRootPath));

				var root = testTree.GetRootItem();

				Assert.Null(root);
			}
		}
        public void GetItemsByPath_ReturnsExpectedItem_WhenChildPathIsRequested_AndTreeIsAtRoot_CaseInsensitive()
        {
            using (var testTree = new TestSfsTree())
            {
                testTree.CreateTestTree("/sitecore/templates/User Defined");

                testTree.ClearAllCaches();

                var root = testTree.GetItemsByPath("/sitecore/templates/uSer dEfiNed").ToArray();

                Assert.NotNull(root);
                Assert.NotEmpty(root);
                Assert.Equal(root.First().Name, "User Defined");
            }
        }
Exemplo n.º 53
0
		public void GetChildren_ReturnsExpectedItem_WhenRootPathIsParent_AndTreeIsAtRoot()
		{
			using (var testTree = new TestSfsTree())
			{
				testTree.CreateTestTree("/sitecore/templates");

				var root = testTree.GetRootItem();

				var children = testTree.GetChildren(root).ToArray();

				Assert.NotNull(children);
				Assert.Equal(1, children.Length);
				Assert.Equal(children[0].Name, "templates");
			}
		}
        public void GetItemByPath_GetsExpectedItem_WhenItemNameIsTooLong()
        {
            using (var testTree = new TestSfsTree())
            {
                // force the tree to shorten after 10 char names
                testTree.MaxFileNameLengthForTests = 10;
                CreateTestTree("/sitecore/hello hello", testTree);

                var overlengthItem = testTree.GetItemsByPath("/sitecore/hello hello").ToArray();

                Assert.Equal(1, overlengthItem.Count());

                Assert.Equal("/sitecore/hello hello", overlengthItem.First().Path);
            }
        }
        public void GetItemByPath_GetsExpectedItem_WhenPathIsAChildOfShortenedName()
        {
            using (var testTree = new TestSfsTree())
            {
                // force the tree to shorten after 10 char names
                testTree.MaxFileNameLengthForTests = 10;
                CreateTestTree("/sitecore/hello hello/goodbye", testTree);

                var overlengthChild = testTree.GetItemsByPath("/sitecore/hello hello/goodbye").ToArray();

                Assert.Equal(1, overlengthChild.Count());

                Assert.Equal("/sitecore/hello hello/goodbye", overlengthChild.First().Path);
            }
        }
        public void GetItemByPath_GetsExpectedItem_WhenPathIsAChildOfShortenedName()
        {
            using (var testTree = new TestSfsTree())
            {
                // force the tree to shorten after 10 char names
                testTree.MaxFileNameLengthForTests = 10;
                testTree.CreateTestTree("/sitecore/hello hello/goodbye");

                var overlengthChild = testTree.GetItemsByPath("/sitecore/hello hello/goodbye").ToArray();

                Assert.Equal(1, overlengthChild.Length);

                Assert.Equal("/sitecore/hello hello/goodbye", overlengthChild.First().Path);
            }
        }
		public void GetItemsByPath_ReturnsExpectedItem_WhenChildPathIsRequested_AndTreeIsAtRoot_CaseInsensitive()
		{
			using (var testTree = new TestSfsTree())
			{
				testTree.CreateTestTree("/sitecore/templates/User Defined");

				testTree.ClearAllCaches();

				var root = testTree.GetItemsByPath("/sitecore/templates/uSer dEfiNed").ToArray();

				Assert.NotNull(root);
				Assert.NotEmpty(root);
				Assert.Equal(root.First().Name, "User Defined");
			}
		}
        public void GetItemById_ResolvesItem_WhenItemIsRoot_AndCacheIsEmpty()
        {
            using (var testTree = new TestSfsTree())
            {
                CreateTestTree("/sitecore", testTree);

                var root = testTree.GetRootItem();

                testTree.ClearAllCaches();

                var byId = testTree.GetItemById(root.Id);

                Assert.NotNull(byId);
                Assert.Equal(root.Id, byId.Id);
            }
        }
Exemplo n.º 59
0
		public void GetChildren_ReturnsExpectedItem_WhenRootPathIsParent_AndTreeIsNested_AndCacheIsCleared()
		{
			using (var testTree = new TestSfsTree("/sitecore/templates"))
			{
				testTree.CreateTestTree("/sitecore/templates/User Defined");

				var root = testTree.GetItemsByPath("/sitecore/templates").First();

				testTree.ClearAllCaches();

				var children = testTree.GetChildren(root).ToArray();

				Assert.NotNull(children);
				Assert.Equal(1, children.Length);
				Assert.Equal(children[0].Name, "User Defined");
			}
		}
Exemplo n.º 60
0
		public void Save_WritesItem_WhenPathRequiresLoopbackFolder()
		{
			using (var testTree = new TestSfsTree())
			{
				// force the tree to loopback after only 10 chars after the root path
				testTree.MaxPathLengthForTests = 10;
				testTree.CreateTestTree("/sitecore/content");

				var rootItem = testTree.GetRootItem();

				var loopedItem = testTree.GetChildren(rootItem).First();

				Assert.Equal("/sitecore/content", loopedItem.Path);
				// loopback path will have root item ID in it
				Assert.True(loopedItem.SerializedItemId.Contains(rootItem.Id.ToString()));
			}
		}