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(source);
but how can I test
mapper.From(source).AddParameters("param", 42).AdaptToType();
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);
}