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); }
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); }
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}");