Example #1
0
        public void CreateObject_MapObjectToObject_Success()
        {
            var map = Map.Create("FooProfile", "BarProfile",
                                 MapItem.Create("Id", "Id", "Id"),
                                 MapItem.Create("Name", "FooName", "BarName"));

            var fooProfile = Profile.Create("FooProfile",
                                            ProfileProperty.Create("Id"),
                                            ProfileProperty.Create("FooName"));

            var barProfile = Profile.Create("BarProfile",
                                            ProfileProperty.Create("Id"),
                                            ProfileProperty.Create("BarName"));


            var client = MapperClient.Create(fooProfile, barProfile);

            var foo = new Foo()
            {
                Id      = 1,
                FooName = "Hello World!"
            };

            var bar = new Bar();


            bar = client.Map(foo, bar, map);

            Assert.AreEqual(foo.Id, bar.Id);
            Assert.AreEqual(foo.FooName, bar.BarName);
        }
Example #2
0
        public void CreateObject_MapFullObjectToFullObject_Success()
        {
            var foo = new Foo();


            foo.FooName            = "Hello World!";
            foo.Id                 = 1;
            foo.Child.FooChildName = "Foo Child";

            var bar = new Bar();

            var map = Map.Create("FooProfile", "BarProfile",
                                 "Id Id Id",
                                 "Name FooName BarName",
                                 "ChildName Child.FooChildName Child.BarChildName");

            var client = MapperClient.Create("FooProfile:Id FooName Child.FooChildName",
                                             "BarProfile:Id BarName Child.BarChildName");

            bar = client.Map(foo, bar, map);

            Assert.AreEqual(foo.Id, bar.Id);
            Assert.AreEqual(foo.FooName, bar.BarName);
            Assert.AreEqual(foo.Child.FooChildName, bar.Child.BarChildName);
        }
Example #3
0
        public void CreateObject_MapChildToChild_Success()
        {
            var foo = new Foo();

            foo.Child.FooChildName = "Hello World!";

            var bar = new Bar();

            var map = Map.Create("FooProfile", "BarProfile",
                                 MapItem.Create("Name", "Child.FooChildName", "Child.BarChildName"));

            var fooProfile = Profile.Create("FooProfile",
                                            ProfileProperty.Create("Child.FooChildName"));

            var barProfile = Profile.Create("BarProfile",
                                            ProfileProperty.Create("Child.BarChildName"));

            var client = MapperClient.Create(fooProfile, barProfile);

            bar = client.Map(foo, bar, map);

            Assert.AreEqual(foo.Child.FooChildName, bar.Child.BarChildName);
        }