Mapster
Mapster copied to clipboard
Suggestion: IMapper.From should return IAdapterBuilder<TSource> not TypeAdapterBuilder<TSource>
I have currently the following code
private readonly IMapper mapper; // Set by dependency injection
I can easily set up a mockup for IMapper and unit test the following code:
mapper.Map<TDestination>(source);
but how can I test
mapper.From(source).AddParameters("param", 42).AdaptToType<TDestination>();
In my opinion the interface should not return a concrete type, but also an abstraction.
public interface IMapper { TypeAdapterConfig Config { get; }
IAdapterBuilder<TSource> From<TSource>(TSource source); // Not TypeAdapterBuilder<TSource>
TDestination Map<TDestination>(object source);
TDestination Map<TSource, TDestination>(TSource source);
TDestination Map<TSource, TDestination>(TSource source, TDestination destination);
object Map(object source, Type sourceType, Type destinationType);
object Map(object source, object destination, Type sourceType, Type destinationType);
}
Class with internal constructor causes issues when using with NSubstitute