public void An_incomplete_game_cannot_be_scored() { var sut = new BowlingGame(); var previousRolls = new [] { 0, 0 }; DoRoll(previousRolls, sut); Assert.Throws <ArgumentException>(() => sut.Score()); }
public void Bonus_roll_for_a_spare_in_the_last_frame_must_be_rolled_before_score_can_be_calculated() { var sut = new BowlingGame(); var previousRolls = new [] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3 }; DoRoll(previousRolls, sut); Assert.Throws <ArgumentException>(() => sut.Score()); }
public void Cannot_roll_if_game_already_has_ten_frames() { var sut = new BowlingGame(); var previousRolls = new [] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; DoRoll(previousRolls, sut); Assert.Throws <ArgumentException>(() => sut.Roll(0)); }
public void The_second_bonus_rolls_after_a_strike_in_the_last_frame_cannot_be_a_strike_if_the_first_one_is_not_a_strike() { var sut = new BowlingGame(); var previousRolls = new [] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 6 }; DoRoll(previousRolls, sut); Assert.Throws <ArgumentException>(() => sut.Roll(10)); }
public void Can_score_one_player_ball_0() { var game = new BowlingGame(1); game.SetPlayerName(1, "Mal"); game.StartGame(); ObjectApprover.VerifyWithJson(game); }
public void An_unstarted_game_cannot_be_scored() { var sut = new BowlingGame(); var previousRolls = new int[0]; DoRoll(previousRolls, sut); Assert.Throws <ArgumentException>(() => sut.Score()); }
public void Perfect_game() { var game = new BowlingGame(); RollMany(10, 12, game); Assert.That(game.Score(), Is.EqualTo(300)); }
public void ScoreOfStrikeDeferred_OneRoll_Strike() { var game = new BowlingGame(); game.Roll(pinsKnockedDown: 10); Assert.Equal(0, game.Score); }
public void Cannot_roll_after_bonus_rolls_for_strike() { var sut = new BowlingGame(); var previousRolls = new [] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 3, 2 }; DoRoll(previousRolls, sut); Assert.Throws <ArgumentException>(() => sut.Roll(2)); }
public void A_roll_cannot_score_more_than_10_points() { var sut = new BowlingGame(); var previousRolls = Array.Empty <int>(); DoRoll(previousRolls, sut); Assert.Throws <ArgumentException>(() => sut.Roll(11)); }
public void Legacy_Rolling_a_negative_number_is_invalid() { // Demonstrates a one way to avoid re-writing legacy assertions. Better to re-write. var bg = new BowlingGame(); bg.LegacyBowl(-1); Assert.AreEqual(-1, bg.Score); }
public void Bonus_roll_after_a_strike_in_the_last_frame_cannot_score_more_than_10_points() { var sut = new BowlingGame(); var previousRolls = new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10 }; DoRoll(previousRolls, sut); Assert.Throws <ArgumentException>(() => sut.Roll(11)); }
public void Two_rolls_in_a_frame_cannot_score_more_than_10_points() { var sut = new BowlingGame(); var previousRolls = new[] { 5 }; DoRoll(previousRolls, sut); Assert.Throws <ArgumentException>(() => sut.Roll(6)); }
public GameBuilder() { _random = new Random(); _game = new BowlingGame(new FrameKeeper(), new ScoreCalculator()); _frames = new List<int>(); }
public void ScoreIsZero_OneRoll_NoPinsKnockedDown() { var game = new BowlingGame(); game.Roll(pinsKnockedDown: 0); Assert.Equal(0, game.Score); }
public void Rolls_cannot_score_negative_points() { var sut = new BowlingGame(); var previousRolls = Array.Empty <int>(); DoRoll(previousRolls, sut); Assert.Throws <ArgumentException>(() => sut.Roll(-1)); }
public void Can_add_players() { var game = new BowlingGame(1); game.SetPlayerName(1, "Mal"); ObjectApprover.VerifyWithJson(game.ListPlayerNames()); }
public void ScoreIsPinsKnockedDown_OneRoll_SomePinsKnockedDown() { var game = new BowlingGame(); game.Roll(pinsKnockedDown: 3); Assert.Equal(3, game.Score); }
protected override void context() { _game = new BowlingGame(); for (int i = 0; i < 10; i++) { _game.Roll(1, 1); } }
public void ShouldReturnScoreEqualToPinsNumberGiven(int firstThrow, int secondThrow) { BowlingGame bowlingGame = new BowlingGame(); bowlingGame.ThrowBowling(firstThrow, secondThrow); var result = bowlingGame.GetScore(); result.Should().Be(firstThrow + secondThrow); }
public void Strike() { _subject = new BowlingGame(); _subject.Roll(10); Enumerable.Repeat(1, 18).Select(pins => _subject.Roll(pins)).ToList(); Assert.Equal(30, _subject.Score()); }
public void ScoreOfStrikeIsDeferred_TwoRolls_FirstRollIsStrike() { var game = new BowlingGame(); game.Roll(pinsKnockedDown: 10); game.Roll(pinsKnockedDown: 5); Assert.Equal(5, game.Score); }
protected override void context() { _game = new BowlingGame(); for (int i = 0; i < 9; i++) { _game.RollStrike(); } _game.RollLastFrame(10, 10, 10); }
protected override void context() { _game = new BowlingGame(); _game.RollStrike(); for (int i = 0; i < 9; i++) { _game.Roll(2, 2); } }
public void Rolling_a_Strike_followed_by_3_followed_by_5_scores_26() { _myGame = GetNewGame(); RollStrike(); _myGame.Roll(3); _myGame.Roll(5); RollMany(0, 16); _myGame.Score().Should().Be(26); }
public void VerifySeveralRollsCreateSeveralFrames() { var bowlingGame = new BowlingGame(); bowlingGame.Roll(1); bowlingGame.Roll(2); bowlingGame.Roll(3); Assert.AreEqual(2, bowlingGame.Round); }
private static BowlingGame RollMany(IEnumerable <int> rolls, BowlingGame game) { foreach (var pins in rolls) { game.Roll(pins); } return(game); }
public void ScoresSummedUp_TwoRolls() { var game = new BowlingGame(); game.Roll(pinsKnockedDown: 3); game.Roll(pinsKnockedDown: 4); Assert.Equal(7, game.Score); }
public void RecordFirstRoll() { BowlingGame bowlingGame = new BowlingGame(); bowlingGame.Roll(5); int score = bowlingGame.Score(); Assert.AreEqual(5, score); }
public void ScoreOfSpareDeferred_TwoRolls_Spare() { var game = new BowlingGame(); game.Roll(pinsKnockedDown: 3); game.Roll(pinsKnockedDown: 7); Assert.Equal(3, game.Score); }
public void SingleSpare() { BowlingGame g = new BowlingGame(); rollSpare(g); g.roll(3); rollMany(g, 17, 0); Assert.AreEqual(16, g.score()); }
public void ItShouldCalculateTotalScoreCorrectly(string scores, int expected) { // arrange var sut = new BowlingGame(); // act int actual = sut.CalculateTotal(scores); actual.ShouldEqual(expected, "scores: " + scores); }
public void ShouldScore300WhenThrowAllSplitsInTenFrames() { var game = new BowlingGame().Throw(4).Throw(4) .Throw(4).Throw(4) .Throw(4).Throw(4) .Throw(4).Throw(4) .Throw(4).Throw(4) .Throw(4).Throw(4) .Throw(4).Throw(4) .Throw(4).Throw(4) .Throw(4).Throw(4) .Throw(4).Throw(4); for (int i = 1; i < 11; i++) { Assert.AreEqual(game.GetScoreOfFrame(i), i * 8); } }
public void SetUp() { g = new BowlingGame(); }
public void TestInitialize() { game = new BowlingGame(); }
public void TearDown() { game = null; }
public void Example() { int expected = 6 * 9; int actual = new BowlingGame().Answer; Assert.AreEqual(expected, actual); }
public void Setup() { bg = new BowlingGame(); }
public void SetUp() { _scorerFactory = MockRepository.GenerateMock<IScorerFactory>(); _frameScorer = MockRepository.GenerateMock<IFrameScorer>(); _testObject = new BowlingGame(_scorerFactory); }
public void ANewGame() { _game = new BowlingGame(); }
public void Given_a_new_bowling_game() { game = new BowlingGame(); }
public void SetUp() { _game = new BowlingGame(); }
public void ShouldReturnCorrectFramePlaying() { { var game = new BowlingGame(); Assert.AreEqual(game.Throw(10).Throw(10).FramesPlaying, 3); } { var game = new BowlingGame(); Assert.AreEqual(game.Throw(1).Throw(1).FramesPlaying, 2); } }
public void WhenGetScoreOfNewGame_ShouldReturnZero() { var game = new BowlingGame(); Assert.AreEqual(game.GetScoreOfFrame(1), 0); }
public void ShouldNotAllowThrow() { var game = new BowlingGame(); game.Throw(3).Throw(8); }
public BowlingGameTests() { _game = new BowlingGame(); }