Exemplo n.º 1
0
        public async Task ShouldNotWalkHorizontallyInToWalls()
        {
            var wallLocation       = _gameSettings.PacMan.Location.Right;
            var ghostStartLocation = _gameSettings.PacMan.Location.Right.Right;

            _gameSettings.Walls.Add(wallLocation);
            var ghost = _ghostBuilder.WithLocation(ghostStartLocation).Create();

            _gameSettings.Ghosts.Add(ghost);

            var gameHarness = new GameHarness(_gameSettings);
            await gameHarness.PlayGame();

            await gameHarness.WaitForScatterToComplete();

            using var _ = new AssertionScope();
            gameHarness.Game.Ghosts[ghost.Name].Should().NotBeEquivalentTo(new
            {
                Location = wallLocation
            });

            gameHarness.Game.Ghosts[ghost.Name].Should().NotBeEquivalentTo(new
            {
                Location = ghostStartLocation
            });
        }
Exemplo n.º 2
0
        public async Task WeGetAnExtraLifeWhenScoreReachesBonusLifePointAfterEatingFruit()
        {
            var gameSettings = new TestGameSettings();

            gameSettings.Coins.Add(gameSettings.PacMan.Location.Below);
            gameSettings.Coins.Add(gameSettings.PacMan.Location.FarAway());
            gameSettings.Fruit = gameSettings.PacMan.Location.Below.Below;
            gameSettings.FruitAppearsAfterCoinsEaten.Add(1);
            gameSettings.PointsNeededForBonusLife = PointsFor.EatingFirstFruit;

            var gameHarness = new GameHarness(gameSettings);
            await gameHarness.PlayGame();

            await gameHarness.ChangeDirection(Direction.Down);

            var previousLives = gameHarness.Lives;

            await gameHarness.EatCoin();

            gameHarness.WeExpectThatPacMan().HasLives(previousLives);

            using var _ = new AssertionScope();
            await gameHarness.AssertSingleNotificationFires(GameNotification.ExtraPac, async() =>
            {
                await gameHarness.EatFruit();
            });

            gameHarness.Game.Lives.Should().Be(previousLives + 1);
        }
Exemplo n.º 3
0
        public async Task PacManShouldBeAliveAfter4SecondsWhenInRespawning()
        {
            var initialPosition = _gameSettings.PacMan.Location;

            var ghost = GhostBuilder.New()
                        .WithLocation(initialPosition.Left.Left.Left.Left)
                        .WithScatterStrategyRight()
                        .WithChaseStrategyRight()
                        .Create();

            _gameSettings.Ghosts.Add(ghost);

            var gameHarness = new GameHarness(_gameSettings);
            await gameHarness.PlayGame();

            await gameHarness.ChangeDirection(Direction.Left);

            await gameHarness.Move();

            await gameHarness.GetEatenByGhost(ghost);

            await gameHarness.WaitToFinishDying();

            gameHarness.EnsureGameStatus(GameStatus.Respawning);

            await gameHarness.WaitToRespawn();

            gameHarness.Game.Status.Should().Be(GameStatus.Alive);
        }
Exemplo n.º 4
0
        public async Task FruitShouldFirstAppearAfterSetNumberOfPills()
        {
            var fruitLocation = _gameSettings.PacMan.Location.FarAway();

            _gameSettings.Fruit = fruitLocation;
            _gameSettings.FruitAppearsAfterCoinsEaten.Add(5);

            _gameSettings.Coins.Add(_gameSettings.PacMan.Location.Left);
            _gameSettings.Coins.Add(_gameSettings.PacMan.Location.Left.Left);
            _gameSettings.Coins.Add(_gameSettings.PacMan.Location.Left.Left.Left);
            _gameSettings.Coins.Add(_gameSettings.PacMan.Location.Left.Left.Left.Left);
            _gameSettings.Coins.Add(_gameSettings.PacMan.Location.Left.Left.Left.Left.Left);

            var gameHarness = new GameHarness(_gameSettings);

            gameHarness.StartGame();

            await gameHarness.ChangeDirection(Direction.Left);

            await gameHarness.EatCoin();

            await gameHarness.EatCoin();

            await gameHarness.EatCoin();

            await gameHarness.EatCoin();

            await gameHarness.EatCoin();

            gameHarness.Game.Fruits.Should().BeEquivalentTo(new
            {
                Location = _gameSettings.Fruit,
                Type     = FruitType.Cherry
            });
        }
