public void TestCanAct() { Agent agent1 = new Hacker(); Agent agent2 = new Saboteur(); // They should not be able to act initially because they don't have targets Assert.False(agent1.CanAct); Assert.False(agent2.CanAct); // They should be able to act once they have targets agent1.Target = agent2; agent2.Target = agent1; Assert.True(agent1.CanAct); Assert.True(agent2.CanAct); // A blocked agent should't be able to act agent1.Block(agent2); Assert.IsFalse(agent1.CanAct); // A dead agent should't be able to act agent2.Execute(); Assert.IsFalse(agent2.CanAct); // If the blocker dies, the blocked agent should no longer be blocked Assert.IsTrue(agent1.CanAct); }
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); }
public void TestBlock() { Agent agent = new Hacker(); Agent blocker = new Saboteur(); agent.Block(blocker); Assert.IsTrue(agent.IsBlocked); Assert.IsNotNull(agent.Blocker); Assert.IsTrue(agent.Visitors.Contains(blocker.Codename)); Assert.IsFalse(agent.CanAct); // CanAct should still be false after a target is assigned agent.Target = blocker; Assert.IsFalse(agent.CanAct); }