Beispiel #1
0
        public BmiResult CalculateResult(double mass, double height)
        {
            double bmi = CalculateWeight(mass, height);
            string category = categoryRetriever.GetWeightCategoryString(bmi);

            BmiResult bmiResult = new BmiResult()
                                        {
                                            Bmi = bmi,
                                            Category = category
                                        };
            return bmiResult;
        }
        public void Calculate_BmiResult_In_Metric_Mode()
        {
            double weight = 85;
            double height = 1.82;

            var calculator = new BmiCalculator(FormulaType.Metric, new CategoryRetriever());

            BmiResult actual = calculator.CalculateResult(weight, height);

            double bmiResult = 25.7;
            string category = "Over weight";
            var expected = new BmiResult(bmiResult, category);

            Assert.NotNull(actual);
            Assert.Equal(expected.Bmi, actual.Bmi);
            Assert.Equal(expected.Category, actual.Category);
        }
        public void Calculate_BmiResult_In_Imperial_Mode()
        {
            double weight = 190;
            double height = 72;

            var calculator = new BmiCalculator();

            BmiResult actual = calculator.CalculateResult(weight, height);

            double bmiResult = 25.8;
            string category = "Over weight";
            var expected = new BmiResult(bmiResult, category);

            Assert.NotNull(actual);
            Assert.Equal(expected.Bmi, actual.Bmi);
            Assert.Equal(expected.Category, actual.Category);
        }