public void TestBlockApplyPowerUp()
        {
            var block = CreateGameBlock();

            Assert.Throws <InvalidOperationException>(block.ApplyPowerUp, "Should indicate that no player is present");

            var wall = new DestructibleWallEntity();

            block.SetEntity(wall);
            Assert.Throws <InvalidOperationException>(block.ApplyPowerUp, "Should indicate that entity is not a player");

            block.SetEntity(null);
            var player = new PlayerEntity();

            block.SetEntity(player);
            Assert.Throws <InvalidOperationException>(block.ApplyPowerUp, "Should indicate that no power up entity is present");

            var entity = new BombBagPowerUpEntity();

            block.SetPowerUpEntity(entity);
            Assert.AreEqual(block.PowerUpEntity, entity, "Power up entity was not set on game block");
            Assert.AreEqual(block.Location, entity.Location, "Power up location not set correctly");

            block.ApplyPowerUp();

            Assert.IsNull(block.PowerUpEntity, "Power up entity should be removed after having been applied");
        }
        public void TestBombagPowerUp()
        {
            var block   = new GameBlock(1, 1);
            var player  = new PlayerEntity();
            var powerup = new BombBagPowerUpEntity();

            player.BombBag    = 1;
            player.BombRadius = 1;

            block.SetEntity(player);
            block.SetPowerUpEntity(powerup);
            block.ApplyPowerUp();

            Assert.AreEqual(2, player.BombBag, "Expected player bombag to increase after power up was applied");
        }
        public void TestBlockSetPowerUp()
        {
            var block = CreateGameBlock();

            var entity = new BombBagPowerUpEntity();

            Assert.IsNull(block.PowerUpEntity, "Game block did not start with null power up entity");

            block.SetPowerUpEntity(entity);
            Assert.AreEqual(block.PowerUpEntity, entity, "Power up entity was not set on game block");

            entity = new BombBagPowerUpEntity();
            Assert.Throws <InvalidOperationException>(() => block.SetPowerUpEntity(entity),
                                                      "Game block allowed power up entity to be overrriden");
        }
        public void TestPowerUpMapSymbols()
        {
            var block = CreateGameBlock();

            var powerUp = new BombBagPowerUpEntity();
            var wall    = new DestructibleWallEntity();

            block.SetPowerUpEntity(powerUp);
            block.SetEntity(wall);

            block.ExplodingBombs.Add(new BombEntity());

            Assert.AreEqual('*', block.GetMapSymbol(), "Exploding character should always be first to display");
            block.ExplodingBombs.Clear();

            Assert.AreEqual(wall.GetMapSymbol(), block.GetMapSymbol(), "Entities should always be displayed before power ups");
            block.SetEntity(null);

            Assert.AreEqual(powerUp.GetMapSymbol(), block.GetMapSymbol(), "Power up should be shown when no other symbols are present");
            block.SetPowerUpEntity(null);

            Assert.AreEqual(' ', block.GetMapSymbol(), "Empty character should display when no other entities are present on the map");

            var player = new PlayerEntity();

            block.SetEntity(player);
            block.PlantBomb(2);

            block.SetPowerUpEntity(powerUp);

            var currentSymbol = block.Bomb.GetMapSymbol();

            Assert.AreEqual(currentSymbol, block.GetMapSymbol(), "The map symbol for a bomb should be shown");

            var block2 = new GameBlock(4, 4);

            block.SetEntity(null);
            block2.SetEntity(player);

            Assert.AreNotEqual(currentSymbol, block.GetMapSymbol(), "Block symbol for bomb should change if user is moved away");
        }