Exemplo n.º 1
0
        public void ConverterIsUsedForTheRootDocument()
        {
            var options = new OclSerializerOptions();

            options.Converters.Add(new FakeConverter());

            new OclSerializer(options).ToOclDocument(new FakeType())
            .Should()
            .HaveChildrenExactly(new OclAttribute("Fake", null));
        }
Exemplo n.º 2
0
        public void MultilineStringsUseHeredocAndTheHeredocIdentifierFromOptions()
        {
            var options = new OclSerializerOptions
            {
                DefaultHeredocTag = "YYY"
            };

            var expected = @"MyAttr = <<-YYY
        a
        b
    YYY";

            Execute(w => w.Write(new OclAttribute("MyAttr", "a\nb")), options)
            .Should()
            .Be(expected.ToUnixLineEndings());
        }
Exemplo n.º 3
0
        public void IndentOptionsAreUsed()
        {
            var options = new OclSerializerOptions
            {
                IndentChar  = '+',
                IndentDepth = 5
            };

            var block = new OclBlock("MyBlock")
            {
                new OclAttribute("Child", 5)
            };

            var expected = @"MyBlock {
+++++Child = 5
}";

            Execute(w => w.Write(block), options)
            .Should()
            .Be(expected.ToUnixLineEndings());
        }
Exemplo n.º 4
0
        public void BlockNamesCanBeDerivedFromTheBlocksTypeOrData()
        {
            var options = new OclSerializerOptions();

            options.Converters.Add(new DefaultBlockNameFromNamePropertyConverter());
            var obj = new
            {
                Sample = new SampleWithANameProperty
                {
                    Name = "The Name"
                }
            };

            new OclSerializer(options).ToOclDocument(obj)
            .Should()
            .Be(
                new OclDocument
            {
                new OclBlock("the_name")
            }
                );
        }