コード例 #1
0
        public void CanCreateTreeNode()
        {
            const string sitecoreRootPath = @"sitecore/templates/system/branches";
            const int    rootItemsCount   = 1;
            const int    childrenItemsCountForFirstNode = 4;
            const string firstChildName = @"Branch";

            var webApiRepository = new Mock <ISitecoreWebApiRepository>();

            webApiRepository
            .Setup(r => r.RequestItemsAsync(It.IsAny <SitecoreActionType>(), It.IsAny <string>()))
            .ReturnsAsync(_validRequestResult);

            var repository = new TemplatesRepository(webApiRepository.Object, sitecoreRootPath);

            var tree = repository.CreateTree().ToList();

            Assert.NotNull(tree);
            Assert.AreEqual(rootItemsCount, tree.Count);
            Assert.AreEqual(childrenItemsCountForFirstNode, tree.First().Children.Count);
            Assert.AreEqual(firstChildName, tree.First().Children.First().Value.Name);
        }