public void ExecuteSimple()
        {
            var field = new FieldSyntax
            {
                Name = new NameSyntax
                {
                    Value = "key"
                },
                Value = new ListSyntax
                {
                    new TextSyntax
                    {
                        Text = "value"
                    }
                }
            };
            var objectField = fieldInstruction.Evaluate(CompilerStateFixtures.Empty(), field);

            Assert.IsType <ObjectField>(objectField);
            var castedField = (ObjectField)objectField;

            Assert.Equal("key", castedField.Key);
            var resultArguments = (Argument[])castedField.Argument.Value;
            var paragraph       = (Paragraph)resultArguments[0].Value;
            var leaf            = (ITextLeaf)paragraph.Leaves[0];

            Assert.Equal("value", leaf.Content);
        }
Beispiel #2
0
        public void ExecuteNullSyntaxNodeException()
        {
            var ex = Assert.Throws <ArgumentNullException>(() =>
            {
                textInstruction.Evaluate(CompilerStateFixtures.Empty(), null);
            });

            Assert.Equal("text", ex.ParamName);
        }
        public void EvaluateFieldNullException()
        {
            var ex = Assert.Throws <ArgumentNullException>(() =>
            {
                fieldInstruction.Evaluate(CompilerStateFixtures.Empty(), null);
            });

            Assert.Equal("field", ex.ParamName);
        }
        public void NonValidTypeException()
        {
            var ex = Assert.Throws <ArgumentNullException>(() =>
            {
                EngineInstruction.Evaluate(CompilerStateFixtures.Empty(), null);
            });

            Assert.Equal("node", ex.ParamName);
        }
Beispiel #5
0
        public void EvaluateEmpty()
        {
            var node   = new ArraySyntax();
            var result = arrayInstruction.Evaluate(CompilerStateFixtures.Empty(), node);

            Assert.IsType <ObjectArray>(result);
            var array = (ObjectArray)result;

            Assert.Equal(node, array.Origin);
            Assert.Empty(array.Get(typeof(object)));
        }
        public void ReturnsValueTest()
        {
            var cs = CompilerStateFixtures.Empty();

            PageVariables.Size.Set(cs.Document, new Size(410, 0));
            PageVariables.Margin.Set(cs.Document, Thickness.Zero);
            var result = instruction.Evaluate(cs, new Language.Syntax.PercentSyntax());

            Assert.IsType <string>(result);
            Assert.Equal("*4.1pt", result as string);
        }
Beispiel #7
0
        public void ExecuteSimple()
        {
            var result = textInstruction.Evaluate(CompilerStateFixtures.Empty(), new TextSyntax
            {
                Text = "text"
            });

            Assert.IsType <TextLeaf>(result);
            var text = (TextLeaf)result;

            Assert.Equal("text", text.Content);
        }