Exemple #1
0
        public void Evaluate()
        {
            ParserContext    pc = new ParserContext(ParserContext.DefaultBufferSize);
            FormatterContext fc = new FormatterContext(FormatterContext.DefaultBufferSize);

            IsSetExpression ee = new IsSetExpression(new MessageExpression(3));

            // Passing null message (as parameter and in the contexts).
            try {
                ee.EvaluateParse(ref pc);
                Assert.Fail();
            }
            catch (ExpressionEvaluationException) {
            }
            try {
                ee.EvaluateFormat(new StringField(3, "000000"), ref fc);
                Assert.Fail();
            }
            catch (ExpressionEvaluationException) {
            }

            // Evaluate.
            Message msg = MessagesProvider.GetMessage();

            pc.CurrentMessage = msg;
            Assert.IsTrue(ee.EvaluateParse(ref pc));
            fc.CurrentMessage = msg;
            Assert.IsTrue(ee.EvaluateFormat(new StringField(3, "000000"), ref fc));
            ee = new IsSetExpression(new MessageExpression(4));
            Assert.IsFalse(ee.EvaluateParse(ref pc));
            Assert.IsFalse(ee.EvaluateFormat(new StringField(3, "000000"), ref fc));
        }
Exemple #2
0
        public void InstantiationAndProperties()
        {
            IsSetExpression ee = new IsSetExpression();

            Assert.IsNull(ee.MessageExpression);

            MessageExpression me = new MessageExpression(3);

            ee = new IsSetExpression(me);

            Assert.IsTrue(ee.MessageExpression.GetLeafFieldNumber() == 3);
            Assert.IsTrue(ee.MessageExpression == me);

            me.FieldNumber = 5;
            Assert.IsTrue(ee.MessageExpression.GetLeafFieldNumber() == 5);

            ee.MessageExpression = null;
            Assert.IsNull(ee.MessageExpression);
        }