Esempio n. 1
0
    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());
    }
Esempio n. 2
0
    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());
    }
Esempio n. 3
0
    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));
    }
Esempio n. 4
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));
    }
Esempio n. 5
0
        public void Can_score_one_player_ball_0()
        {
            var game = new BowlingGame(1);

            game.SetPlayerName(1, "Mal");
            game.StartGame();
            ObjectApprover.VerifyWithJson(game);
        }
Esempio n. 6
0
    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());
    }
Esempio n. 7
0
    public void Perfect_game()
    {
        var game = new BowlingGame();

        RollMany(10, 12, game);

        Assert.That(game.Score(), Is.EqualTo(300));
    }
Esempio n. 8
0
        public void ScoreOfStrikeDeferred_OneRoll_Strike()
        {
            var game = new BowlingGame();

            game.Roll(pinsKnockedDown: 10);

            Assert.Equal(0, game.Score);
        }
Esempio n. 9
0
    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));
    }
Esempio n. 10
0
    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));
    }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
    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));
    }
Esempio n. 13
0
    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));
    }
Esempio n. 14
0
        public GameBuilder()
        {
            _random = new Random();

            _game = new BowlingGame(new FrameKeeper(), new ScoreCalculator());

            _frames = new List<int>();
        }
Esempio n. 15
0
        public void ScoreIsZero_OneRoll_NoPinsKnockedDown()
        {
            var game = new BowlingGame();

            game.Roll(pinsKnockedDown: 0);

            Assert.Equal(0, game.Score);
        }
Esempio n. 16
0
    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));
    }
Esempio n. 17
0
        public void Can_add_players()
        {
            var game = new BowlingGame(1);

            game.SetPlayerName(1, "Mal");

            ObjectApprover.VerifyWithJson(game.ListPlayerNames());
        }
Esempio n. 18
0
        public void ScoreIsPinsKnockedDown_OneRoll_SomePinsKnockedDown()
        {
            var game = new BowlingGame();

            game.Roll(pinsKnockedDown: 3);

            Assert.Equal(3, game.Score);
        }
Esempio n. 19
0
 protected override void context()
 {
     _game = new BowlingGame();
     for (int i = 0; i < 10; i++)
     {
         _game.Roll(1, 1);
     }
 }
Esempio n. 20
0
        public void ShouldReturnScoreEqualToPinsNumberGiven(int firstThrow, int secondThrow)
        {
            BowlingGame bowlingGame = new BowlingGame();

            bowlingGame.ThrowBowling(firstThrow, secondThrow);
            var result = bowlingGame.GetScore();

            result.Should().Be(firstThrow + secondThrow);
        }
Esempio n. 21
0
        public void Strike()
        {
            _subject = new BowlingGame();

            _subject.Roll(10);
            Enumerable.Repeat(1, 18).Select(pins => _subject.Roll(pins)).ToList();

            Assert.Equal(30, _subject.Score());
        }
Esempio n. 22
0
        public void ScoreOfStrikeIsDeferred_TwoRolls_FirstRollIsStrike()
        {
            var game = new BowlingGame();

            game.Roll(pinsKnockedDown: 10);
            game.Roll(pinsKnockedDown: 5);

            Assert.Equal(5, game.Score);
        }
Esempio n. 23
0
 protected override void context()
 {
     _game = new BowlingGame();
     for (int i = 0; i < 9; i++)
     {
         _game.RollStrike();
     }
     _game.RollLastFrame(10, 10, 10);
 }
Esempio n. 24
0
 protected override void context()
 {
     _game = new BowlingGame();
     _game.RollStrike();
     for (int i = 0; i < 9; i++)
     {
         _game.Roll(2, 2);
     }
 }
Esempio n. 25
0
 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);
 }
Esempio n. 26
0
        public void VerifySeveralRollsCreateSeveralFrames()
        {
            var bowlingGame = new BowlingGame();

            bowlingGame.Roll(1);
            bowlingGame.Roll(2);
            bowlingGame.Roll(3);
            Assert.AreEqual(2, bowlingGame.Round);
        }
Esempio n. 27
0
    private static BowlingGame RollMany(IEnumerable <int> rolls, BowlingGame game)
    {
        foreach (var pins in rolls)
        {
            game.Roll(pins);
        }

        return(game);
    }
Esempio n. 28
0
        public void ScoresSummedUp_TwoRolls()
        {
            var game = new BowlingGame();

            game.Roll(pinsKnockedDown: 3);
            game.Roll(pinsKnockedDown: 4);

            Assert.Equal(7, game.Score);
        }
Esempio n. 29
0
        public void RecordFirstRoll()
        {
            BowlingGame bowlingGame = new BowlingGame();

            bowlingGame.Roll(5);
            int score = bowlingGame.Score();

            Assert.AreEqual(5, score);
        }
Esempio n. 30
0
        public void ScoreOfSpareDeferred_TwoRolls_Spare()
        {
            var game = new BowlingGame();

            game.Roll(pinsKnockedDown: 3);
            game.Roll(pinsKnockedDown: 7);

            Assert.Equal(3, game.Score);
        }
Esempio n. 31
0
        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);
        }
Esempio n. 33
0
        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);
            }
        }
Esempio n. 34
0
 public void SetUp()
 {
     g = new BowlingGame();
 }
 public void TestInitialize()
 {
     game = new BowlingGame();
 }
Esempio n. 36
0
 public void TearDown()
 {
     game = null;
 }
Esempio n. 37
0
 public void Example()
 {
     int expected = 6 * 9;
     int actual = new BowlingGame().Answer;
     Assert.AreEqual(expected, actual);
 }
Esempio n. 38
0
 public void Setup()
 {
     bg = new BowlingGame();
 }
Esempio n. 39
0
 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();
 }
Esempio n. 42
0
 public void SetUp()
 {
     _game = new BowlingGame();
 }
Esempio n. 43
0
 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);
     }
 }   
Esempio n. 44
0
 public void WhenGetScoreOfNewGame_ShouldReturnZero()
 {
     var  game    = new BowlingGame();
     Assert.AreEqual(game.GetScoreOfFrame(1), 0);
 }
Esempio n. 45
0
 public void ShouldNotAllowThrow()
 {
     var game = new BowlingGame();
     game.Throw(3).Throw(8);
 }   
Esempio n. 46
0
 public BowlingGameTests()
 {
     _game = new BowlingGame();
 }