Created a extension method on IMapper as below:
public static AutoMapperTypeConverterAssertions<TDestinationModel>ForType<TDestinationModel>(this IMapper subject)
{
return new AutoMapperTypeConverterAssertions<TDestinationModel>(subject);
}
public class AutoMapperTypeConverterAssertions<TDestinationModel> : ReferenceTypeAssertions<object, AutoMapperTypeConverterAssertions<TDestinationModel>>
{
public AutoMapperTypeConverterAssertions(object subject)
{
Subject = subject;
}
protected override string Context => "auto mapper type converter";
public AndConstraint<AutoMapperTypeConverterAssertions<TDestinationModel>> ShouldHaveTypeConverterApplied<TSourceModel, TConverterType>(
string because = "", params object[] becauseArgs)
{
var mapper = Subject as IMapper;
var foundTypeInConfig = mapper
.ConfigurationProvider
.FindTypeMapFor<TSourceModel, TDestinationModel>()
.TypeConverterType;
Execute.Assertion
.BecauseOf(because, becauseArgs)
.ForCondition(foundTypeInConfig == typeof(TConverterType))
.FailWith("Expected the mapping for {0} to contain {1} AutoMapper Type Converter, but was not found.", typeof(TDestinationModel).Name, typeof(TConverterType).Name);
}
return new AndConstraint<AutoMapperTypeConverterAssertions<TDestinationModel>>(this);
}