示例#1
0
        public void DartsGameTest_PlayTurn_ThrowsExceptionWhenTheGameIsAlreadyFinished()
        {
            _player2.SetupGet(p => p.HasWon).Returns(true);
            var dartsGame = new DartsGame(GameType.The301, new[] { _player1.Object, _player2.Object });

            dartsGame.PlayTurn();
        }
示例#2
0
        public void DartsGameTest_PlayTurn_AsksPlayersInOrderToPlayHisTurn()
        {
            var dartsGame = new DartsGame(GameType.The301, new[] { _player1.Object, _player2.Object });

            using (Sequence.Create())
            {
                _player1.Setup(p => p.PlayTurn()).InSequence();
                _player2.Setup(p => p.PlayTurn()).InSequence();

                dartsGame.PlayTurn();
            }
        }
示例#3
0
        public void DartsGameTest_PlayTurn_EndsTurnWhenAPlayerWins()
        {
            var player3 = new Mock <IPlayer>();

            _player2.SetupSequence(p => p.HasWon)
            .Returns(false)
            .Returns(true);
            var dartsGame = new DartsGame(GameType.The301, new[] { _player1.Object, _player2.Object, player3.Object });

            using (Sequence.Create())
            {
                _player1.Setup(p => p.PlayTurn()).InSequence();
                _player2.Setup(p => p.PlayTurn()).InSequence();

                dartsGame.PlayTurn();

                player3.Verify(p => p.PlayTurn(), Times.Never);
            }
        }