public void RockPaperScissorsRules_GetNextWinningMove_WinnerCorrect(int lastMove, int expectedResult) { //ARRANGE RockPaperScissorsRules ruleSet = new RockPaperScissorsRules(); //ACT var winningMove = ruleSet.GetNextWinningMove(lastMove); //ASSERT Assert.AreEqual(expectedResult, winningMove); }
public void RockPaperScissorsRules_GetWinningMove_WinnerCorrect(int playerOneMove, int playerTwoMove, int expectedResult) { //ARRANGE RockPaperScissorsRules ruleSet = new RockPaperScissorsRules(); //ACT var winningPlayer = ruleSet.GetWinningMove(playerOneMove, playerTwoMove); //ASSERT Assert.AreEqual(expectedResult, winningPlayer); }
public void ComputerPlayer_GetNextMove_NextMoveIsInsidePossibleMoves() { //ARRANGE IRules rules = new RockPaperScissorsRules(); IPlayer player = new ComputerPlayer(); //ACT int nextMove = player.GetNextMove(rules); //ASSERT Assert.That(nextMove, Is.InRange(1, 3)); }
public void TacticalPlayer_GetNextMove_NextMoveIsCorrect(int lastMove, int expectedMove) { //ARRANGE IRules rules = new RockPaperScissorsRules(); IPlayer player = new TacticalPlayer(lastMove); //ACT int nextMove = player.GetNextMove(rules); //ASSERT Assert.AreEqual(expectedMove, nextMove); }
public void HumanPlayer_GetNextMove_ThrowsAnExceptio() { //ARRANGE var expectedExceptionText = "UI is responsible to get next move for this type of player"; IRules rules = new RockPaperScissorsRules(); IPlayer player = MockRepository.GenerateStub <HumanPlayer>(); //ACT void testAction() { player.GetNextMove(rules); } //ASSERT Exception ex = Assert.Throws <Exception>(testAction); Assert.AreEqual(expectedExceptionText, ex.Message); }
static bool TryCreateGameRules(string type, out RuleList rules) { switch (type) { case "D": rules = new RockPaperScissorsRules(); break; case "E": rules = new RockPaperScissorsLizardSpockRules(); break; default: rules = null; break; } return(rules != null); }
public GameResult Play(string input) { Weapon computerWeapon = GetRandomWeapon(); Weapon playerWeapon = ConvertToWeapon(input); RockPaperScissorsRules game = new RockPaperScissorsRules(); var winningWeapon = game.Fight(playerWeapon, computerWeapon); if (winningWeapon == Weapon.None) { return(GameResult.Draw); } else if (winningWeapon == computerWeapon) { ComputerScore++; return(GameResult.Lose); } else { PlayerScore++; return(GameResult.Win); } }
public RockPaperScissorsRulesTests() { this.subject = new RockPaperScissorsRules(); }