public void specify_The_bmi_is_calculated_based_on_the_length_and_the_weight_of_a_person() { DataTable tbl = new DataTable(); tbl.Columns.Add("Length", typeof(int)); tbl.Columns.Add("Weight", typeof(int)); tbl.Columns.Add("BMI", typeof(double)); tbl.Rows.Add(160, 65000, 25.39); tbl.Rows.Add(180, 75000, 23.15); Variables vars = new Variables(); foreach (DataRow row in tbl.Rows) { vars.resetParameters(); context["Given an existing person"] = () => { anExistingPerson(vars); it["OK"] = () => nop(); }; context["And a last measurement with length " + row["Length"] + " and weight " + row["Weight"]] = () => { aLastMeasurementWithLengthAndWeight((int)row["Length"], (int)row["Weight"], vars); it["OK"] = () => nop(); }; context["When I choose to calculate the bmi of this person"] = () => { IChooseToCalculateTheBmiOfThisPerson(vars); vars.BMIBuf = (double) row["BMI"]; it["Then the bmi is " + row["BMI"]] = () => theBmiIs(vars); }; } }
public void specify_The_bmi_is_calculated_based_on_the_most_recent_anamnesis_of_the_person() { Variables vars = new Variables(); context["Given an existing person"] = () => { anExistingPerson(vars); it["OK"] = () => nop(); }; context["And a measurement on 12-12-2012 with length 180 and weight 65000"] = () => { aMeasurementOnWithLengthAndWeight("12-12-2012", 180, 65000, vars); it["OK"] = () => nop(); }; context["And a measurement on 12-12-2012 with length 180 and weight 65000"] = () => { aMeasurementOnWithLengthAndWeight("12-12-2013", 180, 75000, vars); it["OK"] = () => nop(); }; context["When I choose to calculate the bmi of this person"] = () => { IChooseToCalculateTheBmiOfThisPerson(vars); vars.BMIBuf = 23.15; it["Then the bmi is 23.15"] = () => theBmiIs(vars); }; }
private void aLastMeasurementWithLengthAndWeight(int length, int weight, Variables vars) { vars.person.addMeasurement(new Measurement(length, weight, DateTime.Now)); }
private void IChooseToCalculateTheBmiOfThisPerson(Variables vars) { vars.BMI = vars.person.getBMI(); }
private void anExistingPerson(Variables vars) { vars.person = new Person(_SOCSECNR, _BIRTHDATE, _GENDER, new Measurement(_LENGTH, _WEIGHT, _DATE)); }
private void aMeasurementOnWithLengthAndWeight(string date, int length, int weight, Variables vars) { vars.person.addMeasurement(new Measurement(length, weight, DateTime.Parse(date))); }
private void theBmiIs(Variables vars) { vars.person.getBMI().should_be(vars.BMI); }