예제 #1
0
        public void SetUp()
        {
            coalesceNodes = new ExprCoalesceNode[5];

            coalesceNodes[0] = new ExprCoalesceNode();
            coalesceNodes[0].AddChildNode(new SupportExprNode(null, typeof(long?)));
            coalesceNodes[0].AddChildNode(new SupportExprNode(null, typeof(int)));
            coalesceNodes[0].AddChildNode(new SupportExprNode(4, typeof(byte)));

            coalesceNodes[1] = new ExprCoalesceNode();
            coalesceNodes[1].AddChildNode(new SupportExprNode(null, typeof(string)));
            coalesceNodes[1].AddChildNode(new SupportExprNode("a", typeof(string)));

            coalesceNodes[2] = new ExprCoalesceNode();
            coalesceNodes[2].AddChildNode(new SupportExprNode(null, typeof(bool?)));
            coalesceNodes[2].AddChildNode(new SupportExprNode(true, typeof(bool)));

            coalesceNodes[3] = new ExprCoalesceNode();
            coalesceNodes[3].AddChildNode(new SupportExprNode(null, typeof(char)));
            coalesceNodes[3].AddChildNode(new SupportExprNode(null, typeof(char?)));
            coalesceNodes[3].AddChildNode(new SupportExprNode(null, typeof(char)));
            coalesceNodes[3].AddChildNode(new SupportExprNode('b', typeof(char?)));

            coalesceNodes[4] = new ExprCoalesceNode();
            coalesceNodes[4].AddChildNode(new SupportExprNode(5, typeof(float)));
            coalesceNodes[4].AddChildNode(new SupportExprNode(null, typeof(double?)));
        }
예제 #2
0
        public void TestValidate()
        {
            var coalesceNode = new ExprCoalesceNode();

            coalesceNode.AddChildNode(new SupportExprNode(1));

            // Test too few nodes under this node
            try
            {
                coalesceNode.Validate(SupportExprValidationContextFactory.MakeEmpty(container));
                Assert.Fail();
            }
            catch (ExprValidationException)
            {
                // Expected
            }

            // Test node result type not fitting
            coalesceNode.AddChildNode(new SupportExprNode("s"));
            try
            {
                coalesceNode.Validate(SupportExprValidationContextFactory.MakeEmpty(container));
                Assert.Fail();
            }
            catch (ExprValidationException)
            {
                // Expected
            }
        }
예제 #3
0
 public ExprCoalesceNodeForge(
     ExprCoalesceNode parent,
     Type resultType,
     bool[] isNumericCoercion)
 {
     ForgeRenderable = parent;
     EvaluationType = resultType.GetBoxedType(); // Coalescence is a boxed return
     IsNumericCoercion = isNumericCoercion;
 }