Esempio n. 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);
        }
Esempio n. 2
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);
        }