public IActionResult Play() { // Play Game IRandomNumberGenerator randomNumGen = new GetRandomNumber(); Scorekeeper keeper = new Scorekeeper(ONE_DAY); Game game = new Game(randomNumGen); string[] team1 = new string[] { "Ian Botham", "Mike Gatting", "David Gower", "Joe Root", "Jos Buttler", "Ben Stokes", "Johnny Bairstow", "Stuart Broad", "Graham Swann", "Jofra Archer", "Jimmy Anderson" }; string[] team2 = new string[] { "Michael Vaughan", "Alistair Cook", "Viv Richards", "Freddie Flintoff", "Geoff Miller", "Nasser Hussain", "Alex Stewart", "Darren Gough", "Bob Willis", "Phil Tuffnell", "Mike Hendrick" }; keeper.ChangeBowler("Malcolm Marshall"); keeper.SubmitTeam(0, team1); keeper.SubmitTeam(1, team2); Umpire umpey = new Umpire(game, keeper); umpey.playInnings(); keeper.StartInnings(1); keeper.ChangeBowler("Ian Botham"); umpey.playInnings(); //// Map Scores to View Model PlayViewModel pvm = new PlayViewModel(); var(r1, w1, b1, e1) = keeper.GetInningsScore(0); var(r2, w2, b2, e2) = keeper.GetInningsScore(1); pvm.runs = new int[2] { r1, r2 }; pvm.wickets = new int[2] { w1, w2 }; pvm.overs = new int[2] { b1, b2 }; pvm.extras = new int[2] { e1, e2 }; pvm.team1 = team1; pvm.team2 = team2; pvm.scores1 = new int[11]; pvm.scores2 = new int[11]; for (int i = 0; i < 11; i++) { pvm.scores1[i] = keeper.GetBatsmanScore(0, team1[i]); pvm.scores2[i] = keeper.GetBatsmanScore(1, team2[i]); } return(View(pvm)); }
void test_batsmen_scores() { event_sequence(NO_RUNS, ONE_RUN, TWO_RUNS, BOWLED, ONE_RUN, NO_BALL, TWO_RUNS); _keeper.EndOfOver(); event_sequence(BOWLED, SIX_RUNS, NO_RUNS, LBW, FOUR_BYES, THREE_RUNS); _keeper.EndOfOver(); // Assert Scores assert_score(20, 3, 12, 0); Assert.Equal(3, _keeper.GetBatsmanScore(0, "Ian Botham")); Assert.Equal(2, _keeper.GetBatsmanScore(0, "David Gower")); Assert.Equal(1, _keeper.GetBatsmanScore(0, "Michael Vaughan")); Assert.Equal(6, _keeper.GetBatsmanScore(0, "Kevin Pietersen")); Assert.Equal(3, _keeper.GetBatsmanScore(0, "Freddie Flintoff")); }