Пример #1
0
        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);
                };
            }
        }