Ejemplo n.º 1
0
        public void ValueTypeTest()
        {
            IMapperEmit m = AutoMapperEmit.Build(typeof(int), typeof(int));
            int         x = 1;
            int         i = (int)m.Map(x);

            Assert.AreEqual(x, i);
        }
Ejemplo n.º 2
0
        public void MapParametersTest()
        {
            IMapperEmit m = AutoMapperEmit.Build(typeof(Student), typeof(Course));
            Student     s = new Student {
                ImAField = "ImAField", Nickname = "Zezito", Nr = 27721, Name = "Ze Manel", Address = "Rua de Cima"
            };
            Course c = (Course)m.Map(s);

            Assert.AreEqual(s.Address, c.Address);
        }
Ejemplo n.º 3
0
        public void MapTest()
        {
            IMapperEmit m = AutoMapperEmit.Build(typeof(Student), typeof(Person));
            Student     s = new Student {
                Nr = 27721, Name = "Ze Manel"
            };
            Person p = (Person)m.Map(s);

            Assert.AreEqual(s.Name, p.Name);
        }
Ejemplo n.º 4
0
        public void MapByBindTest()
        {
            IMapperEmit m = AutoMapperEmit.Build(typeof(Student), typeof(Person))
                            .Bind(MappingEmit.Fields);
            Student s = new Student {
                ImAField = "ImAField", Nickname = "Zezito", Nr = 27721, Name = "Ze Manel"
            };
            Person p = (Person)m.Map(s);

            Assert.AreEqual(s.ImAField, p.ImAField);
        }
Ejemplo n.º 5
0
        public void MapCustomAttributeTest()
        {
            IMapperEmit m = AutoMapperEmit.Build(typeof(Student), typeof(Person))
                            .Bind(MappingEmit.CustomAttributes);
            Student s = new Student {
                ImAField = "ImAField", Nickname = "Zezito", Nr = 27721, Name = "Ze Manel"
            };
            Person p = (Person)m.Map(s);

            Assert.AreEqual(s.Nickname, p.Nickname);
        }
Ejemplo n.º 6
0
        public void MapArrayTest()
        {
            IMapperEmit m = AutoMapperEmit.Build(typeof(Student), typeof(Person));

            Student[] s = { new Student {
                                ImAField = "ImAField", Nickname = "Zezito", Nr = 27721, Name = "Ze Manel"
                            },
                            new Student {
                                ImAField = "ImAField", Nickname = "Xico", Nr = 27722, Name = "Francisco"
                            } };
            Person[]  p = (Person[])m.Map(s);
            for (int i = 0; i < p.Length; ++i)
            {
                Assert.AreEqual(s[i].Name, p[i].Name);
            }
        }
Ejemplo n.º 7
0
        public void MapByMatchTest()
        {
            int[]       array = { 27999, 27898, 27162 };
            IMapperEmit m     = AutoMapperEmit.Build(typeof(Student), typeof(Person))
                                .Match("Nr", "Id")
                                .Match("Org", "Org");
            Student s = new Student
            {
                ImAField = "ImAField",
                Nickname = "Zezito",
                Nr       = 27721,
                Name     = "Ze Manel",
                Org      = new School("Lisbon", array, "ISEL")
            };
            Person p = (Person)m.Map(s);

            Assert.AreEqual(s.Nr, p.Id);
            Assert.AreEqual(s.Org.Name, p.Org.Name);
        }