public void ShouldUseRulesEachRound() { var match = new RockPaperScissors.Match(rulesMock.Object); var results = match.Play(3, rockPlayerMock.Object, paperPlayerMock.Object); rulesMock.Verify(m => m.GetScore(It.IsAny <Move>(), It.IsAny <Move>()), Times.Exactly(3)); }
public void ShouldUsePlayersMovesEachRound() { var match = new RockPaperScissors.Match(rulesMock.Object); var results = match.Play(3, rockPlayerMock.Object, paperPlayerMock.Object); rockPlayerMock.Verify(m => m.Move(), Times.Exactly(3)); paperPlayerMock.Verify(m => m.Move(), Times.Exactly(3)); }
public void MatchResultsHaveCorrectNumberOfRounds() { var match = new RockPaperScissors.Match(rulesMock.Object); var results = match.Play(5, rockPlayerMock.Object, paperPlayerMock.Object); Assert.AreEqual(5, results.Rounds.Count()); results = match.Play(3, rockPlayerMock.Object, paperPlayerMock.Object); Assert.AreEqual(3, results.Rounds.Count()); }
public void ProducesRoundsWithCorrectResults() { var match = new RockPaperScissors.Match(rulesMock.Object); var results = match.Play(3, rockPlayerMock.Object, paperPlayerMock.Object); var firstRound = results.Rounds.First(); Assert.AreEqual(Move.Rock, firstRound.Player1Move); Assert.AreEqual(Move.Paper, firstRound.Player2Move); Assert.AreEqual(-1, firstRound.Player1Score); Assert.AreEqual(1, firstRound.Player2Score); }
public void EachRoundRaisesRoundPlayedEvent() { var rounds = new List <MatchResults.Round>(); var match = new RockPaperScissors.Match(rulesMock.Object); match.RoundPlayed += (o, e) => { rounds.Add(e.Round); }; match.Play(3, rockPlayerMock.Object, paperPlayerMock.Object); Assert.AreEqual(3, rounds.Count); }
public void PlayerTwoWinsTwoGamesAndMatch() { match = new RockPaperScissors.Match(mockPlayerOne.Object, mockPlayerTwo.Object); mockPlayerOne.SetupSequence(x => x.GetPlayerMove()) .Returns(Move.Scissors) .Returns(Move.Paper) .Returns(Move.Rock); mockPlayerTwo.SetupSequence(x => x.GetPlayerMove()) .Returns(Move.Rock) .Returns(Move.Rock) .Returns(Move.Paper); Assert.AreEqual(MatchResult.PlayerTwoWins, match.Start()); }
public void AllGamesDrawSoMatchIsADraw() { match = new RockPaperScissors.Match(mockPlayerOne.Object, mockPlayerTwo.Object); mockPlayerOne.SetupSequence(x => x.GetPlayerMove()) .Returns(Move.Rock) .Returns(Move.Paper) .Returns(Move.Scissors); mockPlayerTwo.SetupSequence(x => x.GetPlayerMove()) .Returns(Move.Rock) .Returns(Move.Paper) .Returns(Move.Scissors); Assert.AreEqual(MatchResult.Draw, match.Start()); }