示例#1
0
        public void EvalTest()
        {
            // Arrange
            double testValue = 1587.34;

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

            // Assert
            Assert.AreEqual(testVarNode.Eval(), testValue);
        }
示例#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);
        }
示例#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());
        }
示例#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);
        }
示例#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"));
        }
示例#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"));
        }