Exemplo n.º 1
0
        public void DeserializingCollectionOfObjectsWithClassNamesAsBlockNames()
        {
            var result = new OclSerializer().Deserialize <IEnumerable <FakeType> >(
                new OclDocument(
                    new[]
            {
                new OclBlock("fake_type", Array.Empty <string>(), new[] { new OclAttribute("foo", 1) }),
                new OclBlock("fake_type", Array.Empty <string>(), new[] { new OclAttribute("foo", 2) })
            }));

            result.Count().Should().Be(2);
        }
        public void Enum()
        {
            var data = new
            {
                MyProp = BindingFlags.Static
            };

            var result = new OclSerializer().ToOclDocument(data);

            result.Should()
            .HaveChildrenExactly(
                new OclAttribute("my_prop", "Static")
                );
        }
        public void ListOfComplexTypesProperty()
        {
            var data = new
            {
                Cars = new List <Car>
                {
                    new Car(), new Car()
                }
            };

            var result = new OclSerializer().ToOclDocument(data);

            result.Should()
            .HaveChildrenExactly(
                new OclBlock("car")
            {
                new OclAttribute("doors", 2)
            },
                new OclBlock("car")
            {
                new OclAttribute("doors", 2)
            }
                );
        }