public void EndMatch1() { 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.StartOver(ap4); cricketMatch.AddBall(BallType.Legitimate, RunsType.Run, BoundaryType.None, 1, ap4, p1, false, null, null, DisMissalType.None); cricketMatch.AddBall(BallType.Legitimate, RunsType.Run, BoundaryType.None, 0, ap4, p1, false, null, null, DisMissalType.None); cricketMatch.AddBall(BallType.Legitimate, RunsType.Run, BoundaryType.None, 0, ap4, p1, false, null, null, DisMissalType.None); cricketMatch.EndOver(); cricketMatch.EndInnings(); cricketMatch.StartInnings(); cricketMatch.SetStrikerNonStrikerBatsmen(ap3, true); cricketMatch.SetStrikerNonStrikerBatsmen(ap4, false); cricketMatch.StartOver(p1); cricketMatch.AddBall(BallType.Legitimate, RunsType.Run, BoundaryType.None, 1, p1, ap4, false, null, null, DisMissalType.None); cricketMatch.AddBall(BallType.Legitimate, RunsType.Run, BoundaryType.None, 0, p1, ap4, false, null, null, DisMissalType.None); cricketMatch.AddBall(BallType.Legitimate, RunsType.Run, BoundaryType.None, 0, p1, ap4, false, null, null, DisMissalType.None); cricketMatch.EndOver(); cricketMatch.EndInnings(); // cricketMatch.EnforcedFollowOn = true; cricketMatch.StartInnings(); cricketMatch.EndInnings(); cricketMatch.StartInnings(); cricketMatch.EndInnings(); cricketMatch.EndMatch(); var jMatch = new { CricketMatch = cricketMatch }; var sd = JsonConvert.SerializeObject(cricketMatch); var d = JsonConvert.DeserializeObject <CricketMatch>(sd); Assert.IsTrue(cricketMatch != null); }
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); }