Пример #1
0
        public void VerifyQueenBeeInitialization()
        {
            var beeGame = new BeeGame();

            Assert.AreEqual(1, beeGame.Count(bee => bee.BeeType.IsQueen));

            var queen = beeGame.SingleOrDefault(bee => bee.BeeType.Name == "Queen");
            Assert.IsNotNull(queen, "A Queen wasn't created");
            Assert.IsTrue(queen.BeeType.IsQueen);
            Assert.AreEqual(100, queen.HitPoints);
            Assert.AreEqual(8, queen.BeeType.DamagePerHit);
        }
Пример #2
0
 public void VerifyTotalNumberofBeesInitialization()
 {
     var beeGame = new BeeGame();
     Assert.AreEqual(14, beeGame.Count());
 }
Пример #3
0
        [Timeout(10000)] //incase of infinite loop.
        public void VerifyKillQueen()
        {
            var beeTypes = new List<BeeType> {
                new BeeType {Name="One-Shot Queen Bee", DamagePerHit = 5, MaxHitPoints=5, InitialNumberOfBees=1, IsQueen = true},
                new BeeType {Name ="0 damage per hit worker Bee", DamagePerHit = 0, MaxHitPoints=1, InitialNumberOfBees=2},
            };

            var bees = new BeeGame(beeTypes);

            Bee hitBee = null;
            while (bees.Count(bee => !bee.IsDead) > 0)
            {
                hitBee = bees.HitABee();
            }

            Assert.IsTrue(hitBee.BeeType.IsQueen);
            Assert.IsTrue(bees.IsGameOver);
            Assert.AreEqual(3, bees.Count(bee => bee.IsDead));
        }
Пример #4
0
        public void VerifyHitABeeKill()
        {
            var beeTypes = new List<BeeType> {
                new BeeType {Name="One-Shot Bee Type", DamagePerHit = 5, MaxHitPoints=5, InitialNumberOfBees=10 } };

            var beeGame = new BeeGame(beeTypes);
            var hitBee = beeGame.HitABee();

            Assert.IsTrue(hitBee.IsDead);
            Assert.AreEqual(1, beeGame.Count(bee => bee.IsDead));
            Assert.AreEqual(9, beeGame.Count(bee => !bee.IsDead));
            Assert.AreEqual(9, beeGame.Where(bee => bee.HitPoints == 5).Count());
        }
Пример #5
0
        [Timeout(10000)] //in case of infinite loop.
        public void VerifyResetGameAfterGameOver()
        {
            var beeGame = new BeeGame();
            var hitBee = beeGame.HitABee();
            while (hitBee != null)
            {
                hitBee = beeGame.HitABee();
            }
            Assert.IsTrue(beeGame.IsGameOver);

            beeGame.ResetGame();
            Assert.IsTrue(beeGame.IsNewGame);
            Assert.AreEqual(14, beeGame.Count(bee => bee.HitPoints == bee.BeeType.MaxHitPoints));
        }