public void ExpectScoreboardAddMethodToThrowsWhenNonePositiveIntegerForMovesIsProvided()
        {
            var scoreboard = new Scoreboard();
            var moves = -1;
            var playerName = "Test Player";

            scoreboard.Add(moves, playerName);
        }
        public void ExpectScoreboardAddMethodToAddScoreToTopsScores()
        {
            var moves = 5;
            var playerName = "Test Player";
            var scoreboard = new Scoreboard();
            scoreboard.Add(moves, playerName);
            var topScore = scoreboard.GetTopScores()[0];

            Assert.IsInstanceOfType(topScore, typeof(Score));
        }
        /// <summary>
        /// The main method of the Console UI of the game.
        /// </summary>
        public static void Main()
        {
            var printer = new Printer();

            var reader = new Reader();

            var gameInitializator = new GameInitializer.GameInitializer(printer, reader);

            var game = gameInitializator.Initialize();

            var scoreboard = new Scoreboard();

            var commandManager = new CommandManager();

            var boardHistory = new BoardHistory();

            EngineTemplate engine = new Engine.Engine(game, scoreboard, printer, reader, commandManager, boardHistory);

            engine.Run();
        }
        public void ExpectScoreboardAddMethodNotToAddScoreToTopsScoresWhenIsNotInTopScores()
        {
            var scoreboard = new Scoreboard();
            var playerName = "Test Player";
            var maxCountTopScores = Constants.ScoreboardMaxCount;

            for (int moves = 1; moves <= maxCountTopScores; moves++)
            {
                scoreboard.Add(moves, playerName);
            }

            scoreboard.Add(maxCountTopScores + 1, playerName);

            var actualCountOfScoresOutOfTop = scoreboard.GetTopScores()
                .Where(s => s.Moves == maxCountTopScores + 1)
                .Count();

            var expectedCountOfScoresOutOfTop = 0;

            Assert.AreEqual(expectedCountOfScoresOutOfTop, actualCountOfScoresOutOfTop);
        }
        public void ExpectToAddToScoreBoardOneMove()
        {
            var reader = MockStorage.GetReader("move 3");
            var scoreboard = new Scoreboard();

            var engine = new Engine(
                MockStorage.GetSelfSolvingGameAfterOneMove(),
                scoreboard,
                MockStorage.GetPrinter(),
                reader,
                new CommandManager(),
                new BoardHistory());

            engine.Run();
            Assert.AreEqual(1, scoreboard.GetTopScores().First().Moves);
        }
        public void ExpectScoreboardAddMethodToThrowsWhenNullIsProvidedForPlayerNameAndNonPositiveIntegerForMoves()
        {
            var scoreboard = new Scoreboard();
            var moves = -5;
            string playerName = null;

            scoreboard.Add(moves, playerName);
        }
        public void ExpectScoreboardToStringReturnsCorrectScoreboardString()
        {
            var scoreboard = new Scoreboard();
            var moves = 5;
            var playerName = "Test Player";
            scoreboard.Add(moves, playerName);

            var actualToString = scoreboard.ToString();
            var expectedToString = Constants.Scoreboard +
                                   Environment.NewLine +
                                   string.Format(Constants.ScoreboardFormat, 1, playerName, moves) +
                                   Environment.NewLine;

            Assert.AreEqual(expectedToString, actualToString);
        }
        public void ExpectScoreboardToStringReturnsConstanstScoreoardIsEmptyString()
        {
            var scoreboard = new Scoreboard();
            var actualToString = scoreboard.ToString();
            var expectedToString = Constants.ScoreboardIsEmpty
                 + Environment.NewLine;

            Assert.AreEqual(expectedToString, actualToString);
        }
        public void ExpectScoreboardIsInTopScoresMethodToToreturnTrueWhenTopScorProvided()
        {
            var scoreboard = new Scoreboard();
            var playerName = "Test Player";
            var maxCountTopScores = Constants.ScoreboardMaxCount;

            for (int moves = 1; moves <= maxCountTopScores; moves++)
            {
                scoreboard.Add(moves, playerName);
            }

            var expecterIsInTopScore = scoreboard.IsInTopScores(maxCountTopScores - 1);

            Assert.IsTrue(expecterIsInTopScore);
        }
        public void ExpectScoreboardIsInTopScoresMethodToToreturnTrueWhenLessThanMaxCountOfScoresAreInTopScores()
        {
            var scoreboard = new Scoreboard();
            var moves = 5;
            var expecterIsInTopScore = scoreboard.IsInTopScores(moves);

            Assert.IsTrue(expecterIsInTopScore);
        }
        public void ExpectScoreboardAddMethodToThrowsWhenNullIsProvidedForPlayerNameParameter()
        {
            var scoreboard = new Scoreboard();
            var moves = 5;
            string playerName = null;

            scoreboard.Add(moves, playerName);
        }