public void TestDefaultContainer5() { string naming = "test naming"; var mapper = FactoryMapper.MakeDefaultBuilder <PersonaGiuridica, PersonDetails>() .Exclude("Code") .Exclude("Name") .Include( new PropertyMapper <PersonaGiuridica, PersonDetails>( (giuridica, details) => details.UpdateNome(naming))) .BuildMapper(); PersonaGiuridica person = new PersonaGiuridica { Code = "150", Name = "Sergio", Surname = "Hill", AnnoNascita = 1980, Parent = new Person { Name = "fatherName", Surname = "fatherSurname", AnnoNascita = 1950 } }; var res = mapper.Map(person); Assert.IsNotNull(mapper); Assert.IsNull(res.Code); Assert.AreEqual(res.Name, naming); }
public void Test3() { Type t1 = typeof(ISimpleMapper <Student, Person>); Type t2 = typeof(ISourceMapper <Student, Person>); Assert.IsTrue(t1.IsAssignableFrom(t2)); Assert.IsFalse(t2.IsSubclassOf(t1)); Person p1 = new Person(); PersonaGiuridica p2 = new PersonaGiuridica(); Type t0 = p1.GetType(); Assert.IsTrue(t0.IsInstanceOfType(p1)); Assert.IsTrue(t0.IsInstanceOfType(p2)); }
public void TestNonGenericMapper1() { ISourceMapper mapper = FactoryMapper.DynamicResolutionMapper(typeof(PersonaGiuridica), typeof(PersonDetails)); PersonaGiuridica person = new PersonaGiuridica { Code = "150", Name = "Sergio", Surname = "Hill", AnnoNascita = 1980, Parent = new Person { Name = "fatherName", Surname = "fatherSurname", AnnoNascita = 1950 } }; var result = mapper.Map(person); Assert.IsNotNull(result); }
public void TestMapperNonPublicMembers() { ISourceMapper <PersonaGiuridica, PersonDetails> mapper = FactoryMapper.DynamicResolutionMapper <PersonaGiuridica, PersonDetails>(); PersonaGiuridica person = new PersonaGiuridica { Code = "150", Name = "Sergio", Surname = "Hill", AnnoNascita = 1980, Parent = new Person { Name = "fatherName", Surname = "fatherSurname", AnnoNascita = 1950 } }; var result = mapper.Map(person); Assert.IsNotNull(result); }
public void TestAutoMapper2() { Mapper.CreateMap <Person, PersonaGiuridica>(); Person p = new Person { AnnoNascita = 1980, Name = "ciccio", Surname = "pasticcio", Parent = new Person { Name = "fatherCiccio", Surname = "surnamefather", AnnoNascita = 1940 } }; PersonaGiuridica giu = Mapper.Map <Person, PersonaGiuridica>(p); Assert.IsNotNull(giu); }
public void TestDefaultContainer6() { var mapper = FactoryMapper.MakeDefaultBuilder <PersonaGiuridica, PersonDetails>() .Exclude(typeof(PersonDetails).GetProperty("Code")) .BuildMapper(); PersonaGiuridica person = new PersonaGiuridica { Code = "150", Name = "Sergio", Surname = "Hill", AnnoNascita = 1980, Parent = new Person { Name = "fatherName", Surname = "fatherSurname", AnnoNascita = 1950 } }; var res = mapper.Map(person); Assert.IsNotNull(mapper); Assert.IsNull(res.Code); }