コード例 #1
0
        public void TestRequirement()
        {
            //setup
            BaseTrigger trigger1 = new BredAnimalsTrigger();
            BaseTrigger trigger2 = new BredAnimalsTrigger()
            {
                Name = "mytrigger"
            };
            BaseTrigger trigger3 = new BredAnimalsTrigger();

            //test
            Requirement requirement1 = new Requirement((BaseTrigger[])trigger1);
            Requirement requirement2 = new Requirement(new IRequirementItem[] { requirement1, trigger2, trigger3 });

            Assert.AreEqual("[[\"trigger_0\"],\"mytrigger\",\"trigger_1\"]", requirement2.GetRequirementString(null), "GetRequirementString didn't return correct value");
            Assert.AreEqual("trigger_0", trigger1.Name, "trigger1 wasn't given the correct name");
            Assert.AreEqual("trigger_1", trigger3.Name, "trigger3 wasn't given the correct name");

            List <BaseTrigger> triggers = requirement2.GetChildTriggers().ToList();

            Assert.IsTrue(triggers.Contains(trigger1), "GetChildTriggers didn't return trigger1");
            Assert.IsTrue(triggers.Contains(trigger2), "GetChildTriggers didn't return trigger2");
            Assert.IsTrue(triggers.Contains(trigger3), "GetChildTriggers didn't return trigger3");
        }