public void Map_PropertiesWithNumberTypes_ReaturnsRightMappedObject() { Source2 source = new Source2() { Prop1 = 5, Prop2 = 87.0 }; Destination2 etalon = new Destination2() { Prop1 = 5 }; Destination2 dest = mapper.Map <Source2, Destination2>(source); Assert.AreEqual(dest, etalon); }
public void OtherDefaultMapConfiguratorDemo() { Source2 source = new Source2 { Number = 1, UpdatedTime = "2015/6/2 08:49:40.570", Name = "Name来自源对象", EnglishName = "EnglishName来自源对象" }; ObjectsMapper <Source2, Destination2> mapper = ObjectMapperManager.DefaultInstance.GetMapper <Source2, Destination2>( new DefaultMapConfig() .MatchMembers((m1, m2) => "M" + m1 == m2) .ConstructBy <Destination2>(() => new Destination2(6)) .IgnoreMembers <Source2, Destination2>(new string[] { "Number" }) .NullSubstitution <decimal?, decimal>((value) => - 2M) .PostProcess <Destination2>((value, state) => { value.MRemark = "MRemark来自目标对象"; return(value); }) ); Destination2 destination = mapper.Map(source); }
protected override void Because_of() { _destination = Mapper.Map <Source, Destination>(new Source()); _destination1 = Mapper.Map <Source1, Destination1>(new Source1()); _destination2 = Mapper.Map <Source2, Destination2>(new Source2()); }
protected override void Because_of() { _destination = Mapper.Map<Source, Destination>(new Source()); _destination1 = Mapper.Map<Source1, Destination1>(new Source1()); _destination2 = Mapper.Map<Source2, Destination2>(new Source2()); }