public void GetQuitResponseTest() { var reader = new TestConsoleReader("Q"); var userInput = new UserInput(reader); var expected = new Response(ResponseType.PlayerChoseQuit); var actual = userInput.GetResponse(); Assert.Equal(expected, actual); }
public void GetRerollResponseTest(ResponseType expectedType, string userInputString) { var reader = new TestConsoleReader(userInputString); var userInput = new UserInput(reader); var expected = new Response(expectedType); var actual = userInput.GetResponse(); Assert.Equal(expected, actual); }
public void GetResponseShouldReturnHoldResponse(bool[] expectedDice, string userInputString) { var reader = new TestConsoleReader(userInputString); var userInput = new UserInput(reader); var expected = new Response(expectedDice); var actual = userInput.GetResponse(); Assert.Equal(expected, actual); }
public void GetResponseShouldReturnCategoryResponse(Category expectedCategory, string userInputString) { var reader = new TestConsoleReader(userInputString); var userInput = new UserInput(reader); var expected = new Response(expectedCategory); var actual = userInput.GetResponse(); Assert.Equal(expected, actual); }
public void PlayGameTestRollsLeft() { var reader = new TestConsoleReader(new List <string>() { "a,b", "q" }); var rng = new TestRng(6); var dice1 = new Die(rng); var dice2 = new Die(rng); var dice3 = new Die(rng); var dice4 = new Die(rng); var dice5 = new Die(rng); var game = new Game(dice1, dice2, dice3, dice4, dice5, new UserInput(reader), new bool[5]); game.Play(); Assert.Equal(1, game.RollsLeft); }
public void GameShouldQuitWhenAllCategoriesScored() { var reader = new TestConsoleReader(new List <string>() { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" }); var rng = new TestRng(6); var dice1 = new Die(rng); var dice2 = new Die(rng); var dice3 = new Die(rng); var dice4 = new Die(rng); var dice5 = new Die(rng); var game = new Game(dice1, dice2, dice3, dice4, dice5, new UserInput(reader), new bool[5]); game.Play(); Assert.False(game.PlayingGame); }
public void PlayGameAndTestGameStoresScoreInCategory() { var reader = new TestConsoleReader(new List <string>() { "1", "R", "R", "R", "q" }); var rng = new TestRng(1); var dice1 = new Die(rng); var dice2 = new Die(rng); var dice3 = new Die(rng); var dice4 = new Die(rng); var dice5 = new Die(rng); var game = new Game(dice1, dice2, dice3, dice4, dice5, new UserInput(reader), new bool[5]); game.Play(); Assert.Equal(5, game.ScoreCard.Scores.Where(cat => cat.Category == Category.Ones).Select(cat => cat.Score).First()); }
public void PlayGameTestQuit() { var reader = new TestConsoleReader(new List <string>() { "r", "Q" }); var rng1 = new TestRng(1); var rng5 = new TestRng(5); var dice1 = new Die(rng1); var dice2 = new Die(rng1); var dice3 = new Die(rng5); var dice4 = new Die(rng5); var dice5 = new Die(rng5); var game = new Game(dice1, dice2, dice3, dice4, dice5, new UserInput(reader), new bool[5]); game.Play(); Assert.Equal(0, game.ScoreCard.Total); }
public void HoldMethodShouldNotChangeHeldDiceValue() { var reader = new TestConsoleReader(new List <string>() { "a", "q" }); var rng = new TestRng(6); var dice1 = new Die(rng); var dice2 = new Die(rng); var dice3 = new Die(rng); var dice4 = new Die(rng); var dice5 = new Die(rng); var game = new Game(dice1, dice2, dice3, dice4, dice5, new UserInput(reader), new bool[5]); Assert.Equal(new List <int> { 6, 6, 6, 6, 6 }, game.GetValues()); rng.ChangeReturnValue(1); game.Hold(new[] { true, false, false, false, false }); game.Play(); Assert.Equal(new List <int> { 6, 1, 1, 1, 1 }, game.GetValues()); }