Exemplo n.º 5
0
        public async Task PacManDoesNotEatPowerPillAndScoreStaysTheSameWhenCollidesWithGhost()
        {
            var pillAndGhostLocation = _gameSettings.PacMan.Location + Direction.Right;

            var ghost = GhostBuilder.New()
                        .WithLocation(pillAndGhostLocation)
                        .Create();

            _gameSettings.Ghosts.Add(ghost);
            _gameSettings.PowerPills.Add(pillAndGhostLocation);

            var gameHarness = new GameHarness(_gameSettings);

            gameHarness.StartGame();

            var score = gameHarness.Score;

            await gameHarness.ChangeDirection(Direction.Right);

            await gameHarness.GetEatenByGhost(ghost);

            using var _ = new AssertionScope();
            gameHarness.Game.PowerPills.Should().ContainEquivalentOf(pillAndGhostLocation);
            gameHarness.Score.Should().Be(score);
        }
Exemplo n.º 6
0
        public async Task WeGetAnExtraLifeWhenScoreReachesBonusLifePointAfterEatingAGhost()
        {
            var gameSettings = new TestGameSettings();

            var ghostStart = gameSettings.PacMan.Location.Left.Left.Left;
            var ghost      = GhostBuilder.New()
                             .WithLocation(ghostStart)
                             .WithChaseStrategyRight()
                             .WithScatterStrategyRight()
                             .Create();

            gameSettings.Ghosts.Add(ghost);
            gameSettings.PowerPills.Add(gameSettings.PacMan.Location.FarAway());
            gameSettings.PowerPills.Add(gameSettings.PacMan.Location.Left);
            gameSettings.PointsNeededForBonusLife = PointsFor.EatingFirstGhost;

            var gameHarness = new GameHarness(gameSettings);
            await gameHarness.PlayGame();

            await gameHarness.ChangeDirection(Direction.Left);

            await gameHarness.EatPill();

            var previousLives = gameHarness.Lives;

            using var _ = new AssertionScope();
            await gameHarness.AssertSingleNotificationFires(GameNotification.ExtraPac, async() =>
            {
                await gameHarness.EatGhost(ghost);
            });

            gameHarness.Game.Lives.Should().Be(previousLives + 1);
        }
Exemplo n.º 7
0
        public async Task WeGetAnExtraLifeOnceWhenScoreReachesBonusLifePointAfterScoreIncreasesFromEatingFurtherCoins()
        {
            var gameSettings = new TestGameSettings();

            gameSettings.Coins.Add(gameSettings.PacMan.Location.Below);
            gameSettings.Coins.Add(gameSettings.PacMan.Location.Below.Below);
            gameSettings.Coins.Add(gameSettings.PacMan.Location.FarAway());
            gameSettings.PointsNeededForBonusLife = PointsFor.EatingCoin + 1;

            var gameHarness = new GameHarness(gameSettings);
            await gameHarness.PlayGame();

            var previousLives = gameHarness.Lives;

            await gameHarness.ChangeDirection(Direction.Down);

            await gameHarness.EatCoin();

            using var _ = new AssertionScope();
            await gameHarness.AssertSingleNotificationFires(GameNotification.ExtraPac, async() =>
            {
                await gameHarness.EatCoin();
            });

            gameHarness.Game.Lives.Should().Be(previousLives + 1);
        }
