Esempio n. 1
0
        public async Task TestAddPointsToPlayers1()
        {
            // Arrange
            SingleMatch match = new SingleMatch()
            {
                MatchID           = 8,
                NamePlayerA       = "Player A",
                NamePlayerB       = "Player B",
                ScorePlayerA      = 3,
                ScorePlayerB      = 3,
                AdvantageToPlayer = ESidesInGame.PlayerA,
                WinnerInMatch     = ESidesInGame.None,
                Set1 = new SingleSetInMatch()
                {
                    ScorePlayerA = 0,
                    ScorePlayerB = 0,
                    WinnerInSet  = ESidesInGame.None
                },
                Set2 = new SingleSetInMatch()
                {
                    ScorePlayerA = 0,
                    ScorePlayerB = 0,
                    WinnerInSet  = ESidesInGame.None
                },
                Set3 = new SingleSetInMatch()
                {
                    ScorePlayerA = 0,
                    ScorePlayerB = 0,
                    WinnerInSet  = ESidesInGame.None
                }
            };
            var gameData = Newtonsoft.Json.JsonConvert.SerializeObject(match);

            // Act
            string matchStr = await ScoreCalculations.CreateNemGame();

            SingleMatch matchObj      = Newtonsoft.Json.JsonConvert.DeserializeObject <SingleMatch>(matchStr);
            int         currentGameId = matchObj.MatchID;

            for (int i = 0; i < 3; i++)
            {
                matchStr = await ScoreCalculations.PlayerWinningPoint(currentGameId, ESidesInGame.PlayerA);
            }
            for (int i = 0; i < 3; i++)
            {
                matchStr = await ScoreCalculations.PlayerWinningPoint(currentGameId, ESidesInGame.PlayerB);
            }
            matchStr = await ScoreCalculations.PlayerWinningPoint(currentGameId, ESidesInGame.PlayerA);

            matchObj         = Newtonsoft.Json.JsonConvert.DeserializeObject <SingleMatch>(matchStr);
            matchObj.MatchID = 8;
            var actual = Newtonsoft.Json.JsonConvert.SerializeObject(matchObj);

            // Assert
            Assert.AreEqual(gameData, actual);
        }
Esempio n. 2
0
 public async Task <string> IncreaseOnePoint(int gameId, ESidesInGame playerWins)
 {
     return(await ScoreCalculations.PlayerWinningPoint(gameId, playerWins));
 }