public void Reusable_mapper() { var map = new ReusableMapper(); SourceObject source = new SourceObject { Id = 27, Name = "Chris", Amount = 234.75m, }; TargetObject target = map.Transform(source); Assert.AreEqual(source.Id, target.CustomerId); Assert.AreEqual(source.Name, target.DisplayName); Assert.AreEqual(source.Amount, target.OrderAmount); var xml = map.WhatAmIDoing(); Assert.AreEqual("<transform from=\"Magnum.Specs.SourceObject\" to=\"Magnum.Specs.TargetObject\">\r\n <map from=\"Id\" to=\"CustomerId\" />\r\n <map from=\"Name\" to=\"DisplayName\" />\r\n <map from=\"Amount\" to=\"OrderAmount\" />\r\n</transform>\r\n", xml); }
public void It_should_just_work() { var map = new Mapper <SourceObject, TargetObject>(); map.From(x => x.Id).To(y => y.CustomerId); map.From(x => x.Name).To(y => y.DisplayName); map.From(x => x.Amount).To(y => y.OrderAmount); SourceObject source = new SourceObject { Id = 27, Name = "Chris", Amount = 234.75m, }; TargetObject target = map.Transform(source); Assert.AreEqual(source.Id, target.CustomerId); Assert.AreEqual(source.Name, target.DisplayName); Assert.AreEqual(source.Amount, target.OrderAmount); }