Ejemplo n.º 1
0
        public void EvalTest()
        {
            // Arrange
            double testValue = 1587.34;

            // Act
            ValNode testVarNode = new ValNode(testValue);

            // Assert
            Assert.AreEqual(testVarNode.Eval(), testValue);
        }
Ejemplo n.º 2
0
        public void CreateValNode()
        {
            string          name       = "foo";
            TypeInfo        typeinfo   = TypeInfo.Int;
            IExpressionNode expression = new ConstantNode(42);

            ValNode node = new ValNode(name, typeinfo, expression);

            Assert.AreEqual(name, node.Name);
            Assert.AreSame(TypeInfo.Int, node.TypeInfo);
            Assert.AreSame(expression, node.Expression);
        }
Ejemplo n.º 3
0
        public void EvalMultiplyTest()
        {
            // Arrange
            double  testLeftValue  = 11.3214;
            double  testRightValue = 3485;
            ExpNode testLeftNode   = new ValNode(testLeftValue);
            ExpNode testRightNode  = new ValNode(testRightValue);

            OpNode testOpNode = new OpNode(ref testLeftNode, ref testRightNode, '*');

            // Act and Assert
            Assert.AreEqual((testLeftValue * testRightValue), testOpNode.Eval());
        }
Ejemplo n.º 4
0
        public void CreateValNodeWithoutTypeInfo()
        {
            string          name       = "foo";
            TypeInfo        typeinfo   = TypeInfo.Int;
            IExpressionNode expression = new ConstantNode(42);

            ValNode node = new ValNode(name, null, expression);

            Assert.IsNull(node.TypeInfo);

            node.CheckType(null);

            Assert.AreSame(TypeInfo.Int, node.TypeInfo);
        }
Ejemplo n.º 5
0
        public void RegisterInContext()
        {
            string          name       = "foo";
            TypeInfo        typeinfo   = TypeInfo.Int;
            IExpressionNode expression = new ConstantNode(42);

            ValNode node = new ValNode(name, null, expression);

            Context context = new Context();

            node.RegisterInContext(context);

            Assert.IsNotNull(context.GetValue("foo"));
            Assert.AreSame(node, context.GetValue("foo"));
        }
Ejemplo n.º 6
0
        public void RegisterInContext()
        {
            INode node1 = new VarNode("a", null, new ConstantNode(42));
            INode node2 = new ValNode("b", null, new ConstantNode("foo"));

            CompositeNode node = new CompositeNode(new INode[] { node1, node2 });

            Context context = new Context();

            node.RegisterInContext(context);

            Assert.IsNotNull(context.GetValue("a"));
            Assert.IsNotNull(context.GetValue("b"));
            Assert.AreSame(node1, context.GetValue("a"));
            Assert.AreSame(node2, context.GetValue("b"));
        }