示例#1
0
        public void SetUp()
        {
            theAccessorProjection = AccessorProjection <ValueTarget> .For(x => x.Age);

            _theValues = new SimpleValues <ValueTarget>(new ValueTarget
            {
                Age = 37
            });

            theMediaNode = XmlAttCentricMediaNode.ForRoot("root");
        }
        public void should_just_use_IProjectMyself_Project_in_accessor_projection()
        {
            var projection = AccessorProjection <ComplexValueHolder, ComplexValue> .For(x => x.Value);

            var target = new ComplexValueHolder
            {
                Value = new ComplexValue {
                    Name = "Jeremy", Age = 38
                }
            };

            var context = new ProjectionContext <ComplexValueHolder>(new InMemoryServiceLocator(), target);

            var node = new DictionaryMediaNode();

            projection.As <IProjection <ComplexValueHolder> >().Write(context, node);

            node.Values["Value"].As <IDictionary <string, object> >()["Name"].ShouldEqual("Jeremy");
            node.Values["Value"].As <IDictionary <string, object> >()["Age"].ShouldEqual(38);
        }
示例#3
0
        public void should_just_use_IValueProjector_when_overriden_in_accessor_projection()
        {
            var projection = AccessorProjection <CustomValueHolder, CustomValue> .For(x => x.Value);

            projection.ProjectWith <CustomValueProjector>();

            var target = new CustomValueHolder
            {
                Value = new CustomValue {
                    Name = "Jeremy", Age = 38
                }
            };

            var context = new ProjectionContext <CustomValueHolder>(new InMemoryServiceLocator(), target);

            var node = new DictionaryMediaNode();

            projection.As <IProjection <CustomValueHolder> >().Write(context, node);

            node.Values["Value"].As <IDictionary <string, object> >()["Name"].ShouldBe("Jeremy");
            node.Values["Value"].As <IDictionary <string, object> >()["Age"].ShouldBe(38);
        }