Exemplo n.º 8
0
        private async Task <GameHarness> PlayGameUntilFruitAppears(CellLocation fruitLocation)
        {
            _gameSettings.Fruit = fruitLocation;
            _gameSettings.FruitAppearsAfterCoinsEaten.Add(2);

            _gameSettings.Coins.Add(_gameSettings.PacMan.Location.Left);
            _gameSettings.Coins.Add(_gameSettings.PacMan.Location.Left.Left);
            _gameSettings.Coins.Add(_gameSettings.PacMan.Location.FarAway());

            var gameHarness = new GameHarness(_gameSettings);

            gameHarness.StartGame();
            await gameHarness.ChangeDirection(Direction.Left);

            await gameHarness.EatCoin();

            await gameHarness.EatCoin();

            if (!gameHarness.Game.Fruits.Any())
            {
                throw new Exception("Fruit should be visible");
            }

            return(gameHarness);
        }
Exemplo n.º 9
0
        public async Task PacManDoesNotCollectCoinAndScoreStaysTheSameWhenCollidesWithGhost()
        {
            var ghostAndCoinLocation = _gameSettings.PacMan.Location + Direction.Right;

            var ghost = GhostBuilder.New()
                        .WithLocation(ghostAndCoinLocation)
                        .WithScatterStrategy(new StandingStillGhostStrategy())
                        .Create();

            _gameSettings.Ghosts.Add(ghost);
            _gameSettings.Coins.Add(ghostAndCoinLocation);

            var gameHarness = new GameHarness(_gameSettings);
            await gameHarness.PlayGame();

            var score = gameHarness.Score;

            await gameHarness.ChangeDirection(Direction.Right);

            await gameHarness.GetEatenByGhost(ghost);

            using var _ = new AssertionScope();
            gameHarness.Game.Coins.Should().ContainEquivalentOf(ghostAndCoinLocation);
            gameHarness.Score.Should().Be(score);
        }
Exemplo n.º 10
0
        public async Task LivesDecreaseWhenCollidesWithGhostWalkingTowardsPacMan()
        {
            // G . . . P
            // . G . P .
            // . . PG . .
            var ghost = GhostBuilder.New()
                        .WithLocation(_gameSettings.PacMan.Location.Left.Left.Left.Left)
                        .WithChaseStrategyRight()
                        .WithScatterStrategyRight()
                        .Create();

            _gameSettings.Ghosts.Add(ghost);

            var gameHarness = new GameHarness(_gameSettings);
            await gameHarness.PlayGame();

            var currentLives = gameHarness.Lives;

            await gameHarness.ChangeDirection(Direction.Left);

            await gameHarness.Move();

            await gameHarness.GetEatenByGhost(ghost);

            gameHarness.Lives.Should().Be(currentLives - 1);
        }
Exemplo n.º 11
0
        public async Task CannotCollectTheSameCoinTwice()
        {
            var pacManStartingLocation = _gameSettings.PacMan.Location;

            _gameSettings.Coins.Add(pacManStartingLocation.Below);
            _gameSettings.Coins.Add(pacManStartingLocation.FarAway());

            var gameHarness = new GameHarness(_gameSettings);

            gameHarness.StartGame();

            await gameHarness.ChangeDirection(Direction.Down);

            await gameHarness.EatCoin();

            await gameHarness.ChangeDirection(Direction.Up);

            await gameHarness.Move();

            await gameHarness.ChangeDirection(Direction.Down);

            await gameHarness.Move();

            gameHarness.Score.Should().Be(10);
        }
