Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public void ExecuteNullSyntaxNodeException()
        {
            var ex = Assert.Throws <ArgumentNullException>(() =>
            {
                textInstruction.Evaluate(CompilerStateFixtures.Empty(), null);
            });

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

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

            Assert.Equal("node", ex.ParamName);
        }
Ejemplo n.º 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)));
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 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);
        }