public RootDependencyResolver( DefaultProviderServicesResolver defaultProviderServicesResolver, DatabaseInitializerResolver databaseInitializerResolver) { DebugCheck.NotNull(defaultProviderServicesResolver); DebugCheck.NotNull(databaseInitializerResolver); _databaseInitializerResolver = databaseInitializerResolver; _resolvers.Add(_databaseInitializerResolver); _resolvers.Add( new TransientDependencyResolver <MigrationSqlGenerator>( () => new SqlServerMigrationSqlGenerator(), "System.Data.SqlClient")); _resolvers.Add( new TransientDependencyResolver <MigrationSqlGenerator>( () => new SqlCeMigrationSqlGenerator(), "System.Data.SqlServerCe.4.0")); _resolvers.Add(new CachingDependencyResolver(defaultProviderServicesResolver)); _resolvers.Add(new SingletonDependencyResolver <IDbConnectionFactory>(new SqlConnectionFactory())); _resolvers.Add(new SingletonDependencyResolver <IDbModelCacheKeyFactory>(new DefaultModelCacheKeyFactory())); _resolvers.Add(new SingletonDependencyResolver <IManifestTokenService>(new DefaultManifestTokenService())); _resolvers.Add(new SingletonDependencyResolver <IHistoryContextFactory>(new DefaultHistoryContextFactory())); _resolvers.Add(new ThreadLocalDependencyResolver <IDbCommandInterceptor>(() => new DefaultCommandInterceptor())); _resolvers.Add(new SingletonDependencyResolver <IDbProviderFactoryService>(new DefaultDbProviderFactoryService())); }
public RootDependencyResolver( DefaultProviderServicesResolver defaultProviderServicesResolver, DatabaseInitializerResolver databaseInitializerResolver) { DebugCheck.NotNull(defaultProviderServicesResolver); DebugCheck.NotNull(databaseInitializerResolver); _databaseInitializerResolver = databaseInitializerResolver; _resolvers.Add(_databaseInitializerResolver); _resolvers.Add(new DefaultExecutionStrategyResolver()); _resolvers.Add(new CachingDependencyResolver(defaultProviderServicesResolver)); _resolvers.Add(new CachingDependencyResolver(new DefaultProviderFactoryResolver())); _resolvers.Add(new CachingDependencyResolver(new DefaultInvariantNameResolver())); _resolvers.Add(new SingletonDependencyResolver <IDbConnectionFactory>(new SqlConnectionFactory())); _resolvers.Add(new SingletonDependencyResolver <IDbModelCacheKeyFactory>(new DefaultModelCacheKeyFactory())); _resolvers.Add(new SingletonDependencyResolver <IManifestTokenService>(new DefaultManifestTokenService())); _resolvers.Add(new SingletonDependencyResolver <HistoryContextFactory>((e, d) => new HistoryContext(e, d))); _resolvers.Add(new SingletonDependencyResolver <IPluralizationService>(new EnglishPluralizationService())); _resolvers.Add(new SingletonDependencyResolver <IViewAssemblyCache>(new ViewAssemblyCache())); _resolvers.Add(new SingletonDependencyResolver <AttributeProvider>(new AttributeProvider())); #if NET40 _resolvers.Add(new SingletonDependencyResolver <IDbProviderFactoryService>(new Net40DefaultDbProviderFactoryService())); #else _resolvers.Add(new SingletonDependencyResolver <IDbProviderFactoryService>(new DefaultDbProviderFactoryService())); #endif }
private static DatabaseInitializerResolver CreateResolver(IDatabaseInitializer<FakeContext1> initializer = null) { var resolver = new DatabaseInitializerResolver(); resolver.SetInitializer(typeof(FakeContext1), initializer ?? new Mock<IDatabaseInitializer<FakeContext1>>().Object); resolver.SetInitializer(typeof(FakeContext2), new Mock<IDatabaseInitializer<FakeContext2>>().Object); return resolver; }
public RootDependencyResolver( DefaultProviderServicesResolver defaultProviderServicesResolver, DatabaseInitializerResolver databaseInitializerResolver) { DebugCheck.NotNull(defaultProviderServicesResolver); DebugCheck.NotNull(databaseInitializerResolver); _databaseInitializerResolver = databaseInitializerResolver; _resolvers.Add(_databaseInitializerResolver); _resolvers.Add(new DefaultExecutionStrategyResolver()); _resolvers.Add(new CachingDependencyResolver(defaultProviderServicesResolver)); _resolvers.Add(new CachingDependencyResolver(new DefaultProviderFactoryResolver())); _resolvers.Add(new CachingDependencyResolver(new DefaultInvariantNameResolver())); _resolvers.Add(new SingletonDependencyResolver<IDbConnectionFactory>(new SqlConnectionFactory())); _resolvers.Add(new SingletonDependencyResolver<IDbModelCacheKeyFactory>(new DefaultModelCacheKeyFactory())); _resolvers.Add(new SingletonDependencyResolver<IManifestTokenService>(new DefaultManifestTokenService())); _resolvers.Add(new SingletonDependencyResolver<HistoryContextFactory>((e, d) => new HistoryContext(e, d))); _resolvers.Add(new SingletonDependencyResolver<IPluralizationService>(new EnglishPluralizationService())); _resolvers.Add(new SingletonDependencyResolver<IViewAssemblyCache>(new ViewAssemblyCache())); _resolvers.Add(new SingletonDependencyResolver<AttributeProvider>(new AttributeProvider())); #if NET40 _resolvers.Add(new SingletonDependencyResolver<IDbProviderFactoryService>(new Net40DefaultDbProviderFactoryService())); #else _resolvers.Add(new SingletonDependencyResolver<IDbProviderFactoryService>(new DefaultDbProviderFactoryService())); #endif }
public RootDependencyResolver( DefaultProviderServicesResolver defaultProviderServicesResolver, DatabaseInitializerResolver databaseInitializerResolver) { DebugCheck.NotNull(defaultProviderServicesResolver); DebugCheck.NotNull(databaseInitializerResolver); _databaseInitializerResolver = databaseInitializerResolver; _resolvers.Add(_databaseInitializerResolver); _resolvers.Add( new TransientDependencyResolver<MigrationSqlGenerator>( () => new SqlServerMigrationSqlGenerator(), "System.Data.SqlClient")); _resolvers.Add( new TransientDependencyResolver<MigrationSqlGenerator>( () => new SqlCeMigrationSqlGenerator(), "System.Data.SqlServerCe.4.0")); _resolvers.Add(new CachingDependencyResolver(defaultProviderServicesResolver)); _resolvers.Add(new SingletonDependencyResolver<IDbConnectionFactory>(new SqlConnectionFactory())); _resolvers.Add(new SingletonDependencyResolver<IDbModelCacheKeyFactory>(new DefaultModelCacheKeyFactory())); _resolvers.Add(new SingletonDependencyResolver<IManifestTokenService>(new DefaultManifestTokenService())); _resolvers.Add(new SingletonDependencyResolver<IHistoryContextFactory>(new DefaultHistoryContextFactory())); _resolvers.Add(new ThreadLocalDependencyResolver<IDbCommandInterceptor>(() => new DefaultCommandInterceptor())); _resolvers.Add(new SingletonDependencyResolver<IDbProviderFactoryService>(new DefaultDbProviderFactoryService())); }
private static DatabaseInitializerResolver CreateResolver(IDatabaseInitializer <FakeContext1> initializer = null) { var resolver = new DatabaseInitializerResolver(); resolver.SetInitializer(typeof(FakeContext1), initializer ?? new Mock <IDatabaseInitializer <FakeContext1> >().Object); resolver.SetInitializer(typeof(FakeContext2), new Mock <IDatabaseInitializer <FakeContext2> >().Object); return(resolver); }
public void The_database_initializer_resolver_can_be_obtained_from_the_root_resolver() { var initializerResolver = new DatabaseInitializerResolver(); Assert.Same( initializerResolver, new RootDependencyResolver( new DefaultProviderServicesResolver(), initializerResolver) .DatabaseInitializerResolver); }
public void The_database_initializer_resolver_can_be_obtained_from_the_root_resolver() { var initializerResolver = new DatabaseInitializerResolver(); Assert.Same( initializerResolver, new RootDependencyResolver( new DefaultProviderServicesResolver(), initializerResolver) .DatabaseInitializerResolver); }
public RootDependencyResolver( MigrationsConfigurationResolver migrationsConfigurationResolver, DefaultProviderServicesResolver defaultProviderServicesResolver, DatabaseInitializerResolver databaseInitializerResolver) { Contract.Requires(migrationsConfigurationResolver != null); Contract.Requires(defaultProviderServicesResolver != null); Contract.Requires(databaseInitializerResolver != null); _databaseInitializerResolver = databaseInitializerResolver; _resolvers.Add(_databaseInitializerResolver); _resolvers.Add(migrationsConfigurationResolver); _resolvers.Add(new CachingDependencyResolver(defaultProviderServicesResolver)); _resolvers.Add(new SingletonDependencyResolver<IDbConnectionFactory>(new SqlConnectionFactory())); _resolvers.Add(new SingletonDependencyResolver<IDbModelCacheKeyFactory>(new DefaultModelCacheKeyFactory())); }
public void GetService_can_be_accessed_from_multiple_threads_concurrently() { for (var i = 0; i < 30; i++) { var bag = new ConcurrentBag<IDatabaseInitializer<FakeContext1>>(); var resolver = new DatabaseInitializerResolver(); var initializer = new Mock<IDatabaseInitializer<FakeContext1>>().Object; ExecuteInParallel( () => { resolver.SetInitializer(typeof(FakeContext1), initializer); bag.Add(resolver.GetService<IDatabaseInitializer<FakeContext1>>()); }); Assert.Equal(20, bag.Count); Assert.True(bag.All(c => initializer == c)); } }
public void GetService_can_be_accessed_from_multiple_threads_concurrently() { for (var i = 0; i < 30; i++) { var bag = new ConcurrentBag <IDatabaseInitializer <FakeContext1> >(); var resolver = new DatabaseInitializerResolver(); var initializer = new Mock <IDatabaseInitializer <FakeContext1> >().Object; ExecuteInParallel( () => { resolver.SetInitializer(typeof(FakeContext1), initializer); bag.Add(resolver.GetService <IDatabaseInitializer <FakeContext1> >()); }); Assert.Equal(20, bag.Count); Assert.True(bag.All(c => initializer == c)); } }