コード例 #1
0
        public void A_Bowling_Game_Should_Have_Bonus_Balls_Indicator()
        {
            const string bowlingGameStats = "X|X|X|X|X|X|X|X|X|X";
            var          sut = new GameParser(new ScoreBoardValidator());

            Action act = () =>
            {
                sut.GenerateScoreBoard(bowlingGameStats);
            };

            act.Should().Throw <InvalidGameInputException>()
            .WithMessage($"Invalid game input {bowlingGameStats}");
        }
コード例 #2
0
        public void A_FRAME_In_A_Bowling_Game_Should_Not_Have_More_Than_Two_Input()
        {
            const string bowlingGameStats = "X|X|X|X|X|X|234|X|X|X||XX";
            var          sut = new GameParser(new ScoreBoardValidator());

            Action act = () =>
            {
                sut.GenerateScoreBoard(bowlingGameStats);
            };

            act.Should().Throw <InvalidGameInputException>()
            .WithMessage($"Invalid game input {bowlingGameStats}");
        }
コード例 #3
0
        public void Should_Not_Have_Sum_Of_Two_Bonus_Balls_Greater_Than_Ten()
        {
            const string bowlingGameStats = "X|X|X|X|X|X|X|X|X|5/||88";
            var          sut = new GameParser(new ScoreBoardValidator());

            Action act = () =>
            {
                sut.GenerateScoreBoard(bowlingGameStats);
            };

            act.Should().Throw <InvalidGameInputException>()
            .WithMessage($"Invalid game input {bowlingGameStats}");
        }
コード例 #4
0
        public void Should_Not_Have_No_Bonus_Balls_When_Frame_Ten_Is_Spare()
        {
            const string bowlingGameStats = "X|X|X|X|X|X|X|X|X|5/||";
            var          sut = new GameParser(new ScoreBoardValidator());

            Action act = () =>
            {
                sut.GenerateScoreBoard(bowlingGameStats);
            };

            act.Should().Throw <InvalidGameInputException>()
            .WithMessage($"Invalid game input {bowlingGameStats}");
        }
コード例 #5
0
        public void A_FRAME_In_A_Bowling_Game_Should_Not_Have_Strike_As_First_Input_Follow_By_Zero_Pins()
        {
            const string bowlingGameStats = "X|X|X|X|X|X|X-|X|X|X||XX";
            var          sut = new GameParser(new ScoreBoardValidator());

            Action act = () =>
            {
                sut.GenerateScoreBoard(bowlingGameStats);
            };

            act.Should().Throw <InvalidGameInputException>()
            .WithMessage($"Invalid game input {bowlingGameStats}");
        }
コード例 #6
0
        public void Should_Generate_ScoreBoard_With_All_Strike_Frames()
        {
            const string bowlingGameStats         = "x|x|X|X|x|x|x|x|x|x||xx";
            const int    minNumberOfThrowPerFrame = 1;
            var          sut = new GameParser(new ScoreBoardValidator());

            var result = sut.GenerateScoreBoard(bowlingGameStats);

            result.Length.Should().Be(InputIndex.NumberOfFramesInBowlingGame);
            foreach (var frame in result)
            {
                frame.NumberOfBonusAcquired.Should().Be(FrameBonus.Strike);
                frame.PinsDroppedOfAThrow.Count().Should().Be(minNumberOfThrowPerFrame);
                frame.PinsDroppedOfABonusBall.Count().Should().Be((int)FrameBonus.Strike);
            }
        }
コード例 #7
0
 public ScoreBoard(string gameInfo, GameParser gameParser)
 {
     _frames = gameParser.GenerateScoreBoard(gameInfo);
 }