Exemple #1
0
        public void RandomDoorValuesTest1()
        {
            GameOfMontyHall game = new GameOfMontyHall(3, 1000, new PlayerWhoDontChangeTheSelectedDoor());
            int             carIsBehindTheFirstDoorCounter  = 0;
            int             carIsBehindTheSecondDoorCounter = 0;
            int             carIsBehindTheThirdDoorCounter  = 0;

            for (int i = 0; i < 1000; i++)
            {
                game.DoorInit();

                if (game.Doors[0].BehindTheDoor == 1)
                {
                    carIsBehindTheFirstDoorCounter++;
                }
                if (game.Doors[1].BehindTheDoor == 1)
                {
                    carIsBehindTheSecondDoorCounter++;
                }
                if (game.Doors[2].BehindTheDoor == 1)
                {
                    carIsBehindTheThirdDoorCounter++;
                }
            }

            Console.WriteLine("RandomDoorValuesTest1: " +
                              carIsBehindTheFirstDoorCounter + " " +
                              carIsBehindTheSecondDoorCounter + " " +
                              carIsBehindTheThirdDoorCounter + "\n");

            Assert.IsTrue(carIsBehindTheFirstDoorCounter > 300 &&
                          carIsBehindTheSecondDoorCounter > 300 &&
                          carIsBehindTheThirdDoorCounter > 300);
        }
Exemple #2
0
        public void OpenRandomDoorTest1()
        {
            GameOfMontyHall game             = new GameOfMontyHall(3, 1000, new PlayerWhoChangeTheSelectedDoor());
            int             firstDoorIsOpen  = 0;
            int             secondDoorIsOpen = 0;
            int             thirdDoorIsOpen  = 0;

            for (int i = 0; i < 1000; i++)
            {
                game.DoorInit();
                game.SelectRandomDoor();
                game.OpenRandomDoor();


                if (game.Doors[0].IsDoorOpen == true)
                {
                    firstDoorIsOpen++;
                }
                if (game.Doors[1].IsDoorOpen == true)
                {
                    secondDoorIsOpen++;
                }
                if (game.Doors[2].IsDoorOpen == true)
                {
                    thirdDoorIsOpen++;
                }
            }

            Console.WriteLine("OpenRandomDoorTest1: " + firstDoorIsOpen + " " + secondDoorIsOpen + " " + thirdDoorIsOpen + "\n");

            Assert.IsTrue(firstDoorIsOpen > 300 &&
                          secondDoorIsOpen > 300 &&
                          thirdDoorIsOpen > 300);
        }
Exemple #3
0
        public void StartTheGame_PlayerChangesSelectedDoorTest2()
        {
            GameOfMontyHall game = new GameOfMontyHall(3, 10000, new PlayerWhoChangeTheSelectedDoor());

            game.Start();
            Console.WriteLine("NumberOfGamesWon: " + game.Player.NumberOfGamesWon);
            Assert.IsTrue(game.Player.NumberOfGamesWon > 6000);
        }
Exemple #4
0
        public void PlayerWonOneGameTest()
        {
            GameOfMontyHall game            = new GameOfMontyHall(3, 1000, new PlayerWhoDontChangeTheSelectedDoor());
            int             indexOfCarDoors = 0;

            game.DoorInit();
            for (int i = 0; i < game.Doors.Count; i++)
            {
                if (game.Doors[i].BehindTheDoor == 1)
                {
                    indexOfCarDoors = i;
                }
            }

            game.Player.SelectedDoor = indexOfCarDoors + 1;
            game.PlayerWonTheGame();
            Assert.AreEqual(1, game.Player.NumberOfGamesWon);
        }
Exemple #5
0
        public void ChangeTheSelectedDoorByPlayer1000TimesTest()
        {
            GameOfMontyHall game = new GameOfMontyHall(3, 1000, new PlayerWhoChangeTheSelectedDoor());

            int firstDoorIsSelectedCounter  = 0;
            int secondDoorIsSelectedCounter = 0;
            int thirdDoorIsSelectedCounter  = 0;

            for (int i = 0; i < 1000; i++)
            {
                game.DoorInit();
                game.SelectRandomDoor();
                game.OpenRandomDoor();
                game.Player.ChangeTheSelectedDoorByPlayer(game.Doors);

                switch (game.Player.SelectedDoor)
                {
                case 1:
                    firstDoorIsSelectedCounter++;
                    break;

                case 2:
                    secondDoorIsSelectedCounter++;
                    break;

                case 3:
                    thirdDoorIsSelectedCounter++;
                    break;

                default:
                    break;
                }
            }

            Console.WriteLine("SelectRandomDoorTest1: " +
                              firstDoorIsSelectedCounter + " " +
                              secondDoorIsSelectedCounter + " " +
                              thirdDoorIsSelectedCounter + "\n");

            Assert.IsTrue(firstDoorIsSelectedCounter > 300 &&
                          secondDoorIsSelectedCounter > 300 &&
                          thirdDoorIsSelectedCounter > 300);
        }