Roll() public method

public Roll ( int pins ) : void
pins int
return void
Exemplo n.º 1
0
        [TestMethod] // 7
        public void StrikeFirstFrameGuttersRest()
        {
            var game = new Game();

            game.Roll(10);
            SimulateRoll(game, 19, 0);
            Assert.AreEqual(10, game.Score());
        }
Exemplo n.º 2
0
 private void RollMany(int numberRoll, int pinsKnocked)
 {
     for (var i = 0; i < numberRoll; i++)
     {
         _game.Roll(pinsKnocked);
     }
 }
Exemplo n.º 3
0
 private void RollMany(int n, int pins)
 {
     for (int i = 0; i < n; i++)
     {
         game.Roll(pins);
     }
 }
Exemplo n.º 4
0
 public void TestOneSpare()
 {
     rollSpare();
     g.Roll(3);
     RollMany(17, 0);
     Assert.Equal(16, g.TotalScore);
 }
Exemplo n.º 5
0
        public static Game RollMany(this Game game, int rolls, ushort pins)
        {
            for (var i = 0; i < rolls; i++)
            {
                game.Roll(pins);
            }

            return(game);
        }
Exemplo n.º 6
0
        public void TestOneSpare()
        {
            _game.Roll(3);
            _game.Roll(7);
            _game.Roll(3);
            ProcessRolling(17, 0);

            Assert.AreEqual(16, _game.GetScore());
        }
Exemplo n.º 7
0
        [TestMethod] // 13
        public void AllSpares()
        {
            var game = new Game();

            for (int i = 0; i < 21; i++)
            {
                game.Roll(5);
            }

            Assert.AreEqual(150, game.Score());
        }
Exemplo n.º 8
0
        [TestMethod] // 9
        public void ThreeConsecutiveStrikesPlusTwoBallBonusThenGutters()
        {
            var game = new Game();

            game.Roll(10);
            game.Roll(10);
            game.Roll(10);
            game.Roll(5);
            game.Roll(0);
            game.Roll(5);
            game.Roll(0);
            SimulateRoll(game, 10, 0);
        }
Exemplo n.º 9
0
        public void RollAndHitInvalidNumberOfPins(int numberOfPinsKnockedDown)
        {
            // Given too many pins in a roll
            _game.Roll(numberOfPinsKnockedDown);

            // The game ignores the roll and does not give any score
            Assert.Equal(0, _game.Score());
        }
Exemplo n.º 10
0
        public void Score_UserGetsPinsWithOnlyOnePin_ReturnsTwenty()
        {
            Game game = new Game();

            for (int i = 1; i <= 20; i++)
                game.Roll(1);

            Assert.That(game.Score, Is.EqualTo(20));
        }
Exemplo n.º 11
0
        public void Score_UserGetsNoPoint_ReturnsZero()
        {
            Game game = new Game();

            for (int i = 1; i <= 20; i++)
                game.Roll(0);

            Assert.That(game.Score, Is.EqualTo(0));
        }
Exemplo n.º 12
0
        public void Score_TwoStrikes_AndRestOne()
        {
            Game game = new Game();
            game.Roll(10);
            game.Roll(10);
            for (int i = 1; i <= 16; i++)
                game.Roll(1);

            Assert.That(game.Score, Is.EqualTo(49));
        }
Exemplo n.º 13
0
 public void Score_PerfectGame_ResultIs300()
 {
     Game game = new Game();
     for (int i = 1; i <= 12; i++)
         game.Roll(10);
     Assert.That(game.Frames.Count,Is.EqualTo(10));
     Assert.That(game.Score, Is.EqualTo(300));
 }
Exemplo n.º 14
0
        public void Score_Game_With_Spares_Only()
        {
            Game game = new Game();

            for (int i = 1; i <= 21; i++)
                game.Roll(5);

            Assert.That(game.Score, Is.EqualTo(150));
        }
Exemplo n.º 15
0
        public void Score_Game_With_Nines_And_Miss_Only()
        {
            Game game = new Game();

            for (int i = 1; i <= 10; i++)
            {
                game.Roll(9);
                game.Roll(0);
            }

            Assert.That(game.Score, Is.EqualTo(90));
        }
Exemplo n.º 16
0
 public static void Main(string[] args)
 {
     var game = new Game();
     game.Roll(12);
 }
Exemplo n.º 17
0
 public static void TakeOneRoll(this Game game, int roll)
 {
     game.Roll(roll);
 }
Exemplo n.º 18
0
 public static void TakeTwoRolls(this Game game, int firstRoll, int seconeRoll)
 {
     game.Roll(firstRoll);
     game.Roll(seconeRoll);
 }