public static void Main(string[] args) { var consoleReader = new ConsoleReader(); var player = new Player(consoleReader); var scoreCard = new ScoreCard(); var rng = new Rng(); var yatzy = new YatzyGame(player, scoreCard, rng); Display.WelcomeMessage(); yatzy.PlayGame(); }
public void GameShouldThrowRoundOverExceptionWhenRollsExceeded() { var mockRng = new Mock <IRng>(); mockRng.Setup(rng => rng.Next(It.IsAny <int>(), It.IsAny <int>())).Returns(1); var mockInput = new Mock <IConsoleReader>(); mockInput.SetupSequence(consoleReader => consoleReader.GetInput()).Returns("r").Returns("r").Returns("r").Returns("q"); var player = new Player(mockInput.Object); var scoreCard = new ScoreCard(); var yatzy = new YatzyGame(player, scoreCard, mockRng.Object); Assert.Throws <RoundOverException>(() => yatzy.PlayGame()); }
public void GameShouldEndWhenUserRespondsQuit() { var mockRng = new Mock <IRng>(); mockRng.Setup(rng => rng.Next(It.IsAny <int>(), It.IsAny <int>())).Returns(1); var mockInput = new Mock <IConsoleReader>(); mockInput.Setup(consoleReader => consoleReader.GetInput()).Returns("q"); var player = new Player(mockInput.Object); var scoreCard = new ScoreCard(); var yatzy = new YatzyGame(player, scoreCard, mockRng.Object); yatzy.PlayGame(); Assert.False(yatzy.IsPlayingGame); }
public void GameShouldEndWhenAllCategoriesScored() { var mockRng = new Mock <IRng>(); mockRng.Setup(rng => rng.Next(It.IsAny <int>(), It.IsAny <int>())).Returns(1); var mockInput = new Mock <IConsoleReader>(); mockInput.SetupSequence(consoleReader => consoleReader.GetInput()).Returns("a").Returns("b").Returns("c").Returns("d").Returns("e").Returns("f").Returns("g").Returns("h").Returns("i").Returns("j").Returns("k").Returns("l").Returns("m").Returns("n").Returns("o"); var player = new Player(mockInput.Object); var scoreCard = new ScoreCard(); var yatzy = new YatzyGame(player, scoreCard, mockRng.Object); yatzy.PlayGame(); Assert.False(yatzy.IsPlayingGame); }