Exemplo n.º 1
0
        public void BoolTrueEqualTest()
        {
            var equal = new Equal(new Bool(true), new Bool(true));
            var result = (bool)equal.Execute();

            Assert.Equal(true, result);
        }
Exemplo n.º 2
0
        public void CalculateIfTest()
        {
            var parameters = new ParameterCollection() { new Parameter("x", 10) };

            var cond = new Equal(new Variable("x"), new Number(10));
            var @if = new If(cond, new Number(20));

            Assert.Equal(20.0, @if.Execute(parameters));
        }
Exemplo n.º 3
0
        public void CalculateElseTest()
        {
            var parameters = new ParameterCollection() { new Parameter("x", 0) };

            var cond = new Equal(new Variable("x"), new Number(10));
            var @if = new If(cond, new Number(20));

            @if.Calculate(parameters);
        }
Exemplo n.º 4
0
        public void BoolTrueAndFalseVarEqualTest()
        {
            var parameters = new ParameterCollection()
            {
                new Parameter("x", true),
                new Parameter("y", false)
            };
            var equal = new Equal(new Variable("x"), new Variable("y"));
            var result = (bool)equal.Execute(parameters);

            Assert.Equal(false, result);
        }
Exemplo n.º 5
0
        public void CalculateIfElseNegativeNumberTest()
        {
            var parameters = new ParameterCollection() { new Parameter("x", 0) };

            var cond = new Equal(new Variable("x"), new Number(0));
            var @if = new If(cond, new Number(1), new UnaryMinus(new Number(1)));

            Assert.Equal(1.0, @if.Execute(parameters));

            parameters["x"] = 10;

            Assert.Equal(-1.0, @if.Execute(parameters));
        }
Exemplo n.º 6
0
        public void CalculateIfElseTest()
        {
            var parameters = new ParameterCollection() { new Parameter("x", 10) };

            var cond = new Equal(new Variable("x"), new Number(10));
            var @if = new If(cond, new Number(20), new Number(0));

            Assert.AreEqual(20.0, @if.Calculate(parameters));

            parameters["x"] = 0;

            Assert.AreEqual(0.0, @if.Calculate(parameters));
        }
Exemplo n.º 7
0
        public void NumberVarEqualTest()
        {
            var parameters = new ParameterCollection()
            {
                new Parameter("x", 10),
                new Parameter("y", 10)
            };
            var equal = new Equal(new Variable("x"), new Variable("y"));
            var result = (bool)equal.Execute(parameters);

            Assert.Equal(true, result);
        }
Exemplo n.º 8
0
        public void NumberEqualTest()
        {
            var equal = new Equal(new Number(10), new Number(10));
            var result = (bool)equal.Execute();

            Assert.Equal(true, result);
        }
Exemplo n.º 9
0
        public void NumberAndBoolVarEqualTest()
        {
            var parameters = new ParameterCollection()
            {
                new Parameter("x", 10),
                new Parameter("y", false)
            };
            var equal = new Equal(new Variable("x"), new Variable("y"));

            Assert.Throws<NotSupportedException>(() => (bool)equal.Execute(parameters));
        }