Beispiel #1
0
        public void AllStrikesButLastSpare_MatchExpectations(int frameNumber, int expectedPoints)
        {
            var game = Enumerable.Range(1, 9).Select(n => new FramePoints(10)).ToList();

            game.Add(new FramePoints(9, 1, 1));
            var calculator = new PointsCalculator(game);

            var points = calculator.GetPointsUpTo(frameNumber);

            points.Should().Be(expectedPoints);
        }
Beispiel #2
0
        public void SpareWithNoContinuation_OnlyActualPoints()
        {
            var game = new List <FramePoints>
            {
                new FramePoints(1, 4),
                new FramePoints(5, 5),
            };
            var calculator = new PointsCalculator(game);

            var points = calculator.GetPointsUpTo(2);

            points.Should().Be(15);
        }
Beispiel #3
0
        public void StrikeAndAdditionalRuns_SumAll()
        {
            var game = new List <FramePoints>
            {
                new FramePoints(1, 4),
                new FramePoints(10, 0, 2, 1),
            };
            var calculator = new PointsCalculator(game);

            var points = calculator.GetPointsUpTo(2);

            points.Should().Be(18);
        }
Beispiel #4
0
        public void SpareAndAdditionalRuns_SumOnly3rdRun()
        {
            var game = new List <FramePoints>
            {
                new FramePoints(1, 4),
                new FramePoints(5, 5, 2, 1),
            };
            var calculator = new PointsCalculator(game);

            var points = calculator.GetPointsUpTo(2);

            points.Should().Be(17);
        }
Beispiel #5
0
        public void SpareAndNextFrame1_FullPoints()
        {
            var game = new List <FramePoints>
            {
                new FramePoints(3, 7),
                new FramePoints(3, 2),
            };
            var calculator = new PointsCalculator(game);

            var points = calculator.GetPointsUpTo(2);

            points.Should().Be(18);
        }
Beispiel #6
0
        public void StrikeAndNextFrame_FullPoints()
        {
            var game = new List <FramePoints>
            {
                new FramePoints(1, 4),
                new FramePoints(10, 0),
                new FramePoints(4, 2),
            };
            var calculator = new PointsCalculator(game);

            var points = calculator.GetPointsUpTo(2);

            points.Should().Be(21);
        }
Beispiel #7
0
        public void InvalidFrameNumber_ThrowsOutOfRange(int frameNumber)
        {
            var game = new List <FramePoints>
            {
                new FramePoints(1, 4),
                new FramePoints(4, 5),
                new FramePoints(6, 4),
                new FramePoints(5, 5),
                new FramePoints(10, 0),
                new FramePoints(0, 1),
                new FramePoints(7, 3),
                new FramePoints(6, 4),
                new FramePoints(10, 0),
                new FramePoints(2, 8, 6),
            };
            var calculator = new PointsCalculator(game);

            Action getPoints = () => calculator.GetPointsUpTo(frameNumber);

            getPoints.Should().Throw <ArgumentOutOfRangeException>($"frame number must be from 1 to 10 but is {frameNumber}");
        }
Beispiel #8
0
        public void AFrame_MatchExpectations(int frameNumber, int expectedPoints)
        {
            var game = new List <FramePoints>
            {
                new FramePoints(1, 4),
                new FramePoints(4, 5),
                new FramePoints(6, 4),
                new FramePoints(5, 5),
                new FramePoints(10, 0),
                new FramePoints(0, 1),
                new FramePoints(7, 3),
                new FramePoints(6, 4),
                new FramePoints(10, 0),
                new FramePoints(2, 8, 6),
            };
            var calculator = new PointsCalculator(game);

            var points = calculator.GetPointsUpTo(frameNumber);

            points.Should().Be(expectedPoints);
        }