Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

unittest servicector automapper

public TestsCtor()
{
    _fixture = new Fixture().Customize(new AutoMoqCustomization());
    var converterLogger = _fixture.Freeze<Mock<ILogger<MyTypeConverter>>>();
    var automapperServiceCtor = _fixture.Freeze<Mock<Func<Type, object>>>();
    automapperServiceCtor.Setup(x => x.Invoke(typeof(ILogger<MyTypeConverter>))).Returns(converterLogger.Object);
    var mapperConfig = new MapperConfiguration(cfg => {
        cfg.ConstructServicesUsing(automapperServiceCtor.Object);
        cfg.AddProfile<AutoMapperConfig>(); 
    });
    _mapper = new Mapper(mapperConfig);
}
 
PREVIOUS NEXT
Tagged: #unittest #servicector #automapper
ADD COMMENT
Topic
Name
2+9 =