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") } });
public object Deserialize(string ocl, Type type) { var document = OclParser.Execute(ocl); return(type == typeof(OclDocument) ? document : Deserialize(document, type)); }
public void Empty() => OclParser.Execute(@" MyBlock { } ") .Should() .HaveChildrenExactly(new OclBlock("MyBlock"));
public void DictionaryEmpty() => OclParser.Execute(@" Properties = { } ") .Should() .HaveChildrenExactly( new OclAttribute("Properties", new Dictionary <string, string>()) );
public void MultipleInRoot() => OclParser.Execute(@" One = 1 Two = 2 ") .Should() .HaveChildrenExactly( new OclAttribute("One", 1), new OclAttribute("Two", 2) );
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)); }
public void MultipleInRoot() => OclParser.Execute(@" MyBlock {} MyBlock {} ") .Should() .HaveChildrenExactly( new OclBlock("MyBlock"), new OclBlock("MyBlock") );
public void WithSingleAttributeChild() => OclParser.Execute(@" MyBlock { Child = 1 } ") .Should() .HaveChildrenExactly(new OclBlock("MyBlock") { new OclAttribute("Child", 1) });
public void WithMultipleAttributeChild() => OclParser.Execute(@" MyBlock { Child = 1 Child2 = 2 } ") .Should() .HaveChildrenExactly(new OclBlock("MyBlock") { new OclAttribute("Child", 1), new OclAttribute("Child2", 2) });
public void DictionaryOneItem() => OclParser.Execute(@" Properties = { ""One"" = ""1"" } ") .Should() .HaveChildrenExactly( new OclAttribute("Properties", new Dictionary <string, string> { { "One", "1" } } ) );
public void MultipleInBlock() => OclParser.Execute(@" MyBlock { One = 1 Two = 2 } ") .Should() .HaveChildrenExactly( new OclBlock("MyBlock") { new OclAttribute("One", 1), new OclAttribute("Two", 2) } );
public void NestedBlocks() => OclParser.Execute(@" MyBlock { ChildBlock { GrandChildBlock {} } } ") .Should() .HaveChildrenExactly(new OclBlock("MyBlock") { new OclBlock("ChildBlock") { new OclBlock("GrandChildBlock") } });
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" } } ) );
public void True() => OclParser.Execute("Foo = true") .Should() .HaveChildrenExactly(new OclAttribute("Foo", true));
public void False() => OclParser.Execute("Foo = false") .Should() .HaveChildrenExactly(new OclAttribute("Foo", false));
public void Decimal(string input, decimal expected) => OclParser.Execute(@"Foo = " + input) .Should() .HaveChildrenExactly(new OclAttribute("Foo", expected));
public void Null() => OclParser.Execute("Foo = null") .Should() .HaveChildrenExactly(new OclAttribute("Foo", null));
public void WithExtraWhitespace() => OclParser.Execute(" \t Foo = \t \"Bar\" \t ") .Should() .HaveChildrenExactly(new OclAttribute("Foo", "Bar"));
public void SingleLabel() => OclParser.Execute(@"MyBlock ""Foo"" {}") .Should() .HaveChildrenExactly(new OclBlock("MyBlock", new[] { "Foo" }));
public void StringInvalidEscape() { Action action = () => OclParser.Execute(@"Foo = ""\q"""); action.Should().Throw <OclException>().WithMessage(@"Unrecognised character escape: \q"); }
public void MultipleLabels() => OclParser.Execute(@"MyBlock ""Foo"" ""Bar"" ""Baz"" {}") .Should() .HaveChildrenExactly(new OclBlock("MyBlock", new[] { "Foo" }));
public void String(string text, string expected) => OclParser.Execute($@"Foo = ""{text}""") .Should() .HaveChildrenExactly(new OclAttribute("Foo", expected));
public void EmptyArray(string input) => OclParser.Execute(input) .Should() .HaveChildrenExactly(new OclAttribute("Foo", new string[0]));
public void Blank() => OclParser.Execute(" \t \r\n \t ") .Should() .Be(new OclDocument());
public void StringArray(string input) => OclParser.Execute(input) .Should() .HaveChildrenExactly(new OclAttribute("Foo", new[] { "A", "B" }));
public void Empty() => OclParser.Execute("") .Should() .Be(new OclDocument());