Esempio n. 1
0
        public void MapShouldMapCollectionPropertiesAndUseFooBarTypeMapper()
        {
            MapperFactory.AddMapper(new FooBar());
            var foo = new Foo
            {
                Foos = new List <Foo>
                {
                    new Foo {
                        Name = "f1", Props = "v", Xyz = 19
                    },
                    new Foo {
                        Name = "f2", Props = "i", Xyz = 7
                    },
                    new Foo {
                        Name = "f3", Props = "v", Xyz = 3
                    },
                }
            };

            var bar = Mapper.Map <Foo, Bar>(foo);

            Assert.AreEqual(foo.Foos.Count(), bar.Foos.Count());

            var ffoos = foo.Foos.ToArray();
            var bfoos = bar.Foos.ToArray();

            for (var i = 0; i < ffoos.Count(); i++)
            {
                Assert.AreEqual(ffoos[i].Name, bfoos[i].Name);
                Assert.AreEqual(ffoos[i].Name + ffoos[i].Xyz + ffoos[i].Props, bfoos[i].NoConvention);
            }
        }
Esempio n. 2
0
        public void MapShouldUseFooBarTypeMapperForMapping()
        {
            MapperFactory.AddMapper(new FooBar());
            var foo = new Foo {
                Name = "a", Props = "b", Xyz = 123
            };
            var bar = new Bar();

            Mapper.Map(foo, bar);

            Assert.AreEqual("a123b", bar.NoConvention);
            Assert.AreEqual(foo.Name, bar.Name);
        }