private static Variable createVariable(string text, Dictionary<string, Variable>variables) { var designation = Regex.Match(text, "^[a-ö]+").Value; var value = getValue(text, variables); var variable = new Variable(designation, value); variables.Add(designation, variable); var conditions = getConditions(text, variables, value, designation); variable.SetConditions(conditions.ToArray()); return variable; }
public void regenerate_should_not_set_new_value_that_does_not_match_conditions() { // Given var rand = new RandomInteger(1, 4); var leq = new LessThan(rand, new RealNumber(2)); SUT = new Variable("a", rand); SUT.SetConditions(leq); // When SUT.Regenerate(); // Then Assert.LessOrEqual(SUT.GetRealNumber().Value, 2.0); }
public void setCondtions_should_throw_if_value_cant_match_conditions() { // Given SUT = new Variable("a", new RandomInteger(3, 5)); // Then var ex = Assert.Throws<ArgumentException>(() => SUT.SetConditions(new LessThan(SUT.Value, new RealNumber(2)))); Assert.AreEqual("Value can't take a number that is accepted by the conditions\r\nParameter name: conditions", ex.Message); }