Skip to content

Suggestion: IMapper.From should return IAdapterBuilder<TSource> not TypeAdapterBuilder<TSource> #376

@Ergamon

Description

@Ergamon

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);

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions