コード例 #1
0
ファイル: BowlingTest.cs プロジェクト: mercy-merry/exercism
    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());
    }
コード例 #2
0
ファイル: BowlingTest.cs プロジェクト: mercy-merry/exercism
    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());
    }
コード例 #3
0
ファイル: BowlingTest.cs プロジェクト: mercy-merry/exercism
    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));
    }
コード例 #4
0
ファイル: BowlingTest.cs プロジェクト: mercy-merry/exercism
    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));
    }
コード例 #5
0
ファイル: BowlingGameTests.cs プロジェクト: davidalpert/tmp
        public void Can_score_one_player_ball_0()
        {
            var game = new BowlingGame(1);

            game.SetPlayerName(1, "Mal");
            game.StartGame();
            ObjectApprover.VerifyWithJson(game);
        }
コード例 #6
0
ファイル: BowlingTest.cs プロジェクト: mercy-merry/exercism
    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());
    }
コード例 #7
0
    public void Perfect_game()
    {
        var game = new BowlingGame();

        RollMany(10, 12, game);

        Assert.That(game.Score(), Is.EqualTo(300));
    }
コード例 #8
0
        public void ScoreOfStrikeDeferred_OneRoll_Strike()
        {
            var game = new BowlingGame();

            game.Roll(pinsKnockedDown: 10);

            Assert.Equal(0, game.Score);
        }
コード例 #9
0
ファイル: BowlingTest.cs プロジェクト: mercy-merry/exercism
    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));
    }
コード例 #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));
    }
コード例 #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);
        }
コード例 #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));
    }
コード例 #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));
    }
コード例 #14
0
ファイル: GameBuilder.cs プロジェクト: amirci/bowling_game
        public GameBuilder()
        {
            _random = new Random();

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

            _frames = new List<int>();
        }
コード例 #15
0
        public void ScoreIsZero_OneRoll_NoPinsKnockedDown()
        {
            var game = new BowlingGame();

            game.Roll(pinsKnockedDown: 0);

            Assert.Equal(0, game.Score);
        }
コード例 #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));
    }
コード例 #17
0
ファイル: BowlingGameTests.cs プロジェクト: davidalpert/tmp
        public void Can_add_players()
        {
            var game = new BowlingGame(1);

            game.SetPlayerName(1, "Mal");

            ObjectApprover.VerifyWithJson(game.ListPlayerNames());
        }
コード例 #18
0
        public void ScoreIsPinsKnockedDown_OneRoll_SomePinsKnockedDown()
        {
            var game = new BowlingGame();

            game.Roll(pinsKnockedDown: 3);

            Assert.Equal(3, game.Score);
        }
コード例 #19
0
 protected override void context()
 {
     _game = new BowlingGame();
     for (int i = 0; i < 10; i++)
     {
         _game.Roll(1, 1);
     }
 }
コード例 #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);
        }
コード例 #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());
        }
コード例 #22
0
        public void ScoreOfStrikeIsDeferred_TwoRolls_FirstRollIsStrike()
        {
            var game = new BowlingGame();

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

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

            bowlingGame.Roll(1);
            bowlingGame.Roll(2);
            bowlingGame.Roll(3);
            Assert.AreEqual(2, bowlingGame.Round);
        }
コード例 #27
0
ファイル: BowlingTest.cs プロジェクト: aymannadeem/exercism
    private static BowlingGame RollMany(IEnumerable <int> rolls, BowlingGame game)
    {
        foreach (var pins in rolls)
        {
            game.Roll(pins);
        }

        return(game);
    }
コード例 #28
0
        public void ScoresSummedUp_TwoRolls()
        {
            var game = new BowlingGame();

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

            Assert.Equal(7, game.Score);
        }
コード例 #29
0
        public void RecordFirstRoll()
        {
            BowlingGame bowlingGame = new BowlingGame();

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

            Assert.AreEqual(5, score);
        }
コード例 #30
0
        public void ScoreOfSpareDeferred_TwoRolls_Spare()
        {
            var game = new BowlingGame();

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

            Assert.Equal(3, game.Score);
        }
コード例 #31
0
        public void SingleSpare()
        {
            BowlingGame g = new BowlingGame();

            rollSpare(g);
            g.roll(3);
            rollMany(g, 17, 0);
            Assert.AreEqual(16, g.score());
        }
コード例 #32
0
        public void ItShouldCalculateTotalScoreCorrectly(string scores, int expected)
        {
            // arrange
            var sut = new BowlingGame();

            // act
            int actual = sut.CalculateTotal(scores);

            actual.ShouldEqual(expected, "scores: " + scores);
        }
コード例 #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);
            }
        }
コード例 #34
0
 public void SetUp()
 {
     g = new BowlingGame();
 }
コード例 #35
0
 public void TestInitialize()
 {
     game = new BowlingGame();
 }
コード例 #36
0
ファイル: BowlingGameTest.cs プロジェクト: simongregory/katas
 public void TearDown()
 {
     game = null;
 }
コード例 #37
0
 public void Example()
 {
     int expected = 6 * 9;
     int actual = new BowlingGame().Answer;
     Assert.AreEqual(expected, actual);
 }
コード例 #38
0
ファイル: GameTests.cs プロジェクト: vermeeca/Katas
 public void Setup()
 {
     bg = new BowlingGame();
 }
コード例 #39
0
 public void SetUp()
 {
     _scorerFactory = MockRepository.GenerateMock<IScorerFactory>();
     _frameScorer = MockRepository.GenerateMock<IFrameScorer>();
     _testObject = new BowlingGame(_scorerFactory);
 }
コード例 #40
0
 public void ANewGame()
 {
     _game = new BowlingGame();
 }
 public void Given_a_new_bowling_game()
 {
     game = new BowlingGame();
 }
コード例 #42
0
 public void SetUp()
 {
     _game = new BowlingGame();
 }
コード例 #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);
     }
 }   
コード例 #44
0
 public void WhenGetScoreOfNewGame_ShouldReturnZero()
 {
     var  game    = new BowlingGame();
     Assert.AreEqual(game.GetScoreOfFrame(1), 0);
 }
コード例 #45
0
 public void ShouldNotAllowThrow()
 {
     var game = new BowlingGame();
     game.Throw(3).Throw(8);
 }   
コード例 #46
0
 public BowlingGameTests()
 {
     _game = new BowlingGame();
 }