Exemplo n.º 1
0
        public void TestAttack()
        {
            Agent agent     = new Hacker();
            Agent attacker  = new Android();
            Agent protector = new Medic();

            agent.Protect(protector);
            agent.Attack(attacker);
            Assert.IsTrue(agent.WasAttacked);
            Assert.IsTrue(agent.IsActive);
            Assert.IsNull(agent.Killer);

            agent.Reset();

            agent.Attack(attacker);
            Assert.IsTrue(agent.WasAttacked);
            Assert.IsFalse(agent.IsActive);
            Assert.IsNotNull(agent.Killer);
            Assert.AreSame(attacker, agent.Killer);
        }
Exemplo n.º 2
0
        public void TestReset()
        {
            Agent agent     = new Hacker();
            Agent protector = new Medic();
            Agent blocker   = new Saboteur();
            Agent framer    = new Fabricator();
            Agent killer    = new Android();

            string name     = agent.Name;
            string codename = agent.Codename;
            Gender gender   = agent.Gender;

            agent.Reset();
            Assert.AreEqual(name, agent.Name);
            Assert.AreEqual(codename, agent.Codename);
            Assert.AreEqual(gender, agent.Gender);

            agent.Visit(protector);
            agent.Reset();
            Assert.IsNotNull(agent.Visitors);
            Assert.AreEqual(0, agent.Visitors.Count);

            agent.Target   = protector;
            agent.IsActing = true;
            agent.Reset();
            Assert.IsNull(agent.Target);
            Assert.IsFalse(agent.IsActing);

            agent.Protect(protector);
            agent.Reset();
            Assert.IsFalse(agent.IsProtected);
            Assert.IsNull(agent.Protector);

            agent.Block(blocker);
            agent.Reset();
            Assert.IsFalse(agent.IsBlocked);
            Assert.IsNull(agent.Blocker);

            agent.Frame(framer);
            agent.Reset();
            Assert.IsFalse(agent.WasFramed);

            agent.Attack(killer);
            agent.Reset();
            Assert.IsFalse(agent.WasAttacked);
            Assert.IsFalse(agent.WasKilled);
            Assert.IsFalse(agent.IsActive);
            Assert.IsNotNull(agent.Killer);
        }
Exemplo n.º 3
0
        public void TestProtect()
        {
            Agent agent     = new Hacker();
            Agent protector = new Medic();
            Agent attacker  = new Android();

            agent.Protect(protector);
            Assert.IsTrue(agent.IsProtected);
            Assert.IsNotNull(agent.Protector);
            Assert.IsTrue(agent.Visitors.Contains(protector.Codename));

            agent.Attack(attacker);
            Assert.IsTrue(agent.WasAttacked);
            Assert.IsTrue(agent.IsActive);
        }