public void InheritanceTree_Test() { ModelRoot modelRoot = new ModelRoot(); Interface I00 = new Interface(modelRoot, "I00"); Interface I01 = new Interface(modelRoot, "I01"); Interface I02 = new Interface(modelRoot, "I02"); Interface I03 = new Interface(modelRoot, "I03"); Interface I04 = new Interface(modelRoot, "I04"); Interface I05 = new Interface(modelRoot, "I05"); Entity C01 = new Entity(modelRoot, "C01"); Entity C02 = new Entity(modelRoot, "C02"); Entity C03 = new Entity(modelRoot, "C03"); // assign inheritance I02.SetInheritance(I01); I04.SetInheritance(I01); I03.SetInheritance(I02, I04); I05.SetInheritance(I04, I02); C01.SetInheritance(I03, I05, I00); C02.SetInheritance(C01); //C03.SetInheritance(I00); // test case #1 var inheritanceTrees = InheritanceTree.Create(C01, C02, C03); InheritanceTree.RebuildTree(true, inheritanceTrees.ToArray()); InheritanceTree C01_inheritanceTree = inheritanceTrees[0]; //C01_inheritanceTree.RebuildTree(true); ReadOnlyCollection <InheritanceNode> flatList = C01_inheritanceTree.GetFlatList(InheritanceListMode.CurrentLevel); IEnumerable <IInterface> flatInterfaces = flatList.Select(node => node.Interface); Assert.IsTrue(flatInterfaces.Contains(I03)); Assert.IsTrue(flatInterfaces.Contains(I05)); Assert.IsTrue(flatInterfaces.Contains(I00)); // test case #2 //inheritanceTrees[1].RebuildTree(true); var mergedPaths = InheritanceTree.MergePaths(inheritanceTrees).ToArray(); }
public InheritanceTree GetInheritanceTree() { return(InheritanceTree.Create(this)); }