コード例 #1
0
 public void GameClosedByShouldReturnSecondPlayerWhenTheSecondPlayerIsGameCloser()
 {
     var firstRoundPlayerInfo = new RoundPlayerInfo(new Mock<IPlayer>().Object);
     var secondRoundPlayerInfo = new RoundPlayerInfo(new Mock<IPlayer>().Object) { GameCloser = true };
     var roundResult = new RoundResult(firstRoundPlayerInfo, secondRoundPlayerInfo);
     Assert.AreEqual(PlayerPosition.SecondPlayer, roundResult.GameClosedBy);
 }
コード例 #2
0
 public void GameClosedByShouldReturnNoOnePlayerWhenNoneOfThePlayersIsGameCloser()
 {
     var firstRoundPlayerInfo = new RoundPlayerInfo(new Mock<IPlayer>().Object);
     var secondRoundPlayerInfo = new RoundPlayerInfo(new Mock<IPlayer>().Object);
     var roundResult = new RoundResult(firstRoundPlayerInfo, secondRoundPlayerInfo);
     Assert.AreEqual(PlayerPosition.NoOne, roundResult.GameClosedBy);
 }
コード例 #3
0
 public void ConstructorShouldSetProperties()
 {
     var firstRoundPlayerInfo = new RoundPlayerInfo(new Mock<IPlayer>().Object);
     var secondRoundPlayerInfo = new RoundPlayerInfo(new Mock<IPlayer>().Object);
     var roundResult = new RoundResult(firstRoundPlayerInfo, secondRoundPlayerInfo);
     Assert.AreEqual(firstRoundPlayerInfo, roundResult.FirstPlayer);
     Assert.AreEqual(secondRoundPlayerInfo, roundResult.SecondPlayer);
 }
コード例 #4
0
        public void NoTricksPlayerShouldReturnSecondPlayerWhenOnlyFirstPlayerHasTricks()
        {
            var firstRoundPlayerInfo = new RoundPlayerInfo(new Mock<IPlayer>().Object);
            var secondRoundPlayerInfo = new RoundPlayerInfo(new Mock<IPlayer>().Object);
            var roundResult = new RoundResult(firstRoundPlayerInfo, secondRoundPlayerInfo);

            firstRoundPlayerInfo.TrickCards.Add(new Card(CardSuit.Club, CardType.Ace));

            Assert.AreEqual(PlayerPosition.SecondPlayer, roundResult.NoTricksPlayer);
        }
コード例 #5
0
        private void UpdatePoints(RoundResult roundResult)
        {
            IRoundWinnerPointsLogic roundWinnerPointsPointsLogic = new RoundWinnerPointsPointsLogic();
            var roundWinnerPoints = roundWinnerPointsPointsLogic.GetWinnerPoints(
                roundResult.FirstPlayer.RoundPoints,
                roundResult.SecondPlayer.RoundPoints,
                roundResult.GameClosedBy,
                roundResult.NoTricksPlayer,
                this.gameRules);

            switch (roundWinnerPoints.Winner)
            {
            case PlayerPosition.FirstPlayer:
                this.FirstPlayerTotalPoints += roundWinnerPoints.Points;
                this.firstToPlay             = PlayerPosition.SecondPlayer;
                break;

            case PlayerPosition.SecondPlayer:
                this.SecondPlayerTotalPoints += roundWinnerPoints.Points;
                this.firstToPlay              = PlayerPosition.FirstPlayer;
                break;
            }
        }
コード例 #6
0
        private void UpdatePoints(RoundResult roundResult)
        {
            IRoundWinnerPointsLogic roundWinnerPointsPointsLogic = new RoundWinnerPointsPointsLogic();
            var roundWinnerPoints = roundWinnerPointsPointsLogic.GetWinnerPoints(
                roundResult.FirstPlayer.RoundPoints,
                roundResult.SecondPlayer.RoundPoints,
                roundResult.GameClosedBy,
                roundResult.NoTricksPlayer,
                this.gameRules);

            switch (roundWinnerPoints.Winner)
            {
                case PlayerPosition.FirstPlayer:
                    this.FirstPlayerTotalPoints += roundWinnerPoints.Points;
                    this.firstToPlay = PlayerPosition.SecondPlayer;
                    break;
                case PlayerPosition.SecondPlayer:
                    this.SecondPlayerTotalPoints += roundWinnerPoints.Points;
                    this.firstToPlay = PlayerPosition.FirstPlayer;
                    break;
            }
        }