public void MappingFactory_KnownSourceAndTargetType_Create_ReturnsSameInstance() { var factory = new MappingFactory(typeof(UserToUserViewMap).Assembly); var mapper1 = factory.Create <User, UserView>(); var mapper2 = factory.Create <User, UserView>(); mapper1.ShouldBe(mapper2); }
public void MappingFactory_KnownSourceAndTargetType_Create_ReturnsInstance() { var factory = new MappingFactory(typeof(UserToUserViewMap).Assembly); var mapper = factory.Create <User, UserView>(); mapper.ShouldNotBeNull(); }
public void MappingFactory_UnknownSourceAndTargetType_Create_ReturnsNull() { var factory = new MappingFactory(typeof(MapBase).Assembly); var mapper = factory.Create <User, UserView>(); mapper.ShouldBeNull(); }
public void MappingFactory_ForAllMappings_GetAll_ReturnsSameInstanceAsCreate() { var factory = new MappingFactory(typeof(UserToUserViewMap).Assembly); var mapping1 = factory.Create <User, UserView>(); var mappings = factory.GetAll(); var mapping2 = mappings.First(); mapping2.ShouldBe(mapping1); }
public override TTarget Convert(TSource source) { var mapper = MappingFactory.Create <TSource, TTarget>(); return(mapper?.Map(source)); }