コード例 #1
0
        public void creates_the_property_block()
        {
            var target = new WritingTarget {
                StringProp = "Test"
            };
            var context = contextFor(x => x.StringProp, target);

            var block = new PropertyBlockWriter().Write(context).As <PropertyBlock>();

            block.Name.ShouldEqual("stringProp");
            block.Value.ShouldEqual("Test");
        }
コード例 #2
0
        public void creates_the_nested_block()
        {
            var target = new WritingTarget
            {
                Nested = new WritingTarget
                {
                    StringProp = "Test"
                }
            };

            var context = contextFor(x => x.Nested, target);

            var block = new NestedBlockWriter().Write(context).As <ObjectBlock>();

            block.Name.ShouldEqual("nested");
        }
コード例 #3
0
        public void creates_the_collection_block()
        {
            var target = new WritingTarget
            {
                Collection = new List <WritingTarget>()
                {
                    new WritingTarget {
                        StringProp = "One"
                    },
                    new WritingTarget {
                        StringProp = "Two"
                    }
                }
            };

            var context = contextFor(x => x.Collection, target);

            var block = new CollectionBlockWriter().Write(context).As <CollectionBlock>();

            block.Name.ShouldEqual("collection");

            block.Blocks[0].As <ObjectBlock>().Blocks[0].As <PropertyBlock>().Value.ShouldEqual("One");
            block.Blocks[1].As <ObjectBlock>().Blocks[0].As <PropertyBlock>().Value.ShouldEqual("Two");
        }
コード例 #4
0
 private BlockWritingContext contextFor(Expression <Func <WritingTarget, object> > expression, WritingTarget target)
 {
     return(BlockWritingContext.ContextFor(expression, target));
 }