Exemplo n.º 1
0
        public void MixedChildren()
        => OclParser.Execute(@"
                    MyBlock {
                        ChildBlock1 {


                        }
                        Child1 = 1
                        Child2 = 2


    ChildBlock2 ""Label"" {
        GrandChildBlock {}


        GrandChild = ""A""

    }
                    }
                ")
        .Should()
        .HaveChildrenExactly(new OclBlock("MyBlock")
        {
            new OclBlock("ChildBlock1"),
            new OclAttribute("Child1", 1),
            new OclAttribute("Child2", 2),

            new OclBlock("ChildBlock2", new[] { "Label" })
            {
                new OclBlock("GrandChildBlock"),
                new OclAttribute("GrandChild", "A")
            }
        });
Exemplo n.º 2
0
        public object Deserialize(string ocl, Type type)
        {
            var document = OclParser.Execute(ocl);

            return(type == typeof(OclDocument)
                ? document
                : Deserialize(document, type));
        }
Exemplo n.º 3
0
        public void Empty()
        => OclParser.Execute(@"
                    MyBlock {

                    }
                ")
        .Should()
        .HaveChildrenExactly(new OclBlock("MyBlock"));
Exemplo n.º 4
0
 public void DictionaryEmpty()
 => OclParser.Execute(@"
         Properties = {
         }
         ")
 .Should()
 .HaveChildrenExactly(
     new OclAttribute("Properties", new Dictionary <string, string>())
     );
Exemplo n.º 5
0
 public void MultipleInRoot()
 => OclParser.Execute(@"
         One = 1
         Two = 2
         ")
 .Should()
 .HaveChildrenExactly(
     new OclAttribute("One", 1),
     new OclAttribute("Two", 2)
     );
Exemplo n.º 6
0
        public void Int(string input, int expected)
        {
            var result = OclParser.Execute(@"Foo = " + input);

            result
            .Should()
            .HaveChildrenExactly(new OclAttribute("Foo", expected));

            result.OfType <OclAttribute>().First().Value.Should().BeOfType(typeof(int));
        }
Exemplo n.º 7
0
 public void MultipleInRoot()
 => OclParser.Execute(@"
         MyBlock {}
         MyBlock {}
         ")
 .Should()
 .HaveChildrenExactly(
     new OclBlock("MyBlock"),
     new OclBlock("MyBlock")
     );
Exemplo n.º 8
0
 public void WithSingleAttributeChild()
 => OclParser.Execute(@"
             MyBlock {
                 Child = 1
             }
         ")
 .Should()
 .HaveChildrenExactly(new OclBlock("MyBlock")
 {
     new OclAttribute("Child", 1)
 });
Exemplo n.º 9
0
        public void WithMultipleAttributeChild()
        => OclParser.Execute(@"
                    MyBlock {
                        Child = 1
                        Child2 = 2

                    }
                ")
        .Should()
        .HaveChildrenExactly(new OclBlock("MyBlock")
        {
            new OclAttribute("Child", 1),
            new OclAttribute("Child2", 2)
        });
Exemplo n.º 10
0
 public void DictionaryOneItem()
 => OclParser.Execute(@"
         Properties = {
             ""One"" = ""1""
         }
         ")
 .Should()
 .HaveChildrenExactly(
     new OclAttribute("Properties",
                      new Dictionary <string, string>
 {
     { "One", "1" }
 }
                      )
     );
Exemplo n.º 11
0
 public void MultipleInBlock()
 => OclParser.Execute(@"
         MyBlock {
             One = 1
             Two = 2
         }
         ")
 .Should()
 .HaveChildrenExactly(
     new OclBlock("MyBlock")
 {
     new OclAttribute("One", 1),
     new OclAttribute("Two", 2)
 }
     );
Exemplo n.º 12
0
 public void NestedBlocks()
 => OclParser.Execute(@"
             MyBlock {
                 ChildBlock {
                     GrandChildBlock {}
                 }
             }
         ")
 .Should()
 .HaveChildrenExactly(new OclBlock("MyBlock")
 {
     new OclBlock("ChildBlock")
     {
         new OclBlock("GrandChildBlock")
     }
 });
Exemplo n.º 13
0
 public void Dictionary()
 => OclParser.Execute(@"
         Properties = {
             One.One = ""1""
             ""Two Two"" = ""2""
             ""Three\""Three"" = ""3""
         }
         ")
 .Should()
 .HaveChildrenExactly(
     new OclAttribute("Properties",
                      new Dictionary <string, string>
 {
     { "One.One", "1" },
     { "Two Two", "2" },
     { "Three\"Three", "3" }
 }
                      )
     );
Exemplo n.º 14
0
 public void True()
 => OclParser.Execute("Foo = true")
 .Should()
 .HaveChildrenExactly(new OclAttribute("Foo", true));
Exemplo n.º 15
0
 public void False()
 => OclParser.Execute("Foo = false")
 .Should()
 .HaveChildrenExactly(new OclAttribute("Foo", false));
Exemplo n.º 16
0
 public void Decimal(string input, decimal expected)
 => OclParser.Execute(@"Foo = " + input)
 .Should()
 .HaveChildrenExactly(new OclAttribute("Foo", expected));
Exemplo n.º 17
0
 public void Null()
 => OclParser.Execute("Foo = null")
 .Should()
 .HaveChildrenExactly(new OclAttribute("Foo", null));
Exemplo n.º 18
0
 public void WithExtraWhitespace()
 => OclParser.Execute(" \t   Foo    = \t  \"Bar\"  \t  ")
 .Should()
 .HaveChildrenExactly(new OclAttribute("Foo", "Bar"));
Exemplo n.º 19
0
 public void SingleLabel()
 => OclParser.Execute(@"MyBlock ""Foo"" {}")
 .Should()
 .HaveChildrenExactly(new OclBlock("MyBlock", new[] { "Foo" }));
Exemplo n.º 20
0
        public void StringInvalidEscape()
        {
            Action action = () => OclParser.Execute(@"Foo = ""\q""");

            action.Should().Throw <OclException>().WithMessage(@"Unrecognised character escape: \q");
        }
Exemplo n.º 21
0
 public void MultipleLabels()
 => OclParser.Execute(@"MyBlock ""Foo"" ""Bar"" ""Baz"" {}")
 .Should()
 .HaveChildrenExactly(new OclBlock("MyBlock", new[] { "Foo" }));
Exemplo n.º 22
0
 public void String(string text, string expected)
 => OclParser.Execute($@"Foo = ""{text}""")
 .Should()
 .HaveChildrenExactly(new OclAttribute("Foo", expected));
Exemplo n.º 23
0
 public void EmptyArray(string input)
 => OclParser.Execute(input)
 .Should()
 .HaveChildrenExactly(new OclAttribute("Foo", new string[0]));
Exemplo n.º 24
0
 public void Blank()
 => OclParser.Execute(" \t \r\n \t ")
 .Should()
 .Be(new OclDocument());
Exemplo n.º 25
0
 public void StringArray(string input)
 => OclParser.Execute(input)
 .Should()
 .HaveChildrenExactly(new OclAttribute("Foo", new[] { "A", "B" }));
Exemplo n.º 26
0
 public void Empty()
 => OclParser.Execute("")
 .Should()
 .Be(new OclDocument());