示例#1
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));
        }
示例#2
0
        public void SimulatorShouldPlayGameWherePlayerSwitchesRandomly(int prizeDoor, int chosenDoor)
        {
            var prize     = new TestRng(prizeDoor);
            var choice    = new TestRng(chosenDoor);
            var simulator = new Simulator();

            Assert.Equal(1000, simulator.PlayAllGames(prize, choice, 1).Item1);
            Assert.Equal(0, simulator.PlayAllGames(prize, choice, 0).Item1);
        }
示例#3
0
        public void SimulateGamePlayGivenNumberOfTimesRecordsWinsAndLosses(int prizeNumber, int choiceNumber,
                                                                           int expected)
        {
            var prize     = new TestRng(prizeNumber);
            var choice    = new TestRng(choiceNumber);
            var simulator = new Simulator();

            simulator.PlayAllGames(prize, choice, 1);
            Assert.Equal(expected, simulator.PlayAllGames(prize, choice, 1).Item1);
        }
示例#4
0
        public void CreateThreeDoorsAssignsPrizeToRandomDoor()
        {
            var montyHall  = new MontyHall();
            var doorNumber = new TestRng(1);

            montyHall.SetUpThreeDoors(doorNumber);
            Assert.Equal(false, montyHall.Doors[0].Prize == Prize.Car);
            Assert.Equal(true, montyHall.Doors[1].Prize == Prize.Car);
            Assert.Equal(false, montyHall.Doors[2].Prize == Prize.Car);
        }
示例#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);
        }
示例#6
0
        public void PlayerShouldBeAbleToChooseARandomDoor()
        {
            var montyHall  = new MontyHall();
            var doorNumber = new TestRng(1);

            montyHall.SetUpThreeDoors(doorNumber);
            var choice = new TestRng(2);
            var player = new Player(choice, 0);

            player.ChooseRandomDoor(choice, montyHall.Doors);
            Assert.Equal(false, montyHall.Doors[0].IsChosen);
            Assert.Equal(false, montyHall.Doors[1].IsChosen);
            Assert.Equal(true, montyHall.Doors[2].IsChosen);
        }
示例#7
0
        public void HostShouldOpenAnUnSelectedDoorThatIsGoat()
        {
            var montyHall  = new MontyHall();
            var host       = new Host();
            var doorNumber = new TestRng(1);

            montyHall.SetUpThreeDoors(doorNumber);
            var choice = new TestRng(2);
            var player = new Player(choice, 0);

            player.ChooseRandomDoor(choice, montyHall.Doors);
            host.OpenUnselectedDoorThatIsGoat(montyHall.Doors);
            Assert.Equal(true, montyHall.Doors[0].IsOpened);
            Assert.Equal(false, montyHall.Doors[1].IsOpened);
            Assert.Equal(false, montyHall.Doors[2].IsOpened);
        }
示例#8
0
        public void PlayerShouldBeAbleToASwitchDoors()
        {
            var montyHall  = new MontyHall();
            var host       = new Host();
            var doorNumber = new TestRng(1);

            montyHall.SetUpThreeDoors(doorNumber);
            var choice = new TestRng(2);
            var player = new Player(choice, 1);

            player.ChooseRandomDoor(choice, montyHall.Doors);
            host.OpenUnselectedDoorThatIsGoat(montyHall.Doors);
            player.SwitchDoor(montyHall.Doors);
            Assert.Equal(false, montyHall.Doors[0].IsChosen);
            Assert.Equal(true, montyHall.Doors[1].IsChosen);
            Assert.Equal(false, montyHall.Doors[2].IsChosen);
        }