Exemple #1
0
        public void GuessTest_Cows4()
        {
            CowsAndBulls game = new CowsAndBulls();

            game.Guess("1234", "1234");
            Assert.Equal(4, game.GuessedCows);
        }
Exemple #2
0
        public void ConstructorTest()
        {
            CowsAndBulls game = new CowsAndBulls();

            Assert.Equal("Playing", game.Status);
            Assert.Equal(0, game.Guesses);
        }
Exemple #3
0
        public void GuessTest_Cows2Bulls2()
        {
            CowsAndBulls game = new CowsAndBulls();

            game.Guess("1100", "1010");
            Assert.Equal(2, game.GuessedCows);
            Assert.Equal(2, game.GuessedBulls);
        }
Exemple #4
0
        public void Test3()
        {
            var guesser = new CowsAndBulls();

            Assert.Equal(4, guesser.CountCows(guesser.Goal));
            Assert.Equal(3, guesser.CountCows(new string(String.Empty + guesser.Goal[0] + guesser.Goal[1] + guesser.Goal[2] + guesser.Goal[0])));
            Assert.Equal(2, guesser.CountCows(new string(String.Empty + guesser.Goal[0] + guesser.Goal[1] + guesser.Goal[1] + guesser.Goal[0])));
            Assert.Equal(1, guesser.CountCows(new string(String.Empty + guesser.Goal[0] + guesser.Goal[2] + guesser.Goal[1] + guesser.Goal[0])));
            Assert.Equal(0, guesser.CountCows(new string(String.Empty + guesser.Goal[3] + guesser.Goal[2] + guesser.Goal[1] + guesser.Goal[0])));
        }
Exemple #5
0
        public void Test2()
        {
            var guesser = new CowsAndBulls();

            Assert.Equal(0, guesser.CountBulls("1234", "1234"));
            Assert.Equal(1, guesser.CountBulls("1234", "1231"));
            Assert.Equal(2, guesser.CountBulls("1234", "1241"));
            Assert.Equal(3, guesser.CountBulls("1234", "1341"));
            Assert.Equal(4, guesser.CountBulls("1234", "2341"));
        }
Exemple #6
0
        public void Test1()
        {
            var guesser = new CowsAndBulls();

            for (int num = 0; num < 100000; num++)
            {
                if (num < 1000 || num > 9999)
                {
                    Assert.Equal("bad input", guesser.Guess(num));
                }
                else
                {
                    Assert.NotEqual("bad input", guesser.Guess(num));
                }
            }
        }
Exemple #7
0
        public void CheckUserInputTest_CorrectInput()
        {
            CowsAndBulls game = new CowsAndBulls();

            Assert.True(game.CheckUserInput("1234"));
        }
Exemple #8
0
        public void CheckUserInputTest_FalseInput(string guess)
        {
            CowsAndBulls game = new CowsAndBulls();

            Assert.False(game.CheckUserInput(guess));
        }
Exemple #9
0
        public void RandomNumberTest_ContainsNumbers()
        {
            CowsAndBulls game = new CowsAndBulls();

            Assert.True(Int32.Parse(game.RandomNumber()) >= 0 && Int32.Parse(game.RandomNumber()) <= 9999);
        }
Exemple #10
0
        public void RandomNumberTest_ProperLength()
        {
            CowsAndBulls game = new CowsAndBulls();

            Assert.Equal(4, game.RandomNumber().Length);
        }