Example #1
0
        public void ShouldHaveValidationErrorForInvalidRoundsWhenCalculatingTwelveRounds(
            int firstRollForRoundTen, int secondRollForRoundTen, int firstRollForRoundEleven, int secondRollForRoundEleven)
        {
            var calculateRoundScores = new CalculateRoundScores
            {
                Rounds = Enumerable.Repeat(new RoundRolls
                {
                    FirstRoll  = 10,
                    SecondRoll = 0
                }, 10)
            };

            calculateRoundScores.Rounds = calculateRoundScores.Rounds.Concat(new[]
            {
                new RoundRolls
                {
                    FirstRoll  = firstRollForRoundTen,
                    SecondRoll = secondRollForRoundTen
                },
                new RoundRolls
                {
                    FirstRoll  = firstRollForRoundEleven,
                    SecondRoll = secondRollForRoundEleven
                }
            });
            _validator.ShouldHaveValidationErrorFor(scores => scores.Rounds.ToList(), calculateRoundScores);
        }
Example #2
0
        public void ShouldHaveNotValidationErrorForValidRoundsWhenCalculatingElevenRounds(int firstRollForTenthRound, int secondRollForTenthRound)
        {
            var calculateRoundScores = new CalculateRoundScores
            {
                Rounds = Enumerable.Repeat(new RoundRolls
                {
                    FirstRoll  = 10,
                    SecondRoll = 0
                }, 9)
            };

            calculateRoundScores.Rounds = calculateRoundScores.Rounds.Concat(new[]
            {
                new RoundRolls
                {
                    FirstRoll  = firstRollForTenthRound,
                    SecondRoll = secondRollForTenthRound
                },
                new RoundRolls
                {
                    FirstRoll  = 5,
                    SecondRoll = 5
                }
            });
            _validator.ShouldHaveValidationErrorFor(scores => scores.Rounds.ToList(), calculateRoundScores);
        }
Example #3
0
        public void ShouldHaveValidationErrorForOutOfRangeRollValueSums()
        {
            var calculateRoundScores = new CalculateRoundScores
            {
                Rounds = Enumerable.Repeat(new RoundRolls
                {
                    FirstRoll  = 10,
                    SecondRoll = 10
                }, 2)
            };

            _validator.ShouldHaveValidationErrorFor(scores => scores.Rounds, calculateRoundScores);
        }
Example #4
0
        public void ShouldNotHaveValidationErrorForValidRollValues(int firstRoll, int secondRoll)
        {
            var calculateRoundScores = new CalculateRoundScores
            {
                Rounds = Enumerable.Repeat(new RoundRolls
                {
                    FirstRoll  = firstRoll,
                    SecondRoll = secondRoll
                }, 2)
            };

            _validator.ShouldNotHaveValidationErrorFor(scores => scores.Rounds, calculateRoundScores);
        }
Example #5
0
        public void ShouldNotHaveValidationErrorForValidRoundsCount(int roundsCount)
        {
            var calculateRoundScores = new CalculateRoundScores
            {
                Rounds = Enumerable.Repeat(new RoundRolls
                {
                    FirstRoll  = 10,
                    SecondRoll = 0
                }, roundsCount)
            };

            _validator.ShouldNotHaveValidationErrorFor(scores => scores.Rounds.Count(), calculateRoundScores);
        }
Example #6
0
 public ActionResult <IEnumerable <RoundScore> > Calculate([FromBody] CalculateRoundScores calculateRoundScores)
 {
     return(Ok(_handler.Handle(calculateRoundScores)));
 }