public void TET_Struc_RemoveTree_Status_Clear() { var list = new FolderList { new Folder { TreeChildren = { new Folder(), new Folder(), } } }; list.MarkSaved(); var root = list[0]; list.Clear(); Assert.AreEqual(list.Count, 0); Assert.AreEqual(list.DeletedList.Count, 1); Assert.IsTrue(root.IsDeleted); Assert.IsTrue(root.TreeChildren[0].IsDeleted); Assert.IsTrue(root.TreeChildren[1].IsDeleted); }
public void TET_Serialization_ByBit() { var list = new FolderList { new Folder { TreeChildren = { new Folder(), new Folder(), } }, new Folder { TreeChildren = { new Folder(), } }, }; list = ObjectCloner.Clone(list); Assert.IsTrue(list.Count == 2); var a = list[0]; Assert.IsTrue(a.TreeChildren.Count == 2); var b = list[1]; Assert.IsTrue(b.TreeChildren.Count == 1); }
public void TET_Struc_Clone() { var list = new FolderList { new Folder { TreeChildren = { new Folder(), new Folder(), } }, new Folder { TreeChildren = { new Folder(), } }, }; var list2 = new FolderList(); list2.Clone(list, CloneOptions.NewComposition()); Assert.IsTrue(list2.Count == 2); var a = list2[0]; Assert.IsTrue(a.TreeChildren.IsLoaded && a.TreeChildren.Count == 2); foreach (var treeChild in a.TreeChildren) { Assert.IsTrue(treeChild.IsTreeParentLoaded && treeChild.TreeParent == a); } var b = list2[1]; Assert.IsTrue(b.TreeChildren.IsLoaded && b.TreeChildren.Count == 1); }
public void TET_Query_LoadSubTreeIgnoreOtherNodes() { var repo = RF.Concrete<FolderRepository>(); using (RF.TransactionScope(repo)) { var list = new FolderList { new Folder { Name = "1", TreeChildren = { new Folder { Name = "1.1", TreeChildren = { new Folder{ Name = "1.1.1" }, new Folder{ Name = "1.1.2" }, } }, new Folder{Name = "1.2"}, } }, }; repo.Save(list); var root = list[0]; list = repo.GetForIgnoreTest(); Assert.IsTrue(list.Count == 1); Assert.IsTrue((list as ITreeComponent).CountNodes() == 2, "内存中只有 1 和 1.2 两个节点。"); } }
public void TET_Save_ByEntityList() { var repo = RF.Concrete<FolderRepository>(); using (RF.TransactionScope(repo)) { var list = new FolderList { new Folder { Name = "001.", TreeChildren = { new Folder() } }, new Folder{Name = "002."}, }; repo.Save(list); var list2 = repo.GetAll(); Assert.IsTrue(list2.Count == 2, "查询出的 EntityList 应该只有根节点。"); Assert.IsTrue(list2[0].Name == "001.", "查询出的结构应该正确。"); Assert.IsTrue(list2[0].TreeChildren.Count == 1, "查询出的结构应该正确。"); Assert.IsTrue(list2[0].TreeChildren[0].TreeIndex == "001.001.", "查询出的结构应该正确。"); Assert.IsTrue(list2[1].Name == "002.", "查询出的结构应该正确。"); } }
public void TET_Struc_TreeIndex_TreeChildren_Remove() { var list = new FolderList { new Folder { TreeChildren= { new Folder(), new Folder(), } } }; var root = list[0]; root.TreeChildren.RemoveAt(0); var a1 = root.TreeChildren[0]; Assert.IsTrue(a1.TreeIndex == "001.001."); }
public void TET_Query_GetByTreePId() { var repo = RF.Concrete<FolderRepository>(); using (RF.TransactionScope(repo)) { var list = new FolderList { new Folder { Name = "1", TreeChildren = { new Folder { Name = "1.1", TreeChildren = { new Folder{Name = "1.1.1"}, new Folder{Name = "1.1.2"}, } }, new Folder{Name = "1.2"}, } } }; repo.Save(list); var root = list[0]; list = repo.GetByTreePId(root.Id); Assert.IsTrue(list.Count == 2); Assert.IsTrue(list[0].Name == "1.1"); Assert.IsTrue(list[1].Name == "1.2"); Assert.IsTrue(!list[0].TreeChildren.IsLoaded, "GetByTreePId 方法返回的数据,只有根节点。"); } }
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); }
public void TET_Struc_TreeIndex_EntityList_Insert() { var list = new FolderList { new Folder(), }; var a = list[0]; Assert.IsTrue(a.TreeIndex == "001."); var b = new Folder(); list.Insert(0, b); Assert.IsTrue(b.TreeIndex == "001."); Assert.IsTrue(a.TreeIndex == "002."); }
public void TET_Struc_TreeComponent_EntityList() { var repo = RF.Concrete<FolderRepository>(); using (RF.TransactionScope(repo)) { var list = new FolderList { new Folder { TreeChildren = { new Folder { TreeChildren = { new Folder(), } }, new Folder(), } }, new Folder(), }; repo.Save(list); var roots = repo.GetTreeRoots() as ITreeComponent; TestTreeComponent(roots, 2, 5); } }
public void TET_Struc_TreeComponent_TreeChildren() { var repo = RF.Concrete<FolderRepository>(); using (RF.TransactionScope(repo)) { var list = new FolderList { new Folder { TreeChildren = { new Folder { TreeChildren = { new Folder { TreeChildren = { new Folder(), } }, new Folder(), } }, new Folder(), } }, }; repo.Save(list); var treeChildren= repo.GetTreeRoots()[0].TreeChildren; Assert.IsTrue(!treeChildren.IsLoaded); treeChildren.Load(); var component = treeChildren as ITreeComponent; TestTreeComponent(component, 2, 5); } }
public void TET_Struc_TreeComponent_DefaultValue_EntityList() { ITreeComponent component = new FolderList(); Assert.IsTrue(component.ComponentType == TreeComponentType.NodeList); Assert.IsTrue(component.CountNodes() == 0); Assert.IsTrue(component.IsFullLoaded); Assert.IsTrue(component.TreeComponentParent == null); }
public void TET_Struc_TreeChildren_AddRemoveNewNode() { var list = new FolderList { new Folder { TreeChildren = { new Folder(), new Folder(), } } }; var root = list[0]; var newChild = new Folder(); root.TreeChildren.Add(newChild); root.TreeChildren.Remove(newChild); root.TreeChildren.Add(newChild); root.TreeChildren.Remove(newChild); root.TreeChildren.Add(newChild); }
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); }
public void TET_Struc_TreeIndex_TreeChildren_Add2() { var list = new FolderList { new Folder { TreeChildren= { new Folder { TreeChildren= { new Folder(), } }, new Folder(), } } }; var a = list[0]; Assert.IsTrue(a.TreeIndex == "001."); Assert.IsTrue(a.TreeChildren.Count == 2); var a1 = a.TreeChildren[0]; Assert.IsTrue(a1.TreeIndex == "001.001."); Assert.IsTrue(a1.TreeChildren.Count == 1); Assert.IsTrue(a1.TreeChildren[0].TreeIndex == "001.001.001."); var a2 = a.TreeChildren[1]; Assert.IsTrue(a2.TreeIndex == "001.002."); }
public void TET_Query_GetAll_FullLoaded() { var repo = RF.Concrete<FolderRepository>(); using (RF.TransactionScope(repo)) { var list = new FolderList { new Folder { TreeChildren = { new Folder { TreeChildren = { new Folder(), } }, new Folder(), } } }; repo.Save(list); var tree = repo.GetAll() as ITreeComponent; Assert.IsTrue(tree.IsFullLoaded); } }
public void TET_Struc_TreeIndex_TreeChildren_Insert() { var a = new Folder(); var list = new FolderList { a }; Assert.IsTrue(a.TreeIndex == "001."); var a1 = new Folder(); a.TreeChildren.Add(a1); Assert.IsTrue(a1.TreeIndex == "001.001."); var a2 = new Folder(); a.TreeChildren.Add(a2); Assert.IsTrue(a2.TreeIndex == "001.002."); var a11 = new Folder(); a2.TreeChildren.Add(a11); Assert.IsTrue(a11.TreeIndex == "001.002.001."); }
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."); }
public void TET_Query_GetByTreeParentCode() { var repo = RF.Concrete<FolderRepository>(); using (RF.TransactionScope(repo)) { var list = new FolderList { new Folder { Name = "1", TreeChildren = { new Folder { Name = "1.1", TreeChildren = { new Folder{Name = "1.1.1"}, new Folder{Name = "1.1.2"}, } }, new Folder{Name = "1.2"}, } } }; repo.Save(list); Assert.IsTrue(list.Count == 1); var root = list[0]; Assert.IsTrue(root.TreeChildren.Count == 2); var node11 = root.TreeChildren[0]; Assert.IsTrue(node11.TreeChildren.Count == 2); var a = node11.TreeChildren[0] as Folder; Assert.IsTrue(a.Name == "1.1.1"); var b = node11.TreeChildren[1] as Folder; Assert.IsTrue(b.Name == "1.1.2"); } }
public void TET_Struc_TreeIndex_EntityList_Remove() { var list = new FolderList { new Folder(), new Folder(), }; var a = list[1]; Assert.IsTrue(a.TreeIndex == "002."); list.RemoveAt(0); Assert.IsTrue(a.TreeIndex == "001."); }
public void TET_Query_LoadAllParent() { var repo = RF.Concrete<FolderRepository>(); using (RF.TransactionScope(repo)) { var veryChild = new Folder(); var list = new FolderList { new Folder { TreeChildren = { new Folder { TreeChildren = { veryChild } } } } }; repo.Save(list); veryChild = repo.GetById(veryChild.Id); Assert.IsTrue(!veryChild.IsTreeParentLoaded); repo.LoadAllTreeParents(veryChild); Assert.IsTrue(veryChild.IsTreeParentLoaded); Assert.IsTrue(veryChild.TreeParent.IsTreeParentLoaded); } }
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."); }
public void TET_Query_TreeParentRelation() { var repo = RF.Concrete<FolderRepository>(); using (RF.TransactionScope(repo)) { var list = new FolderList { new Folder { TreeChildren = { new Folder() } } }; repo.Save(list); list = repo.GetAll(); var root = list[0]; var child = root.TreeChildren[0]; Assert.IsTrue(child.TreeParent == root); } }
public void TET_Struc_TreeIndex_InsertRootItem() { var repo = RF.Concrete<FolderRepository>(); using (RF.TransactionScope(repo)) { var list = new FolderList { new Folder() }; repo.Save(list); var root2 = new Folder(); repo.Save(root2); Assert.IsTrue(root2.TreeIndex == "002."); var tree = repo.GetAll(); Assert.IsTrue(tree.Count == 2); Assert.IsTrue(tree[1].TreeIndex == "002."); } }
public void TET_Save_LevelDownRoot() { var repo = RF.Concrete<FolderRepository>(); using (RF.TransactionScope(repo)) { var list = new FolderList { new Folder(), new Folder(), }; repo.Save(list); list = repo.GetAll(); var a = list[0]; var b = list[1]; b.TreeChildren.Add(a); Assert.IsTrue(list.Count == 1); repo.Save(list); list = repo.GetAll(); Assert.IsTrue(list.Count == 1); b = list[0]; Assert.IsTrue(b.TreeChildren.Count == 1); Assert.IsTrue(b.TreeChildren[0].Id.Equals(a.Id)); } }
public void TET_Struc_TreeIndex_InsertRootItem_WhileIndexCollapsed() { var repo = RF.Concrete<FolderRepository>(); using (RF.TransactionScope(repo)) { var list = new FolderList { new Folder(),//001. new Folder//002. { TreeChildren = { new Folder()//002.001. } }, new Folder(),//003. }; repo.Save(list); //删除 001 var root1 = list[0]; root1.PersistenceStatus = PersistenceStatus.Deleted; repo.Save(root1); var root2 = new Folder(); repo.Save(root2); Assert.IsTrue(root2.TreeIndex == "004."); var tree = repo.GetAll(); Assert.IsTrue(tree.Count == 3); Assert.IsTrue(tree[0].TreeIndex == "002."); Assert.IsTrue(tree[0].TreeChildren[0].TreeIndex == "002.001."); Assert.IsTrue(tree[1].TreeIndex == "003."); Assert.IsTrue(tree[2].TreeIndex == "004."); } }
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; }); }
public void TET_Struc_TreeIndex_ResetAllTreeIndex() { var repo = RF.Concrete<FolderRepository>(); using (RF.TransactionScope(repo)) { var list = new FolderList { new Folder { TreeChildren= { new Folder { TreeChildren= { new Folder(), } }, new Folder(), } } }; repo.Save(list); TreeIndexHelper.ResetTreeIndex(repo); var tree = repo.GetAll(); Assert.IsTrue(tree.Count == 1); Assert.IsTrue((tree as ITreeComponent).IsFullLoaded); var root = tree[0]; Assert.IsTrue(root.TreeIndex == "001."); Assert.IsTrue(root.TreeChildren.Count == 2); Assert.IsTrue(root.TreeChildren[0].TreeIndex == "001.001."); Assert.IsTrue(root.TreeChildren[0].TreeChildren.Count == 1); Assert.IsTrue(root.TreeChildren[0].TreeChildren[0].TreeIndex == "001.001.001."); Assert.IsTrue(root.TreeChildren[1].TreeIndex == "001.002."); } }
public void TET_Struc_LazyLoad_TreeChildren_AutoLoad_Add() { var repo = RF.Concrete<FolderRepository>(); using (RF.TransactionScope(repo)) { var list = new FolderList { new Folder { TreeChildren = { new Folder { TreeChildren = { new Folder(), } }, new Folder(), } } }; repo.Save(list); var root = repo.GetById(list[0].Id); Assert.IsTrue(!root.TreeChildren.IsLoaded); root.TreeChildren.Add(new Folder()); Assert.IsTrue(root.TreeChildren.IsLoaded && !root.TreeChildren.IsFullLoaded); } }
public void TET_Struc_Relation_RemoveFromListIfNotRoot() { var list = new FolderList { new Folder(), new Folder(), }; var a = list[0]; var b = list[1]; b.TreeChildren.Add(a); Assert.IsTrue(list.Count == 1); }