예제 #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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        static void Main(string[] args)
        {
            double weightInImperialMode = 190;
            double heightInImperialMode = 72;

            var calculator = new BmiCalculator();

            Console.WriteLine("Bmi in Imperial mode is " + calculator.CalculateWeight(weightInImperialMode, heightInImperialMode));

            double weightInMetricMode = 85;
            double heightInMetriMode  = 1.82;

            var metricCalculator = new BmiCalculator(FormulaType.Metric);

            Console.WriteLine("Bmi in metric mode is " + metricCalculator.CalculateWeight(weightInMetricMode, heightInMetriMode));

            BmiResult bmiResult = calculator.CalculateResult(weightInImperialMode, heightInImperialMode);

            Console.WriteLine("Bmi in Imperial mode is " + bmiResult.Bmi + " Weight category is " + bmiResult.Category);
        }