Exemplo n.º 12
0
        public async Task ShouldNotLoseLifeWhenAlreadyIsDying()
        {
            var ghost = GhostBuilder.New()
                        .WithLocation(_gameSettings.PacMan.Location.Left)
                        .WithScatterStrategyRight()
                        .Create();

            _gameSettings.Ghosts.Add(ghost);

            var ghost2 = GhostBuilder.New()
                         .WithLocation(_gameSettings.PacMan.Location.Left.Left)
                         .WithScatterStrategyRight()
                         .Create();

            _gameSettings.Ghosts.Add(ghost2);

            var gameHarness = new GameHarness(_gameSettings);
            await gameHarness.PlayGame();

            await gameHarness.ChangeDirection(Direction.Left);

            await gameHarness.GetEatenByGhost(ghost);

            gameHarness.WeExpectThatPacMan().HasLives(_gameSettings.InitialLives - 1);

            gameHarness.EnsureGameStatus(GameStatus.Dying);

            await gameHarness.NOP();

            gameHarness.EnsureGameStatus(GameStatus.Dying);

            gameHarness.Lives.Should().Be(_gameSettings.InitialLives - 1);
        }
Exemplo n.º 13
0
        public async Task TheHighScoreAlwaysIncrementsAfterEatingAGhostDuringTheFirstGame()
        {
            var gameSettings = new TestGameSettings();

            var ghostStart = gameSettings.PacMan.Location.Left.Left.Left;
            var ghost      = GhostBuilder.New()
                             .WithLocation(ghostStart)
                             .WithChaseStrategyRight()
                             .WithScatterStrategyRight()
                             .Create();

            gameSettings.Ghosts.Add(ghost);
            gameSettings.PowerPills.Add(gameSettings.PacMan.Location.FarAway());
            gameSettings.PowerPills.Add(gameSettings.PacMan.Location.Left);

            var gameHarness = new GameHarness(gameSettings);
            await gameHarness.PlayGame();

            gameHarness.WeExpectThatPacMan().IsAt(gameSettings.PacMan.Location);
            gameHarness.WeExpectThatGhost(ghost).IsAt(gameSettings.PacMan.Location.Left.Left.Left);

            await gameHarness.ChangeDirection(Direction.Left);

            await gameHarness.EatPill();

            gameHarness.WeExpectThatPacMan().IsAt(gameSettings.PacMan.Location.Left);
            gameHarness.WeExpectThatGhost(ghost).IsAt(gameSettings.PacMan.Location.Left.Left);

            await gameHarness.EatGhost(ghost);

            gameHarness.Game.HighScore.Should().Be(gameHarness.Score);
        }
Exemplo n.º 14
0
        public async Task ShouldNotWalkVerticallyInToWalls()
        {
            var wallLocation       = _gameSettings.PacMan.Location.Below;
            var ghostStartLocation = _gameSettings.PacMan.Location.Below.Below;

            _gameSettings.Walls.Add(wallLocation);
            var ghost = _ghostBuilder.WithLocation(ghostStartLocation).Create();

            _gameSettings.Ghosts.Add(ghost);

            var gameHarness = new GameHarness(_gameSettings);

            gameHarness.StartGame();
            await gameHarness.Move();

            using var _ = new AssertionScope();
            gameHarness.Game.Ghosts[ghost.Name].Should().NotBeEquivalentTo(new
            {
                Location = wallLocation
            });

            gameHarness.Game.Ghosts[ghost.Name].Should().NotBeEquivalentTo(new
            {
                Location = ghostStartLocation
            });
        }
Exemplo n.º 15
0
        public async Task TheHighScoreDoesNotIncrementAfterEatingACoinIfTheScoreIsNotHigherThanTheCurrentHighScore()
        {
            const int initialHighScore = 1000;

            _highScore = initialHighScore;
            var gameSettings = new TestGameSettings();

            gameSettings.HighScoreStorage = this;
            gameSettings.Coins.Add(gameSettings.PacMan.Location.Below);
            gameSettings.Coins.Add(gameSettings.PacMan.Location.FarAway());

            var gameHarness = new GameHarness(gameSettings);
            await gameHarness.PlayGame();

            await gameHarness.ChangeDirection(Direction.Down);

            if (gameHarness.Game.HighScore != initialHighScore)
            {
                throw new Exception($"The current high score should be {initialHighScore} not {gameHarness.Game.HighScore}.");
            }

            await gameHarness.EatCoin();

            gameHarness.Game.HighScore.Should().Be(initialHighScore);
        }
