public void EvalTest() { // Arrange double testValue = 1587.34; // Act ValNode testVarNode = new ValNode(testValue); // Assert Assert.AreEqual(testVarNode.Eval(), testValue); }
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); }
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()); }
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); }
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")); }
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")); }