public void CheckIncorectGuessAtempt()
        {
            BullsAndCowsNumber secretNumber = new BullsAndCowsNumber();

            string guess = "pesh";
            int bulls = 0, cows = 0;

            Assert.IsFalse(secretNumber.IsGuessCorrect(guess, ref bulls, ref cows));
        }
        public void CheckGuessWithGreaterLenght()
        {
            BullsAndCowsNumber secretNumber = new BullsAndCowsNumber();

            string guess = "12345";
            int bulls = 0, cows = 0;

            Assert.IsFalse(secretNumber.IsGuessCorrect(guess, ref bulls, ref cows));
        }
        public void FourCowsTest()
        {
            List<int> secretNumber = new List<int>() { 1, 2, 3, 4 };
            BullsAndCowsNumber game = new BullsAndCowsNumber();

            Type type = typeof(BullsAndCowsNumber);
            var fieldValue = type.GetField("secretDigits", BindingFlags.Instance | BindingFlags.NonPublic);
            fieldValue.SetValue(game, secretNumber);

            int bulls = 0;
            int cows = 0;
            game.IsGuessCorrect("4321", ref bulls, ref cows);
            Assert.IsTrue(bulls == 0 && cows == 4);
        }
        public void OneBullOneCowTest()
        {
            List<int> secretNumber = new List<int>() { 5, 5, 8, 9 };
            BullsAndCowsNumber game = new BullsAndCowsNumber();

            Type type = typeof(BullsAndCowsNumber);
            var fieldValue = type.GetField("secretDigits", BindingFlags.Instance | BindingFlags.NonPublic);
            fieldValue.SetValue(game, secretNumber);

            int bulls = 0;
            int cows = 0;
            game.IsGuessCorrect("4553", ref bulls, ref cows);
            Assert.IsTrue(bulls == 1 && cows == 1);
        }
        public void OneBullAndZeroCowsTestWithTwoEqualDigitsInTheGuess()
        {
            List<int> secretNumber = new List<int>() { 1, 2, 3, 4 };
            BullsAndCowsNumber game = new BullsAndCowsNumber();

            Type type = typeof(BullsAndCowsNumber);
            var fieldValue = type.GetField("secretDigits", BindingFlags.Instance | BindingFlags.NonPublic);
            fieldValue.SetValue(game, secretNumber);

            int bulls = 0;
            int cows = 0;
            game.IsGuessCorrect("2259", ref bulls, ref cows);
            Assert.IsTrue(bulls == 1 && cows == 0);
        }
        /// <summary>
        /// A private method which manages the user guess if the input is a string 
        /// different than a command. If the guess is a string of numbers, the 
        /// method is executed completely. If not prints an apropriate message.
        /// </summary>
        private void ManageUserGuess(string inputLine, BullsAndCowsNumber secretNumber)
        {
            int bullsCount = 0;
            int cowsCount = 0;

            if (secretNumber.IsGuessCorrect(inputLine, ref bullsCount, ref cowsCount))
            {
                this.atemptsCount++;

                if (bullsCount == secretNumber.DigitsNumber)
                {
                    Console.WriteLine("Congratulations! You guessed the secret number in {0} attempts and {1} cheats.", this.atemptsCount, this.helpUsedCount);
                    Console.WriteLine(new string('-', 80));

                    if (this.helpUsedCount == 0 && this.scoreBoard.IsHighScore(this.atemptsCount))
                    {
                        Console.WriteLine("Please enter your name for the top scoreboard: ");

                        string name = Console.ReadLine();
                        this.scoreBoard.Add(name, this.atemptsCount);
                    }
                    else
                    {
                        Console.WriteLine("You are not allowed to enter the top scoreboard.");
                    }

                    Console.WriteLine(this.scoreBoard);
                    this.StartGame();
                }
                else
                {
                    Console.WriteLine("Wrong number! Bulls: {0}, Cows: {1}\n", bullsCount, cowsCount);
                }
            }
            else
            {
                Console.WriteLine("Wrong input format!\n");
            }
        }