Exemplo n.º 1
0
        public void WinAllGamesUsingMaximumFiveGuesses()
        {
            const int NumberOfDifferentPegs = 6;
            const int NumberOfPegsPerLine   = 4;
            const int MaxNumberOfGuesses    = 5;
            var       player = new FiveGuessAlgorithmPlayer();
            var       lines  = LineGenerator.GenerateAllLines(NumberOfDifferentPegs, NumberOfPegsPerLine);
            // it is too slow to test all lines
            // we only test on average 1% of all the different lines (roughly 13 out of 1296)
            var random = new Random();

            lines = lines.Where(l => random.Next(100) == 10).ToList();
            Assert.All(lines,
                       secret =>
            {
                var game   = new Game(NumberOfDifferentPegs, NumberOfPegsPerLine, MaxNumberOfGuesses, secret);
                var result = game.Play(player);
                Assert.True(result.WasTheSecretGuessed);
            });
        }