Esempio n. 1
0
        public void Should_allow_knock_down_10_pins_as_max()
        {
            // Arrange
            var scorer = new Scorer();

            // Act && assert
            scorer.Invoking(s => s.Roll(11)).ShouldThrow<ArgumentException>()
                  .And.Message.Should().Be("Max number of available pins is 10");
        }
Esempio n. 2
0
        public void Should_allow_addtional_20Th_roll_if_there_are_strike_in_the_last_frame_and_one_strike_before()
        {
            // Arrange
            var scorer = new Scorer();

            // Act
            scorer.Roll(10);
            for (int i = 0; i < 17; i++)
            {
                scorer.Roll(0);
            }
            scorer.Roll(10);
            scorer.Roll(0);

            // Assert
            scorer.Invoking(s => s.Roll(1)).ShouldThrow<MaxNumberOfRollsExceededException>();
        }
Esempio n. 3
0
        public void Should_allow_only_19_rolls_if_strike_is_not_in_the_last_frame()
        {
            // Arrange
            var scorer = new Scorer();

            // Act
            scorer.Roll(10);
            for (int i = 0; i < 18; i++)
            {
                scorer.Roll(2);
            }

            // Assert
            scorer.Invoking(r => r.Roll(1)).ShouldThrow<MaxNumberOfRollsExceededException>();
        }
Esempio n. 4
0
        public void Should_not_allow_to_knock_down_negative_number_of_pins()
        {
            // Arrange
            var scorer = new Scorer();

            // Act && Assert
            scorer.Invoking(s => s.Roll(-1)).ShouldThrow<ArgumentException>()
                  .And.Message.Should().Be("Number of pins cannot be negative");
        }
Esempio n. 5
0
        public void Should_allow_only_20_rolls()
        {
            // Arrange
            var scorer = new Scorer();

            // Act
            for (int i = 0; i < 20; i++)
            {
                scorer.Roll(1);
            }

            // Assert
            scorer.Invoking(s => s.Roll(1)).ShouldThrow<MaxNumberOfRollsExceededException>("sdf")
                  .And.Message.Should().Be("Maximum number of rolls exceeded", "Message should be meaningful");
        }