コード例 #1
0
        public void with_the_camel_casing_correction()
        {
            var projection = new Projection <SomeTarget>();

            projection.CamelCaseAttributeNames();
            projection.Value(x => x.Name);
            projection.Value(x => x.Age);
            projection.Child(x => x.Child).Configure(_ => {
                _.Value(x => x.Name);
            });



            var node       = new DictionaryMediaNode();
            var someTarget = new SomeTarget
            {
                Active = true,
                Age    = 40,
                Name   = "Jeremy",
                Child  = new SomeChild {
                    Name = "Max"
                }
            };

            projection.As <IProjection <SomeTarget> >().Write(new ProjectionContext <SomeTarget>(new InMemoryServiceLocator(), someTarget), node);

            node.Values["name"].ShouldEqual("Jeremy");
            node.Values["age"].ShouldEqual(40);

            node.Values["child"].As <IDictionary <string, object> >()["name"].ShouldEqual("Max");
        }
コード例 #2
0
        public void with_the_camel_casing_correction()
        {
            var projection = new Projection<SomeTarget>();

            projection.CamelCaseAttributeNames();
            projection.Value(x => x.Name);
            projection.Value(x => x.Age);
            projection.Child(x => x.Child).Configure(_ => {
                _.Value(x => x.Name);
            });

            var node = new DictionaryMediaNode();
            var someTarget = new SomeTarget
            {
                Active = true,
                Age = 40,
                Name = "Jeremy",
                Child =  new SomeChild{Name = "Max"}
            };

            projection.As<IProjection<SomeTarget>>().Write(new ProjectionContext<SomeTarget>(new InMemoryServiceLocator(), someTarget), node);

            node.Values["name"].ShouldEqual("Jeremy");
            node.Values["age"].ShouldEqual(40);

            node.Values["child"].As<IDictionary<string, object>>()["name"].ShouldEqual("Max");
        }