Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }