unituBowlingTests;interfaceusesDUnitX.TestFramework,uBowling;type[TestFixture]BowlingTests=class(TObject)privateclassfunctionRollMany(pins:arrayofinteger;game:IBowlingGame):IBowlingGame;static;public[Test]// [Ignore('Comment the "[Ignore]" statement to run the test')]procedureShould_be_able_to_score_a_game_with_all_zeros;[Test][Ignore]procedureShould_be_able_to_score_a_game_with_no_strikes_or_spares;[Test][Ignore]procedureA_spare_followed_by_zeros_is_worth_ten_points;[Test][Ignore]procedurePoints_scored_in_the_roll_after_a_spare_are_counted_twice;[Test][Ignore]procedureConsecutive_spares_each_get_a_one_roll_bonus;[Test][Ignore]procedureA_spare_in_the_last_frame_gets_a_one_roll_bonus_that_is_counted_once;[Test][Ignore]procedureA_strike_earns_ten_points_in_frame_with_a_single_roll;[Test][Ignore]procedurePoints_scored_in_the_two_rolls_after_a_strike_are_counted_twice_as_a_bonus;[Test][Ignore]procedureConsecutive_strikes_each_get_the_two_roll_bonus;[Test][Ignore]procedureA_strike_in_the_last_frame_gets_a_two_roll_bonus_that_is_counted_once;[Test][Ignore]procedureRolling_a_spare_with_the_two_roll_bonus_does_not_get_a_bonus_roll;[Test][Ignore]procedureStrikes_with_the_two_roll_bonus_do_not_get_bonus_rolls;[Test][Ignore]procedureA_strike_with_the_one_roll_bonus_after_a_spare_in_the_last_frame_does_not_get_a_bonus;[Test][Ignore]procedureAll_strikes_is_a_perfect_game;[Test][Ignore]procedureRolls_cannot_score_negative_points;[Test][Ignore]procedureA_roll_cannot_score_more_than_10_points;[Test][Ignore]procedureTwo_rolls_in_a_frame_cannot_score_more_than_10_points;[Test][Ignore]procedureTwo_bonus_rolls_after_a_strike_in_the_last_frame_cannot_score_more_than_10_points;[Test][Ignore]procedureAn_unstarted_game_cannot_be_scored;[Test][Ignore]procedureAn_incomplete_game_cannot_be_scored;[Test][Ignore]procedureA_game_with_more_than_ten_frames_cannot_be_scored;[Test][Ignore]procedureBonus_rolls_for_a_strike_in_the_last_frame_must_be_rolled_before_score_can_be_calculated;[Test][Ignore]procedureBoth_bonus_rolls_for_a_strike_in_the_last_frame_must_be_rolled_before_score_can_be_calculated;[Test][Ignore]procedureBonus_roll_for_a_spare_in_the_last_frame_must_be_rolled_before_score_can_be_calculated;end;implementationusesSystem.SysUtils;procedureBowlingTests.Should_be_able_to_score_a_game_with_all_zeros;vargame:IBowlingGame;begingame:=RollMany([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],NewBowlingGame);assert.AreEqual(0,game.Score);end;procedureBowlingTests.Should_be_able_to_score_a_game_with_no_strikes_or_spares;vargame:IBowlingGame;begingame:=RollMany([3,6,3,6,3,6,3,6,3,6,3,6,3,6,3,6,3,6,3,6],NewBowlingGame);assert.AreEqual(90,game.Score);end;procedureBowlingTests.A_spare_followed_by_zeros_is_worth_ten_points;vargame:IBowlingGame;begingame:=RollMany([6,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],NewBowlingGame);assert.AreEqual(10,game.Score);end;procedureBowlingTests.Points_scored_in_the_roll_after_a_spare_are_counted_twice;vargame:IBowlingGame;begingame:=RollMany([6,4,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],NewBowlingGame);assert.AreEqual(16,game.Score);end;procedureBowlingTests.Consecutive_spares_each_get_a_one_roll_bonus;vargame:IBowlingGame;begingame:=RollMany([5,5,3,7,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],NewBowlingGame);assert.AreEqual(31,game.Score);end;procedureBowlingTests.A_spare_in_the_last_frame_gets_a_one_roll_bonus_that_is_counted_once;vargame:IBowlingGame;begingame:=RollMany([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,3,7],NewBowlingGame);assert.AreEqual(17,game.Score);end;procedureBowlingTests.A_strike_earns_ten_points_in_frame_with_a_single_roll;vargame:IBowlingGame;begingame:=RollMany([10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],NewBowlingGame);assert.AreEqual(10,game.Score);end;procedureBowlingTests.Points_scored_in_the_two_rolls_after_a_strike_are_counted_twice_as_a_bonus;vargame:IBowlingGame;begingame:=RollMany([10,5,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],NewBowlingGame);assert.AreEqual(26,game.Score);end;procedureBowlingTests.Consecutive_strikes_each_get_the_two_roll_bonus;vargame:IBowlingGame;begingame:=RollMany([10,10,10,5,3,0,0,0,0,0,0,0,0,0,0,0,0],NewBowlingGame);assert.AreEqual(81,game.Score);end;procedureBowlingTests.A_strike_in_the_last_frame_gets_a_two_roll_bonus_that_is_counted_once;vargame:IBowlingGame;begingame:=RollMany([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,7,1],NewBowlingGame);assert.AreEqual(18,game.Score);end;procedureBowlingTests.Rolling_a_spare_with_the_two_roll_bonus_does_not_get_a_bonus_roll;vargame:IBowlingGame;begingame:=RollMany([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,7,3],NewBowlingGame);assert.AreEqual(20,game.Score);end;procedureBowlingTests.Strikes_with_the_two_roll_bonus_do_not_get_bonus_rolls;vargame:IBowlingGame;begingame:=RollMany([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,10,10],NewBowlingGame);assert.AreEqual(30,game.Score);end;procedureBowlingTests.A_strike_with_the_one_roll_bonus_after_a_spare_in_the_last_frame_does_not_get_a_bonus;vargame:IBowlingGame;begingame:=RollMany([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,3,10],NewBowlingGame);assert.AreEqual(20,game.Score);end;procedureBowlingTests.All_strikes_is_a_perfect_game;vargame:IBowlingGame;begingame:=RollMany([10,10,10,10,10,10,10,10,10,10,10,10],NewBowlingGame);assert.AreEqual(300,game.Score);end;procedureBowlingTests.Rolls_cannot_score_negative_points;vargame:IBowlingGame;begingame:=RollMany([-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],NewBowlingGame);Assert.AreEqual(-1,game.Score);end;procedureBowlingTests.A_roll_cannot_score_more_than_10_points;vargame:IBowlingGame;begingame:=RollMany([11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],NewBowlingGame);Assert.AreEqual(-1,game.Score);end;procedureBowlingTests.Two_rolls_in_a_frame_cannot_score_more_than_10_points;vargame:IBowlingGame;begingame:=RollMany([5,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],NewBowlingGame);Assert.AreEqual(-1,game.Score);end;procedureBowlingTests.Two_bonus_rolls_after_a_strike_in_the_last_frame_cannot_score_more_than_10_points;vargame:IBowlingGame;begingame:=RollMany([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,5,6],NewBowlingGame);Assert.AreEqual(-1,game.Score);end;procedureBowlingTests.An_unstarted_game_cannot_be_scored;vargame:IBowlingGame;begingame:=RollMany([],NewBowlingGame);Assert.AreEqual(-1,game.Score);end;procedureBowlingTests.An_incomplete_game_cannot_be_scored;vargame:IBowlingGame;begingame:=RollMany([0,0],NewBowlingGame);Assert.AreEqual(-1,game.Score);end;procedureBowlingTests.A_game_with_more_than_ten_frames_cannot_be_scored;vargame:IBowlingGame;begingame:=RollMany([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],NewBowlingGame);Assert.AreEqual(-1,game.Score);end;procedureBowlingTests.Bonus_rolls_for_a_strike_in_the_last_frame_must_be_rolled_before_score_can_be_calculated;vargame:IBowlingGame;begingame:=RollMany([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10],NewBowlingGame);Assert.AreEqual(-1,game.Score);end;procedureBowlingTests.Both_bonus_rolls_for_a_strike_in_the_last_frame_must_be_rolled_before_score_can_be_calculated;vargame:IBowlingGame;begingame:=RollMany([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,10],NewBowlingGame);Assert.AreEqual(-1,game.Score);end;procedureBowlingTests.Bonus_roll_for_a_spare_in_the_last_frame_must_be_rolled_before_score_can_be_calculated;vargame:IBowlingGame;begingame:=RollMany([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,3],NewBowlingGame);Assert.AreEqual(-1,game.Score);end;classfunctionBowlingTests.RollMany(pins:arrayofinteger;game:IBowlingGame):IBowlingGame;varcount:integer;beginforcountinpinsdogame.Roll(count);result:=game;end;initializationTDUnitX.RegisterTestFixture(BowlingTests);end.