public void BeforeScenario()
 {
     // "You should avoid using DI in unit testing" - from: http://stackoverflow.com/a/11093830/177710
     // That's why there's no Autofac here.
     _context.DatabaseContext = new DatabaseContext(CreateNewDatabase());
     _fakeEmailService        = new FakeEmailService(_context.DatabaseContext);
     AutoMapperBootstrap.Initialize();
 }
Exemplo n.º 2
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     AutofacConfig.RegisterDependencies();
     WebApiConfig.Register(GlobalConfiguration.Configuration);
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     AuthConfig.RegisterAuth();
     AutoMapperBootstrap.Initialize();
 }
 public void LoadDependencies()
 {
     _serviceCollection.AddTransient <IObjectMapper, AutoMapperObjectMapper>();
     _serviceCollection.AddSingleton(AutoMapperBootstrap.GetConfiguration());
 }
Exemplo n.º 4
0
 /// <summary>
 /// 添加AutoMapper注入支持
 /// </summary>
 /// <param name="services">服务容器</param>
 /// <param name="searchPattern">程序集匹配范围</param>
 /// <returns></returns>
 public static void AddAutoMapper(this IServiceCollection services, string searchPattern)
 {
     services.AddSingleton(c => Mapper.Instance);
     AutoMapperBootstrap.Initialize(searchPattern);
 }
Exemplo n.º 5
0
 protected void Application_Start(object sender, EventArgs e)
 {
     AutoMapperBootstrap.InitializeMap();
 }