コード例 #1
0
        public BmiRange ReadBmi(double height, double weight)
        {
            var result = default(BmiRange);
            // defining two pure fake functions to pass into the HOF
            // takes a string as input (the field name) and returns a double
            // we don't need to double.Parse as we control the test data
            Func <string, double> read = s => s == "height" ? height : weight;
            // takes a BmiRange and returns void
            // uses a local variable (result) to hold the value of BmiRange passed into the function, which the test returns
            Action <BmiRange> write = r => result = r;

            Bmi.Run(read, write);
            return(result);
        }
コード例 #2
0
 public double CalculateBmi(double height, double weight)
 => Bmi.CalculateBmi(height, weight);