public void specify_Bmi_is_calculated_and_rounded_to_2_decimals() { 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(160, 65001, 25.39); tbl.Rows.Add(160, 65009, 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 measurement"] = () => { anExistingMeasurement(vars); it["OK"] = () => nop(); }; context["When the length is " + row["length"] + " and the weight is " + row["weight"]] = () => { TheLengthIsAndTheWeight((int)row["length"], (int)row["weight"], vars); vars.BMI = (double) row["BMI"]; it["Then the bmi is " + row["BMI"]] = () => theBmiIs(vars); }; } }
public void specify_A_new_measurement_can_be_created_with_a_length_and_a_weight_and_a_date() { DataTable tbl = new DataTable(); tbl.Columns.Add("length", typeof(int)); tbl.Columns.Add("weight", typeof(int)); tbl.Columns.Add("date", typeof(String)); tbl.Rows.Add(180, 75000, "12-12-2012"); tbl.Rows.Add(160, 75000, "12-12-2012"); tbl.Rows.Add(50, 75000, "12-12-2012"); tbl.Rows.Add(300, 75000, "12-12-2012"); tbl.Rows.Add(180, 65000, "12-12-2012"); tbl.Rows.Add(180, 20000, "12-12-2012"); tbl.Rows.Add(180, 700000, "12-12-2012"); tbl.Rows.Add(180, 75000, "10-10-2012"); Variables vars = new Variables(); foreach (DataRow row in tbl.Rows) { vars.resetParameters(); context["When I want to make a new measurement with length " + row["length"] + ", weight " + row["weight"] + "and date " + row["date"]] = () => { IWantToMakeANewMeasurementWithLengthAndWeightAndDate((int)row["length"], (int)row["weight"], (String)row["date"], vars); it["OK"] = () => nop(); it["Then A new measurement is created"] = () => aNewMeasurementIsCreated(vars); it["And the length is " + row["length"]] = () => theLengthIs(vars); it["And the weight is " + row["weight"]] = () => theWeightIs(vars); it["And the date is " + row["date"]] = () => theDateIs(vars); }; } }
public void specify_One_measurement_is_smaller_than_another_measurement_if_the_date_of_the_first_measurement_is_older() { Variables vars = new Variables(); vars.resetParameters(); context["Given an existing measurement with date 10-10-2012"] = () => { anExistingMeasurementWithDate("10-10-2012", vars); it["OK"] = () => nop(); context["And another existing measurement with date 12-12-2012"] = () => { anotherExistingMeasurementWithDate("12-12-2012", vars); it["OK"] = () => nop(); }; }; context["When I compare the measurement with date 10-10-2012 with the measurement with date 12-12-2012"] = () => { ICompareTheMeasurementWithDateWithTheMeasurementWithDate(vars); it["Then a negative number is returned"] = () => aNegativeNumberIsReturned(vars); }; }
public void specify_One_measurement_is_equal_than_another_measurement_if_the_dates_of_both_measurements_are_the_same() { Variables vars = new Variables(); vars.resetParameters(); context["Given an existing measurement with date 10-10-2012"] = () => { anExistingMeasurementWithDate("10-10-2012", vars); it["OK"] = () => nop(); context["And another existing measurement with date 10-10-2012"] = () => { anotherExistingMeasurementWithDate("10-10-2012", vars); it["OK"] = () => nop(); }; }; context["When I compare the measurement with date 10-10-2012 with the measurement with date 10-10-2012"] = () => { ICompareTheMeasurementWithDateWithTheMeasurementWithDate(vars); it["Then the number 0 is returned"] = () => theNumber0IsReturned(vars); }; }
public void specify_Measurement_cannot_receive_an_invalid_date() { DataTable tbl = new DataTable(); tbl.Columns.Add("date", typeof(String)); tbl.Columns.Add("remark", typeof(String)); tbl.Rows.Add("10-10-3016", "a date in future"); Variables vars = new Variables(); foreach (DataRow row in tbl.Rows) { vars.resetParameters(); context["Given an existing measurement"] = () => { anExistingMeasurement(vars); it["OK"] = () => nop(); }; context["When I change the date to " + row["date"] + " which is " + row["remark"]] = () => { IChangeTheDateToWhichIsRemark((String)row["date"], vars); it["OK"] = () => nop(); it["An exception is thrown"] = () => anExceptionIsThrown(vars); }; } }
public void specify_Two_measurements_are_not_equal_to_each_other_if_the_date_is_different_even_if_the_lengths_or_weights_are_equal() { Variables vars = new Variables(); vars.resetParameters(); context["Given an existing measurement with length 180, weight 75000 and date 12-12-2012"] = () => { anExistingMeasurementWithLengthAndWeightAndDate(180, 75000, "12-12-2012", vars); it["OK"] = () => nop(); context["And another existing measurement with the same length 180, the same weight 75000 and another date 10-10-2012"] = () => { anotherExistingMeasurementWithAnotherLengthAndWeightAndTheSameDate(180, 75000, "10-10-2012", vars); it["OK"] = () => nop(); }; }; context["When I check if these measurements are equal to each other"] = () => { ICheckIfTheseMeasurementsAreEqualToEachOther(vars); it["Then false is returned"] = () => FalseIsReturned(vars); }; }
public void specify_Measurement_can_receive_a_new_date() { DataTable tbl = new DataTable(); tbl.Columns.Add("date", typeof(String)); tbl.Columns.Add("remark", typeof(String)); tbl.Rows.Add("12-12-2012", "a date in past"); tbl.Rows.Add("10-10-2012", "another date in past"); Variables vars = new Variables(); foreach (DataRow row in tbl.Rows) { vars.resetParameters(); context["Given an existing measurement"] = () => { anExistingMeasurement(vars); it["OK"] = () => nop(); }; context["When I change the date to " + row["date"] + " which is " + row["remark"]] = () => { IChangeTheDateToWhichIsRemark((String)row["date"], vars); it["OK"] = () => nop(); it["The date is the current date"] = () => theDateIs(vars); }; } }
public void specify_Measurement_cannot_receive_an_invalid_weight() { DataTable tbl = new DataTable(); tbl.Columns.Add("weight", typeof(int)); tbl.Columns.Add("remark", typeof(String)); tbl.Rows.Add(-75000, "a negative weight"); tbl.Rows.Add(1999, "a just too small weight"); tbl.Rows.Add(700001, "a just too big weight"); Variables vars = new Variables(); foreach (DataRow row in tbl.Rows) { vars.resetParameters(); context["Given an existing measurement"] = () => { anExistingMeasurement(vars); it["OK"] = () => nop(); }; context["When I change the length to " + row["weight"] + " which is " + row["remark"]] = () => { IChangeTheWeightToWhichIsRemark((int)row["weight"], vars); it["OK"] = () => nop(); it["An exception is thrown"] = () => anExceptionIsThrown(vars); }; } }
public void specify_Measurement_can_receive_a_new_weight() { DataTable tbl = new DataTable(); tbl.Columns.Add("weight", typeof(int)); tbl.Columns.Add("remark", typeof(String)); tbl.Rows.Add(75000, "a normal weight"); tbl.Rows.Add(65000, "another normal weight"); tbl.Rows.Add(20000, "the minimum weight"); tbl.Rows.Add(700000, "the maximum weight"); Variables vars = new Variables(); foreach (DataRow row in tbl.Rows) { vars.resetParameters(); context["Given an existing measurement"] = () => { anExistingMeasurement(vars); it["OK"] = () => nop(); }; context["When I change the length to " + row["weight"] + " which is " + row["remark"]] = () => { IChangeTheWeightToWhichIsRemark((int)row["weight"], vars); it["OK"] = () => nop(); it["Then the weight is " + row["weight"]] = () => theWeightIs(vars); }; } }
public void specify_A_new_measurement_cannot_be_created_with_an_invalid_date_even_if_the_other_data_is_valid() { DataTable tbl = new DataTable(); tbl.Columns.Add("length", typeof(int)); tbl.Columns.Add("weight", typeof(int)); tbl.Columns.Add("date", typeof(String)); tbl.Rows.Add(180, 75000, "10-10-3016"); Variables vars = new Variables(); foreach (DataRow row in tbl.Rows) { vars.resetParameters(); context["When I want to make a new measurement with valid length " + row["length"] + ", valid weight " + row["weight"] + "and invalid date " + row["date"]] = () => { IWantToMakeANewMeasurementWithLengthAndWeightAndDate((int)row["length"], (int)row["weight"], (String)row["date"], vars); it["OK"] = () => nop(); it["Then an exception is thrown"] = () => anExceptionIsThrown(vars); }; } }
public void specify_A_new_measurement_cannot_be_created_with_an_invalid_weight_even_if_the_other_data_are_valid_constructor_with_2_parameters() { DataTable tbl = new DataTable(); tbl.Columns.Add("length", typeof(int)); tbl.Columns.Add("weight", typeof(int)); tbl.Rows.Add(180, -75000); tbl.Rows.Add(180, 1999); tbl.Rows.Add(180, 700001); Variables vars = new Variables(); foreach (DataRow row in tbl.Rows) { vars.resetParameters(); context["When I want to make a new measurement with valid length " + row["length"] + ", invalid weight " + row["weight"] + "and the current date"] = () => { IWantToMakeANewMeasurementWithLengthAndWeight((int)row["length"], (int)row["weight"], vars); it["OK"] = () => nop(); it["Then an exception is thrown"] = () => anExceptionIsThrown(vars); }; } }