Пример #1
0
        public void InningsBreak()
        {
            var match = Matches.GetMatches().First(x => x.MatchId == 12345);

            match.NumberOfOvers = 40;
            var cricketMatch = new CricketMatch(match);

            cricketMatch.Teams.FirstOrDefault().IsHomeTeam = true;
            cricketMatch.CoinToss(10990, TossDecisionType.Batting);
            var homePlayers = Players.GetPlayers().Where(x => x.PlayerRole.TeamId == 10990).Take(4)
                              .Select(x => new CricketPlayer(x)).ToList();
            var awayPlayers = Players.GetPlayers().Where(x => x.PlayerRole.TeamId != 10990).Take(4)
                              .Select(x => new CricketPlayer(x)).ToList();

            cricketMatch.Teams.First(x => x.IsHomeTeam).Players  = homePlayers;
            cricketMatch.Teams.First(x => !x.IsHomeTeam).Players = awayPlayers;
            cricketMatch.StartInnings();
            var p1  = homePlayers.FirstOrDefault();
            var p2  = homePlayers.LastOrDefault();
            var ap3 = awayPlayers.FirstOrDefault();
            var ap4 = awayPlayers.LastOrDefault();

            cricketMatch.SetStrikerNonStrikerBatsmen(p1, true);
            cricketMatch.SetStrikerNonStrikerBatsmen(p2, false);
            cricketMatch.StartOver(ap3);
            cricketMatch.AddBall(BallType.Legitimate, RunsType.Run, BoundaryType.Four, 4, ap3, p1, false, null, null, DisMissalType.None);
            cricketMatch.AddBall(BallType.Legitimate, RunsType.Run, BoundaryType.None, 0, ap3, p1, true, p1, ap4, DisMissalType.Caught);
            cricketMatch.EndOver();
            cricketMatch.EndInnings();
            cricketMatch.SetMatchStatus(MatchStatus.Break);
            var sd = JsonConvert.SerializeObject(cricketMatch);
            var d  = JsonConvert.DeserializeObject <CricketMatch>(sd);

            Assert.IsTrue(cricketMatch != null);
        }
Пример #2
0
        public void StartOver()
        {
            var match = Matches.GetMatches().First(x => x.MatchId == 12345);

            match.NumberOfOvers = 40;
            var cricketMatch = new CricketMatch(match);

            cricketMatch.Teams.FirstOrDefault().IsHomeTeam = true;
            cricketMatch.CoinToss(10990, TossDecisionType.Batting);
            var homePlayers = Players.GetPlayers().Where(x => x.PlayerRole.TeamId == 10990).Take(4)
                              .Select(x => new CricketPlayer(x)).ToList();
            var awayPlayers = Players.GetPlayers().Where(x => x.PlayerRole.TeamId != 10990).Take(4)
                              .Select(x => new CricketPlayer(x)).ToList();

            cricketMatch.Teams.First(x => x.IsHomeTeam).Players  = homePlayers;
            cricketMatch.Teams.First(x => !x.IsHomeTeam).Players = awayPlayers;
            cricketMatch.StartInnings();
            var p1  = homePlayers.FirstOrDefault();
            var p2  = homePlayers.LastOrDefault();
            var ap3 = awayPlayers.FirstOrDefault();

            cricketMatch.SetStrikerNonStrikerBatsmen(p1, true);
            cricketMatch.SetStrikerNonStrikerBatsmen(p2, false);
            cricketMatch.StartOver(ap3);
            var sd = JsonConvert.SerializeObject(cricketMatch);
            var d  = JsonConvert.DeserializeObject <CricketMatch>(sd);

            Assert.IsTrue(cricketMatch != null);
        }