public void ValueTypeTest() { IMapperEmit m = AutoMapperEmit.Build(typeof(int), typeof(int)); int x = 1; int i = (int)m.Map(x); Assert.AreEqual(x, i); }
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); }
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); }
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); }
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); }
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); } }
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); }