Example #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("********* UR Health BMI Calculator *********** \n");

            Console.WriteLine("********* BMI Categories *********** \n");
            Console.WriteLine(" Under Weight =< 18.5 \n Normal Weight > 18.5 And <= 24.9 \n Overweight > 25 And <= 29.9 \n Obesity >=30\n");
            Console.WriteLine("********* End of BMI Categories *********** \n");

            BMICalculator bmiCalculator = new BMICalculator();

            Console.WriteLine("Enter weight in Kilog grams...");

            float weightInKg;

            float.TryParse(Console.ReadLine(), out weightInKg);

            Console.WriteLine("Enter height in Meters...");

            float heightInMeters;

            float.TryParse(Console.ReadLine(), out heightInMeters);

            bmiCalculator.WeightInKg     = weightInKg;
            bmiCalculator.HeightInMeters = heightInMeters;

            float BMI = (float)Math.Round(bmiCalculator.Calculate(), 1);

            Console.WriteLine("Your BMI is : {0} && BMI Category : {1}", BMI, BMICategory.GetBMICategory(BMI));

            Console.WriteLine("*********  ***********");
            Console.Read();
        }
Example #2
0
        public void TestBMIUnderweight() // unit test for Underweight BMI function
        {
            BMICalculator.BMI BMITest = new BMICalculator.BMI
            {
                WeightStones = 2,
                WeightPounds = 6,
                HeightFeet   = 4,
                HeightInches = 72,
            };
            BMICategory expected = BMICategory.Underweight;
            BMICategory actual   = BMITest.BMICategory;

            Assert.AreEqual(expected, actual);
        }
Example #3
0
        public void TestBMIObese()
        {
            BMICalculator.BMI BMITest = new BMICalculator.BMI
            {
                WeightStones = 1,
                WeightPounds = 1,
                HeightFeet   = 1,
                HeightInches = 1,
            };
            BMICategory expected = BMICategory.Obese;
            BMICategory actual   = BMITest.BMICategory;

            Assert.AreEqual(expected, actual);
        }
Example #4
0
        public void TestBMICategory_BMIValueIsObese_ReturnObese()
        {
            //Arrange
            BMI bmi = new BMI();

            bmi.WeightStones = 20;
            bmi.WeightPounds = 10;
            bmi.HeightInches = 10;
            bmi.HeightFeet   = 5;

            //Act
            BMICategory expectedResult = bmi.BMICategory;

            //Assert
            Assert.AreEqual(BMICategory.Obese, expectedResult);
        }
Example #5
0
        public void TestBMICategory_BMIValueIsOverweight_ReturnOverweight()
        {
            //Arrange
            BMI bmi = new BMI();

            bmi.WeightStones = 6;
            bmi.WeightPounds = 10;
            bmi.HeightInches = 1;
            bmi.HeightFeet   = 4;

            //Act
            BMICategory expectedResult = bmi.BMICategory;

            //Assert
            Assert.AreEqual(BMICategory.Overweight, expectedResult);
        }
Example #6
0
        public void TestBMICategory_Calculates_ReturnCategoryOverweight()
        {
            //Arrange
            BMI calcBMIValue = new BMI();

            calcBMIValue.WeightStones = 12;
            calcBMIValue.WeightPounds = 4;
            calcBMIValue.HeightFeet   = 5;
            calcBMIValue.HeightInches = 7;

            //double testBMIValue = calcBMIValue.BMIValue;

            BMICategory expectedResult = BMICategory.Overweight;

            //Act
            BMICategory actualResult = calcBMIValue.BMICategory;

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }