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)); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }