예제 #1
0
        public static void ProcessBMI(Func <string, double> input, Action <BmiRange> output)
        {
            var height = input("height");
            var weight = input("weight");

            BmiRange result = CalculateBMI(height, weight);

            output(result);
        }
예제 #2
0
        public void CalculateBMI_ShouldReturnTheExpectedResult()
        {   //Arrange
            double height = 1.86;
            double weight = 85;
            //Act
            BmiRange result = CalculateBMI(height, weight);

            //Assert
            Assert.Equal(expected: BmiRange.Healthy, actual: result);
        }
예제 #3
0
        public void HOF_ProcessBMI_ShouldBeProvidedWithImpureFunctionsForIO(double height, double weight, BmiRange expected)
        {
            //Arrange
            BmiRange result              = default;
            Func <string, double> input  = (str) => str == "height" ? height : weight;
            Action <BmiRange>     output = (str) => result = str;

            //Act
            ProcessBMI(input, output);
            //Assert
            Assert.Equal(expected: expected, actual: result);
        }
 private static void Write(BmiRange bmiRange)
 => WriteLine($"Based on your BMI, you are {bmiRange}");