Пример #1
0
        public void TET_Struc_AddRemovedTreeIntoList()
        {
            var list = new FolderList
            {
                new Folder
                {
                    TreeChildren =
                    {
                        new Folder
                        {
                            TreeChildren =
                            {
                                new Folder(),
                                new Folder(),
                            }
                        },
                        new Folder(),
                    }
                }
            };
            list.MarkSaved();

            var root = list[0];
            list.Clear();

            (root as ITreeComponent).EachNode(c =>
            {
                Assert.IsTrue(c.IsDeleted);
                return false;
            });

            list.Add(root);

            (root as ITreeComponent).EachNode(c =>
            {
                Assert.IsFalse(c.IsDeleted);
                return false;
            });
        }
Пример #2
0
        public void TET_Struc_TreeIndex_EntityList_RootListAdd()
        {
            var list = new FolderList();

            var a = new Folder();
            list.Add(a);
            Assert.IsTrue(a.TreeIndex == "001.");

            var b = new Folder();
            list.Add(b);
            Assert.IsTrue(b.TreeIndex == "002.");
        }
Пример #3
0
        public void TET_Struc_TreeIndex_EntityList_LeafListAdd()
        {
            var a = new Folder
            {
                TreeChildren =
                {
                    new Folder(),
                    new Folder(),
                }
            };
            new FolderList().Add(a);

            var a11 = a.TreeChildren[0];
            Assert.IsTrue(a11.TreeIndex == "001.001.");
            var a12 = a.TreeChildren[1];
            Assert.IsTrue(a12.TreeIndex == "001.002.");

            var sundryList = new FolderList();
            sundryList.Add(a11);
            Assert.IsTrue(a11.TreeIndex == "001.001.");
            sundryList.Add(a12);
            Assert.IsTrue(a12.TreeIndex == "001.002.");
        }
Пример #4
0
        public void TET_Struc_TreeIndex_DisableAutoIndex()
        {
            var list = new FolderList();
            list.Add(new Folder());

            list.AutoTreeIndexEnabled = false;

            list.Add(new Folder());

            Assert.AreEqual(list[0].TreeIndex, "001.");
            Assert.AreEqual(list[1].TreeIndex, string.Empty);
        }
Пример #5
0
 public void TET_Struc_RootList_AddRemoveNewNode()
 {
     var list = new FolderList
     {
         new Folder()
     };
     var root = list[0];
     var newChild = new Folder();
     list.Add(newChild);
     list.Remove(newChild);
     list.Add(newChild);
     list.Remove(newChild);
     list.Add(newChild);
 }
Пример #6
0
        public void TET_Struc_Relation_CantAddNonRootIntoRootList()
        {
            var list = new FolderList
            {
                new Folder
                {
                    TreeChildren =
                    {
                        new Folder()
                    }
                },
            };
            var a = list[0];
            var b = a.TreeChildren[0];

            var hasException = false;
            try
            {
                list.Add(b);
            }
            catch (InvalidOperationException ex)
            {
                hasException = ex.Message.Contains("树的根节点列表中不能添加非根节点");
            }

            Assert.IsTrue(hasException);
        }