Esempio n. 1
0
        public void TestComputeNodeWhenDivByZero()
        {
            var a = new NodeValue(4);
            var b = new NodeValue(0);
            var c = new NodeOperator(Operator.DIV, a, b);

            c.Compute();
        }
Esempio n. 2
0
        public void TestComputeNodeWhenDiv()
        {
            var a = new NodeValue(4);
            var b = new NodeValue(2);
            var c = new NodeOperator(Operator.DIV, a, b);

            Assert.AreEqual(2, c.Compute());
        }
Esempio n. 3
0
        public void TestComputeNodeWhenMult()
        {
            var a = new NodeValue(1);
            var b = new NodeValue(1);
            var c = new NodeOperator(Operator.MUL, a, b);

            Assert.AreEqual(1, c.Compute());
        }
Esempio n. 4
0
        public void TestComputeNodeWhenASub()
        {
            var a = new NodeValue(1);
            var b = new NodeValue(1);
            var c = new NodeOperator(Operator.SUB, a, b);

            Assert.AreEqual(0, c.Compute());
        }
Esempio n. 5
0
        public void TestComputeNodeWhenAdd()
        {
            var a = new NodeValue(1);
            var b = new NodeValue(1);
            var c = new NodeOperator(Operator.ADD, a, b);

            Assert.AreEqual(2, c.Compute());
        }
Esempio n. 6
0
        public void TestComputeNodeWhitThreeValue()
        {
            var a = new NodeValue(1);
            var b = new NodeValue(1);
            var c = new NodeValue(1);
            var d = new NodeOperator(Operator.ADD, a, b);
            var e = new NodeOperator(Operator.ADD, d, c);

            Assert.AreEqual(3, e.Compute());
        }
Esempio n. 7
0
        public void TestComputeNodeWithCalculPriority()
        {
            var a = new NodeValue(1);
            var b = new NodeValue(2);
            var c = new NodeValue(3);
            var d = new NodeValue(4);
            var e = new NodeOperator(Operator.MUL, b, c);
            var f = new NodeOperator(Operator.SUB, a, d);
            var g = new NodeOperator(Operator.ADD, e, f);

            Assert.AreEqual(3, g.Compute());
        }