Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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;
        }
Exemple #7
0
        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);
        }
Exemple #8
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);
        }
Exemple #9
0
 public void Teardown()
 {
     SUT = null;
 }
Exemple #10
0
 public void Setup()
 {
     SUT = new Variable("a", new RealNumber(1));
 }
Exemple #11
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);
        }
Exemple #12
-1
        public void fullConstructor_should_set_designation()
        {
            // When
            SUT = new Variable("a", new RealNumber(1));

            // Then
            Assert.AreEqual("a", SUT.Designation);
        }
Exemple #13
-1
        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);
        }