Exemplo n.º 1
0
        public void PlayerShouldBeAbleToSwitchSelectedDoor()
        {
            var montyHall = new MontyHall();

            montyHall.PlayGame(true);
            //assert if switched
        }
Exemplo n.º 2
0
        public void PlayerShouldSelectRandomDoor()
        {
            var montyHall = new MontyHall();

            montyHall.PlayGame(true);
            Assert.True(montyHall.Doors.Any(x => x.IsSelected));
        }
Exemplo n.º 3
0
        public void StartingNewGameShouldPlaceAPrizeBehindRandomDoor()
        {
            var montyHall = new MontyHall();

            montyHall.PlayGame(true);
            Assert.True(montyHall.Doors.Any(x => x.IsPrize));
        }
Exemplo n.º 4
0
        public void PlayGameShouldReturnTrueIfChosenDoorIsPrize()
        {
            var montyHall = new MontyHall();
            var car       = new TestRng(2);
            var choice    = new TestRng(0);
            var player    = new Player(choice, 1);

            Assert.Equal(Prize.Car, montyHall.PlayGame(car, player));
        }
Exemplo n.º 5
0
        public void SimulatorShouldDetermineIfPlayerSwitches(bool expected, int switchingChance)
        {
            var prize     = new TestRng(2);
            var choice    = new TestRng(0);
            var simulator = new Simulator();

            simulator.PlayAllGames(prize, choice, switchingChance);
            var montyHall = new MontyHall();
            var player    = new Player(choice, switchingChance);

            montyHall.PlayGame(prize, player);
            Assert.Equal(expected, montyHall.Doors[0].IsChosen);
        }
Exemplo n.º 6
0
 private void PlayGameAndGetScore(IRng doorToPlaceCar, IRng doorToChoose, double switchingChance)
 {
     for (var _ = 0; _ < NumberOfGames; _++)
     {
         var montyHall = new MontyHall();
         var player    = new Player(doorToChoose, switchingChance);
         var prize     = montyHall.PlayGame(doorToPlaceCar, player);
         if (prize == Prize.Car)
         {
             Wins++;
         }
         else
         {
             Losses++;
         }
     }
 }