public void constructor_should_set_left_number() { // Given var nbr = new Variable("a", new RealNumber(1)); // When SUT = new Division(nbr, new Variable("b", new RealNumber(1))); // Then Assert.AreSame(nbr, SUT.LeftSide); }
public void fullConstructor_should_set_the_number() { // Given var nbr = new RealNumber(1); // When SUT = new Variable("a", nbr); // Then Assert.AreSame(nbr, SUT.Value); }
public void constructor_should_set_number() { // Given var nbr = new Variable("a", new RealNumber(1)); // When SUT = new AbsoluteNumber(nbr); // Then Assert.AreSame(nbr, SUT.InnerValue); }
public void fullConstructor_should_throw_if_value_is_null() { // Given // When // Then var ex = Assert.Throws<ArgumentNullException>( () => SUT = new Variable("a", null)); Assert.AreEqual("The value was null and that is not allowd\r\nParameter name: value", ex.Message); }
public void fullConstructor_should_throw_if_designation_is_nnull() { // Given // When // Then var ex = Assert.Throws<ArgumentNullException>( () => SUT = new Variable(null, new RealNumber(1))); Assert.AreEqual("The designation was null, empty or just white space and that is not allowd\r\nParameter name: designation", ex.Message); }
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 regenerate_should_regenerate_value() { // Given var nbr = new Mock<Number>(); SUT = new Variable("a", nbr.Object); // When SUT.Regenerate(); // Then nbr.Verify(x => x.Regenerate(), Times.Once); }
public void Teardown() { SUT = null; }
public void Setup() { SUT = new Variable("a", new RealNumber(1)); }
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); }
public void fullConstructor_should_set_designation() { // When SUT = new Variable("a", new RealNumber(1)); // Then Assert.AreEqual("a", SUT.Designation); }
public void constructor_should_set_right_number() { // Given var nbr = new Variable("a", new RealNumber(1)); // When SUT = new Subtraction(new Variable("b", new RealNumber(1)), nbr); // Then Assert.AreSame(nbr, SUT.RightSide); }