Esempio n. 1
0
 public void CanRecognizeValidBowlingLineString()
 {
     foreach (var g in games)
     {
         var b = new BowlingLine(g);
         Assert.AreEqual(10, b.Frames.Count);
     }
 }
Esempio n. 2
0
        public void Should_ThrowIfThereAreNoPlayers()
        {

            //arrange
            InstantiateUnderTest();

            var bowlingLine = new BowlingLine(new List<BowlingLineScore>());

            //act
            _underTest.CalculateScores(bowlingLine);
        }
Esempio n. 3
0
        public void Should_ThrowIfTooManyFramesRecorded(string score)
        {
            //arrange
            InstantiateUnderTest();
            var playerScore = new BowlingLineScore("test", score);

            //pass 12 frame scores
            _scoreParser.Setup(p => p.ParseScores(It.IsAny<string>()))
                .Returns(TestHelper.GetNumberOfParsedScores(12));

            _bowlingFrameBuilder
                .Setup(b => b.BuildScores(It.IsAny<IEnumerable<Tuple<int, int>>>()))
                .Returns(TestHelper.GetNumberOfFrames(12));
            
            var bowlingLine = new BowlingLine(new List<BowlingLineScore>{playerScore});

            //act
            _underTest.CalculateScores(bowlingLine);
        }
Esempio n. 4
0
        public void Should_ParseScores()
        {
            //arrange
            InstantiateUnderTest();
            var playerScore = new BowlingLineScore("test", TestHelper.AllStrikes);

            _scoreParser.Setup(p => p.ParseScores(It.IsAny<string>()))
               .Returns(TestHelper.GetNumberOfParsedScores(10));


            _bowlingFrameBuilder
                .Setup(b => b.BuildScores(It.IsAny<IEnumerable<Tuple<int, int>>>()))
                .Returns(TestHelper.GetRandomFrameScores);
            
            var bowlingLine = new BowlingLine(new List<BowlingLineScore>{playerScore});

            //act
            _underTest.CalculateScores(bowlingLine);

            //assert
            _scoreParser
                .Verify(p => p.ParseScores(It.IsAny<string>()), Times.Once);
        }
Esempio n. 5
0
        public void ShouldCallScoreCalculator()
        {
            //arrange
            InstantiateUnderTest();
            var playerScore = new BowlingLineScore("test", TestHelper.AllStrikes);

            var scores =TestHelper.GetParsedScoresForAllStrikes();

            _scoreParser.Setup(p => p.ParseScores(It.IsAny<string>()))
               .Returns(scores);

            _bowlingFrameBuilder.Setup(fb => fb.BuildScores(It.IsAny<IEnumerable<Tuple<int, int>>>()))
                .Returns(TestHelper.GetAllFramesAsStrikes());
            

            var bowlingLine = new BowlingLine(new List<BowlingLineScore> { playerScore });

            //act
            _underTest.CalculateScores(bowlingLine);

            //assert
            _scoreCalculator
                .Verify(calc=>calc.CalculateTotalScore(It.IsAny<List<IFrame>>()),Times.Once);

        }
Esempio n. 6
0
        public void FullLine(uint[] rolls, uint?expectedScore)
        {
            var score = BowlingLine.SubmitRolls(rolls);

            Assert.AreEqual(expectedScore, score);
        }
Esempio n. 7
0
        public void RollsAfterDoubleStrike(uint roll1, uint roll2, uint?expectedScore)
        {
            var score = BowlingLine.SubmitRolls(new uint[] { 10u, 10u, roll1, roll2 });

            Assert.AreEqual(expectedScore, score);
        }
Esempio n. 8
0
        public void RollsAfterSpare(uint roll1, uint roll2, uint?expectedScore)
        {
            var score = BowlingLine.SubmitRolls(new uint[] { 5u, 5u, roll1, roll2 });

            Assert.AreEqual(expectedScore, score);
        }
Esempio n. 9
0
        public void SingleFrameStrike()
        {
            var score = BowlingLine.SubmitRolls(new uint[] { 10u });

            Assert.AreEqual(null, score);
        }
Esempio n. 10
0
        public void SingleFrame(uint roll1, uint roll2, uint?expectedScore)
        {
            var score = BowlingLine.SubmitRolls(new uint[] { roll1, roll2 });

            Assert.AreEqual(expectedScore, score);
        }