3
:AutoMapper 나는이 모듈을 사용하고 우선 들어
public class AutoMapperModule : NinjectModule
{
public override void Load()
{
Bind<ITypeMapFactory>().To<TypeMapFactory>();
foreach (var mapper in MapperRegistry.AllMappers())
{
Bind<IObjectMapper>().ToConstant(mapper);
}
Bind<AutoMapper.ConfigurationStore>().ToSelf().InSingletonScope().WithConstructorArgument("mappers", ctx => ctx.Kernel.GetAll<IObjectMapper>());
Bind<IConfiguration>().ToMethod(ctx => ctx.Kernel.Get<AutoMapper.ConfigurationStore>());
Bind<IConfigurationProvider>().ToMethod(ctx => ctx.Kernel.Get<AutoMapper.ConfigurationStore>());
Bind<IMappingEngine>().To<MappingEngine>();
}
}
내 모든 맵에 대한 부트 스트 래퍼 클래스가를
나는 데이터베이스에 액세스하고 저장소를 필요 리졸버가 public static void Configure(IKernel kernel)
{
Mapper.Initialize(map => map.ConstructServicesUsing(t => kernel.Get(t)));
}
주사되었다. 그것은 그대로 작동하지만 단위 테스트 및 IMappingEngine과 함께 작동시키는 방법을 알 수는 없습니다.
public HomeController(IMappingEngine mappingEngine)
{
_mappingEngine = mappingEngine;
}
지도가 없기 때문에 _mappingEngine.Map에서 예외가 발생합니다. 매퍼. 맵이 작동합니다.
무엇이 누락 되었습니까? 부트 스트 래퍼가 단위 테스트를 수행하도록 어떻게하면 리졸버가 저장소에 가짜/모의 저장소를 사용할 수 있습니까?