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"); }
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"); }
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"); }
private BlockWritingContext contextFor(Expression <Func <WritingTarget, object> > expression, WritingTarget target) { return(BlockWritingContext.ContextFor(expression, target)); }