Beispiel #1
0
        public void Skill_AddRecord()
        {
            ILevelFormula formula    = new MockLevelFormula();
            Skill         skill      = new Skill("skill", formula);
            Skill         otherSkill = new Skill("otherSkill", formula);
            Record        record     = new Record(DateTime.Today, 10f, skill);
            Record        record2    = new Record(DateTime.Today, 20f, skill);

            skill.AddRecords(new List <Record>()
            {
                record, record2
            });
            Assert.True(skill.records.Contains(record));
            Assert.True(skill.records.Contains(record2));
            Assert.AreEqual(2, skill.records.Count);
            Record otherRecord = new Record(DateTime.Today, 10f, otherSkill);

            skill.AddRecords(new List <Record>()
            {
                otherRecord
            });
            Assert.AreEqual(2, skill.records.Count);
            skill.AddRecords(new List <Record>()
            {
                record
            });
            Assert.AreEqual(2, skill.records.Count);
        }
Beispiel #2
0
        public MockSkillsDataSource()
        {
            MockLevelFormula formula = new MockLevelFormula();
            Skill            abe     = new Skill("abe", "abe", formula, Color.white, new HashSet <Skill>());
            Skill            cef     = new Skill("cef", "cef", formula, Color.white, new HashSet <Skill>());
            Skill            h       = new Skill("h", "h", formula, Color.white, new HashSet <Skill>());
            Skill            i       = new Skill("i", "i", formula, Color.white, new HashSet <Skill>());
            Skill            ab      = new Skill("ab", "ab", formula, Color.white, new HashSet <Skill>()
            {
                abe
            });
            Skill e = new Skill("e", "e", formula, Color.white, new HashSet <Skill>()
            {
                abe, cef
            });
            Skill f = new Skill("f", "f", formula, Color.white, new HashSet <Skill>()
            {
                cef
            });
            Skill g = new Skill("g", "g", formula, Color.white, new HashSet <Skill>()
            {
                h, i
            });
            Skill a = new Skill("a", "a", formula, Color.white, new HashSet <Skill>()
            {
                ab
            });
            Skill b = new Skill("b", "b", formula, Color.white, new HashSet <Skill>()
            {
                ab
            });
            Skill c = new Skill("c", "c", formula, Color.white, new HashSet <Skill>()
            {
                e, f
            });
            Skill d = new Skill("d", "d", formula, Color.white, new HashSet <Skill>()
            {
                g
            });

            skills = new Dictionary <string, Skill>();

            skills.Add(abe.guid, abe);
            skills.Add(cef.guid, cef);
            skills.Add(h.guid, h);
            skills.Add(i.guid, i);
            skills.Add(ab.guid, ab);
            skills.Add(e.guid, e);
            skills.Add(f.guid, f);
            skills.Add(g.guid, g);
            skills.Add(a.guid, a);
            skills.Add(b.guid, b);
            skills.Add(c.guid, c);
            skills.Add(d.guid, d);

            records = new Dictionary <string, Record>();
        }
Beispiel #3
0
        public void Skill_NewSkill()
        {
            ILevelFormula formula = new MockLevelFormula();
            Skill         skill   = new Skill("skill", formula);

            Assert.AreEqual("skill", skill.name);
            Assert.AreEqual(0, skill.records.Count);
            Assert.AreEqual(0, skill.parents.Count);
        }
Beispiel #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));
        }
Beispiel #5
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);
        }
Beispiel #6
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));
        }
Beispiel #7
0
        private Skill BuildTestSkill()
        {
            ILevelFormula formula = new MockLevelFormula();
            Skill         skill   = new Skill("skill", formula);

            Assert.AreEqual(0, skill.Total());
            Record r1 = new Record(DateTime.Today, 10f, skill);
            Record r2 = new Record(DateTime.Today, 45f, skill);
            Record r3 = new Record(DateTime.Today, 120f, skill);

            skill.AddRecords(new List <Record>()
            {
                r1, r2, r3
            });
            return(skill);
        }
Beispiel #8
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));
        }
Beispiel #9
0
        public void Skill_FireOnUpdated()
        {
            fired = false;

            ILevelFormula formula = new MockLevelFormula();
            Skill         skill   = new Skill("skill", formula);

            skill.OnAmountUpdated += () => { fired = true; };
            Record r1 = new Record(DateTime.Today, 10f, skill);

            skill.AddRecords(new List <Record>()
            {
                r1
            });
            Assert.IsTrue(fired);
            fired = false;
            skill.RemoveRecord(r1);
            Assert.IsTrue(fired);
        }