예제 #1
0
        public void Skill_AddParent()
        {
            ILevelFormula formula = new MockLevelFormula();
            Skill         child   = new Skill("child", formula);
            Skill         parent  = new Skill("parent", formula);

            child.AddParent(parent);
            Assert.AreSame(parent, child.parents.First());
            child.AddParent(parent);
            Assert.AreEqual(1, child.parents.Count);
        }
예제 #2
0
        public void Skill_PreventCircularParents()
        {
            ILevelFormula formula     = new MockLevelFormula();
            Skill         child       = new Skill("child", formula);
            Skill         parent      = new Skill("parent", formula);
            Skill         grandparent = new Skill("grandparent", formula);

            child.AddParent(parent);
            Assert.False(parent.AddParent(child));
            Assert.AreEqual(0, parent.parents.Count);
            parent.AddParent(grandparent);
            Assert.False(grandparent.AddParent(child));
        }
예제 #3
0
        public void Skill_AncestoryContains()
        {
            ILevelFormula formula     = new MockLevelFormula();
            Skill         child       = new Skill("child", formula);
            Skill         parent      = new Skill("parent", formula);
            Skill         otherParent = new Skill("otherParent", formula);
            Skill         grandparent = new Skill("grandparent", formula);
            Skill         uncle       = new Skill("uncle", formula);

            child.AddParent(parent);
            parent.AddParent(grandparent);
            uncle.AddParent(grandparent);
            Assert.IsTrue(child.AncestryContains(grandparent));
            Assert.IsFalse(child.AncestryContains(uncle));
            otherParent.AddParent(grandparent);
            child.AddParent(otherParent);
            Assert.IsTrue(child.AncestryContains(grandparent));
        }
예제 #4
0
        public void Skill_IsChildOf()
        {
            ILevelFormula formula = new MockLevelFormula();
            Skill         child   = new Skill("child", formula);
            Skill         parent  = new Skill("parent", formula);
            Skill         uncle   = new Skill("uncle", formula);

            child.AddParent(parent);
            Assert.True(child.IsChildOf(parent));
            Assert.False(child.IsChildOf(uncle));
        }