public void BasicTest() { var customer = GetCustomer(); var res = new CustomerInput(); res.InjectFrom <FlatLoopInjection>(customer); res.InjectFrom <UnflatLoopInjection>(customer); }
public void BasicTest() { var customer = GetCustomer(); var res = new CustomerInput(); res.InjectFrom <Omu.ValueInjecter.Delta.Injections.FlatLoopInjection>(customer); res.InjectFrom <Omu.ValueInjecter.Delta.Injections.UnflatLoopInjection>(customer); }
public void MapperInstance() { var customer = GetCustomer(); var mapper1 = new MapperInstance(); var mapper2 = new MapperInstance(); mapper1.AddMap <Customer, CustomerInput>((from) => { var input = new CustomerInput(); input.InjectFrom(from); return(input); }); mapper2.AddMap <Customer, CustomerInput>((from) => { var input = new CustomerInput(); input.FirstName = from.FirstName; return(input); }); var input1 = mapper1.Map <CustomerInput>(customer); var input2 = mapper2.Map <CustomerInput>(customer); Assert.AreEqual(customer.LastName, input1.LastName); Assert.AreEqual(null, input2.LastName); }
public void ShouldMapProxy() { var customerProxy = new CustomerProxy { FirstName = "c1", ProxyName = "proxy1", RegDate = DateTime.Now }; Mapper.AddMap <Customer, CustomerInput>(src => { var res = new CustomerInput(); res.InjectFrom(src); res.RegDate = src.RegDate.ToShortDateString(); return(res); }); var input = Mapper.Map <Customer, CustomerInput>(customerProxy); Assert.AreEqual(customerProxy.RegDate.ToShortDateString(), input.RegDate); Assert.AreEqual(customerProxy.FirstName, input.FirstName); }
public void PerformanceCheck() { const int Iterations = 10000; var customer = GetCustomer(); Mapper.AddMap <Customer, CustomerInput>(src => { var res = new CustomerInput(); res.InjectFrom(src); //res.RegDate = src.RegDate.ToShortDateString(); //res.RegDate = src.RegDate.tos; //res.FirstName = src.FirstName; //res.LastName = src.LastName; //res.Id = src.Id; return(res); }); var w = new Stopwatch(); w.Start(); var customerInput = Mapper.Map <CustomerInput>(customer); w.Stop(); Console.WriteLine("{0} one", w.Elapsed); w.Reset(); w.Start(); for (var i = 0; i < Iterations; i++) { Mapper.Map <Customer, CustomerInput>(customer); } w.Stop(); Console.WriteLine("{0} <T,T>", w.Elapsed); w.Reset(); w.Start(); for (var i = 0; i < Iterations; i++) { Mapper.Map <CustomerInput>(customer); } w.Stop(); Console.WriteLine("{0} loop", w.Elapsed); w.Reset(); w.Start(); Mapper.Map <CustomerInput>(customer); w.Stop(); Console.WriteLine("{0} one", w.Elapsed); w.Reset(); w.Start(); for (int i = 0; i < Iterations; i++) { var cc = new Customer(); cc.RegDate = customer.RegDate; cc.FirstName = customer.FirstName; cc.LastName = customer.LastName; cc.Id = customer.Id; } w.Stop(); Console.WriteLine("{0} manual", w.Elapsed); }