Exemplo n.º 16
0
        public void CanReadPortalsFromGame()
        {
            _gameSettings.Portals.Add((1, 2), (3, 4));

            var gameHarness = new GameHarness(_gameSettings);

            gameHarness.Game.Portals.Should().BeEquivalentTo(new Dictionary <CellLocation, CellLocation>
            {
Exemplo n.º 17
0
        public void TheGameCanReadTheHeightFromTheBoard()
        {
            var gameBoardHeight = 100;

            _gameSettings.Height = gameBoardHeight;

            var gameHarness = new GameHarness(_gameSettings);

            gameHarness.Game.Height.Should().Be(gameBoardHeight);
        }
Exemplo n.º 18
0
        public void TheGameCanReadTheWidthFromTheBoard()
        {
            var gameBoardWidth = 100;

            _gameSettings.Width = gameBoardWidth;

            var gameHarness = new GameHarness(_gameSettings);

            gameHarness.Game.Width.Should().Be(gameBoardWidth);
        }
Exemplo n.º 19
0
        public async Task TheGameResumesAfterBeingPausedForOneSecondAfterGhostIsEaten()
        {
            //      P
            //   .  *
            // G .  .

            var ghostStart1 = _gameSettings.PacMan.Location.Below.Below.Left.Left;
            var ghost1      = GhostBuilder.New()
                              .WithLocation(ghostStart1)
                              .WithChaseStrategyRight()
                              .Create();
            var ghost2 = GhostBuilder.New()
                         .WithLocation(_gameSettings.PacMan.Location.FarAway())
                         .WithChaseStrategyRight()
                         .Create();

            _gameSettings.Ghosts.Add(ghost1);
            _gameSettings.Ghosts.Add(ghost2);

            _gameSettings.PowerPills.Add(_gameSettings.PacMan.Location.Below);


            var gameHarness = new GameHarness(_gameSettings);

            gameHarness.Game.StartGame();

            await gameHarness.ChangeDirection(Direction.Down);

            await gameHarness.EatPill();

            gameHarness.WeExpectThatPacMan().IsAt(_gameSettings.PacMan.Location.Below);
            gameHarness.WeExpectThatGhost(ghost1).IsAt(ghostStart1.Right);

            await gameHarness.EatGhost(ghost1);

            gameHarness.WeExpectThatPacMan().IsAt(_gameSettings.PacMan.Location.Below.Below);

            var pacManLocation = gameHarness.Game.PacMan.Location;
            var ghostLocations = gameHarness.Game.Ghosts.Values.Select(x => new {
                x.Name,
                x.Location
            }).ToDictionary(x => x.Name);

            await gameHarness.WaitForPauseToComplete();

            await gameHarness.Move();

            using var _ = new AssertionScope();
            gameHarness.Game.PacMan.Should().NotBeEquivalentTo(new
            {
                Location = pacManLocation
            });
            gameHarness.Game.Ghosts.Should().NotBeEmpty();
            gameHarness.Game.Ghosts.Should().NotBeEquivalentTo(ghostLocations);
        }
Exemplo n.º 20
0
        public async Task FruitShouldNotBeVisibleWhenStartingGame()
        {
            var fruitLocation = _gameSettings.PacMan.Location.FarAway();

            _gameSettings.Fruit = fruitLocation;

            var gameHarness = new GameHarness(_gameSettings);
            await gameHarness.PlayGame();

            gameHarness.Game.Fruits.Should().BeEmpty();
        }
Exemplo n.º 21
0
        public async Task IncrementsScoreBy50WhenPowerPillCollected()
        {
            _gameSettings.PowerPills.Add(_gameSettings.PacMan.Location.Below);
            var gameHarness = new GameHarness(_gameSettings);

            gameHarness.StartGame();
            await gameHarness.ChangeDirection(Direction.Down);

            await gameHarness.EatPill();

            gameHarness.Score.Should().Be(50);
        }
Exemplo n.º 22
0
        public async Task AllGhostsShouldChangeDirectionWhenPacManEatsPowerPill()
        {
            var ghost1 = GhostBuilder.New()
                         .WithLocation(_gameSettings.PacMan.Location.FarAway())
                         .WithDirection(Direction.Up)
                         .Create();
            var ghost2 = GhostBuilder.New()
                         .WithLocation(_gameSettings.PacMan.Location.FarAway())
                         .WithDirection(Direction.Down)
                         .Create();
            var ghost3 = GhostBuilder.New()
                         .WithLocation(_gameSettings.PacMan.Location.FarAway())
                         .WithDirection(Direction.Left)
                         .Create();
            var ghost4 = GhostBuilder.New()
                         .WithLocation(_gameSettings.PacMan.Location.FarAway())
                         .WithDirection(Direction.Right)
                         .Create();

            _gameSettings.Ghosts.AddRange(new[] { ghost1, ghost2, ghost3, ghost4 });

            _gameSettings.PowerPills.Add(_gameSettings.PacMan.Location.FarAway());
            _gameSettings.PowerPills.Add(_gameSettings.PacMan.Location.Right);

            var gameHarness = new GameHarness(_gameSettings);

            gameHarness.StartGame();

            await gameHarness.ChangeDirection(Direction.Right);

            await gameHarness.EatPill();

            gameHarness.Game.Ghosts.Should().BeEquivalentTo(new Dictionary <string, object>
            {
                [ghost1.Name] = new
                {
                    Direction = ghost1.Direction.Opposite()
                },
                [ghost2.Name] = new
                {
                    Direction = ghost2.Direction.Opposite()
                },
                [ghost3.Name] = new
                {
                    Direction = ghost3.Direction.Opposite()
                },
                [ghost4.Name] = new
                {
                    Direction = ghost4.Direction.Opposite()
                },
            });
        }
Exemplo n.º 23
0
        public async Task GameStateStaysAlivewhenPillCollected()
        {
            _gameSettings.PowerPills.Add(_gameSettings.PacMan.Location.Below);
            _gameSettings.Coins.Add(_gameSettings.PacMan.Location.FarAway());
            var gameHarness = new GameHarness(_gameSettings);
            await gameHarness.PlayGame();

            await gameHarness.ChangeDirection(Direction.Down);

            await gameHarness.EatPill();

            gameHarness.Status.Should().Be(GameStatus.Alive);
        }
Exemplo n.º 24
0
        public async Task ShouldBeAbleToTargetWherePacManWillBe()
        {
            var gameHarness = new GameHarness(_gameSettings);
            await gameHarness.PlayGame();

            var directToExpectedPacManLocation = new DirectToExpectedPacManLocation();
            var targetLocation = directToExpectedPacManLocation.GetLocation(gameHarness.Game);

            targetLocation.Should().BeEquivalentTo(new
            {
                _gameSettings.PacMan.Location.Right.Right.Right.Right.Right
            });
        }
Exemplo n.º 25
0
        public async Task PacManStartsInInitialPosition()
        {
            var initialPosition = _gameSettings.PacMan.Location;

            var gameHarness = new GameHarness(_gameSettings);
            await gameHarness.PlayGame();

            gameHarness.Game.PacMan.Should().BeEquivalentTo(new
            {
                Location  = initialPosition,
                Direction = Direction.Right
            });
        }
Exemplo n.º 26
0
        public async Task ScoreDoesNotChangeWhenNoCoinIsCollected()
        {
            var gameHarness = new GameHarness(_gameSettings);
            await gameHarness.PlayGame();

            var score = gameHarness.Score;

            await gameHarness.ChangeDirection(Direction.Down);

            await gameHarness.Move();

            gameHarness.Score.Should().Be(score);
        }
Exemplo n.º 27
0
        public async Task GhostShouldBeRunningHomeAfterThePauseAfterBeingTheEaten()
        {
            //      P
            //   .  *
            // G .  .

            var ghostStart1 = _gameSettings.PacMan.Location.Below.Below.Left.Left;
            var ghost1      = GhostBuilder.New()
                              .WithLocation(ghostStart1)
                              .WithChaseStrategyRight()
                              .Create();
            var ghost2 = GhostBuilder.New()
                         .WithLocation(_gameSettings.PacMan.Location.FarAway())
                         .WithChaseStrategyRight()
                         .Create();

            _gameSettings.Ghosts.Add(ghost1);
            _gameSettings.Ghosts.Add(ghost2);

            _gameSettings.PowerPills.Add(_gameSettings.PacMan.Location.Below);


            var gameHarness = new GameHarness(_gameSettings);

            gameHarness.Game.StartGame();

            await gameHarness.ChangeDirection(Direction.Down);

            await gameHarness.EatPill();

            gameHarness.WeExpectThatPacMan().IsAt(_gameSettings.PacMan.Location.Below);
            gameHarness.WeExpectThatGhost(ghost1).IsAt(ghostStart1.Right);

            await gameHarness.EatGhost(ghost1);

            gameHarness.WeExpectThatPacMan().IsAt(_gameSettings.PacMan.Location.Below.Below);

            var pacManLocation = gameHarness.Game.PacMan.Location;
            var ghostLocations = gameHarness.Game.Ghosts.Values.Select(x => new {
                x.Name,
                x.Location
            }).ToDictionary(x => x.Name);

            await gameHarness.WaitForPauseToComplete();

            await gameHarness.Move();

            using var _ = new AssertionScope();
            gameHarness.Game.Ghosts[ghost1.Name].Status.Should().Be(GhostStatus.RunningHome);
            gameHarness.Game.Ghosts[ghost2.Name].Status.Should().Be(GhostStatus.Edible);
        }
Exemplo n.º 28
0
        public async Task CoinShouldBeCollected()
        {
            var coinLocation = _gameSettings.PacMan.Location.Below;

            _gameSettings.Coins.Add(coinLocation);

            var gameHarness = new GameHarness(_gameSettings);
            await gameHarness.PlayGame();

            await gameHarness.ChangeDirection(Direction.Down);

            await gameHarness.EatCoin();

            gameHarness.Game.Coins.Should().NotContain(coinLocation);
        }
Exemplo n.º 29
0
        public async Task IncrementsScoreBy10WhenCoinCollected()
        {
            var pacManStartingLocation = _gameSettings.PacMan.Location;

            _gameSettings.Coins.Add(pacManStartingLocation.Below);

            var gameHarness = new GameHarness(_gameSettings);
            await gameHarness.PlayGame();

            await gameHarness.ChangeDirection(Direction.Down);

            await gameHarness.EatCoin();

            gameHarness.Score.Should().Be(10);
        }
Exemplo n.º 30
0
        public async Task TheHighScoreAlwaysIncrementsAfterEatingAPowerPillDuringTheFirstGame()
        {
            var gameSettings = new TestGameSettings();

            gameSettings.PowerPills.Add(gameSettings.PacMan.Location.Below);
            gameSettings.PowerPills.Add(gameSettings.PacMan.Location.FarAway());

            var gameHarness = new GameHarness(gameSettings);
            await gameHarness.PlayGame();

            await gameHarness.ChangeDirection(Direction.Down);

            await gameHarness.EatPill();

            gameHarness.Game.HighScore.Should().Be(gameHarness.Score);
        }