private static void TestWithParameters(int age, int length, SkiStyle skistyle,
                                               int expectedSkiLengthMin, int expectedSkiLengthMax, string expectedComment)
        {
            var result = new SkiLengthCalculator().Calculate(age, length, skistyle);

            Assert.Equal(expectedSkiLengthMin, result.SkiLength.Min);
            Assert.Equal(expectedSkiLengthMax, result.SkiLength.Max);
            Assert.Equal(expectedComment, result.Comment);
        }
Ejemplo n.º 2
0
        public Answer Calculate(int age, int length, SkiStyle skistyle)
        {
            if (age < 0 || length < 0)
            {
                throw new ArgumentException("Age and length cannot be a negative number.");
            }

            int    skiLength = length;
            Answer answer    = new Answer(new Range(length, length), "");

            if (skistyle == SkiStyle.Classic)
            {
                answer = new Answer(new Range(skiLength + 20, skiLength + 20), "");

                if (age >= 5 && age <= 8)
                {
                    answer.SkiLength.Min += 10;
                    answer.SkiLength.Max += 20;
                }
            }
            if (skistyle == SkiStyle.FreeStyle)
            {
                answer = new Answer(new Range(skiLength + 10, skiLength + 15),
                                    "Enligt tävlingsreglerna får inte skidan understiga kroppslängden med mer än 10cm.");
                if (age >= 5 && age <= 8)
                {
                    answer.SkiLength.Min += 10;
                    answer.SkiLength.Max += 20;
                }
            }
            if (answer.SkiLength.Max >= 207 && skistyle == SkiStyle.Classic)
            {
                answer.Comment       = "Klassiska skidor tillverkas bara till längder upp till 207cm.";
                answer.SkiLength.Max = 207;
            }
            if (answer.SkiLength.Min >= 207 && skistyle == SkiStyle.Classic)
            {
                answer.SkiLength.Min = 207;
            }

            return(answer);
        }
Ejemplo n.º 3
0
 public AnswerDto GetSkiLength(int length, int age, SkiStyle skistyle)
 {
     return(AnswerDtoFactory.Create(_skiLengthCalculator.Calculate(age, length, skistyle)));
 }
Ejemplo n.º 4
0
 public CalculatorParameters(SkiStyle style, int age, int height)
 {
     Style  = style;
     Age    = age;
     Height = height;
 }