public void GetHistoryContextFactory_should_return_root_service_when_not_locally_registered() { var migrationsConfiguration = new TestMigrationsConfiguration(); var historyContextFactory = migrationsConfiguration .GetHistoryContextFactory(ProviderRegistry.Sql2008_ProviderInfo.ProviderInvariantName); Assert.NotNull(historyContextFactory); Assert.Same(DbConfiguration.DependencyResolver.GetService<Func<DbConnection, string, HistoryContext>>(), historyContextFactory); }
public void Can_get_and_set_local_history_context_factory() { var migrationsConfiguration = new TestMigrationsConfiguration(); Func<DbConnection, string, HistoryContext> factory = (c, s) => new HistoryContext(c, s); migrationsConfiguration.SetHistoryContextFactory("Foo", factory); Assert.Same(factory, migrationsConfiguration.GetHistoryContextFactory("Foo")); }
public void GetHistoryContextFactory_should_return_root_service_when_not_locally_registered() { var migrationsConfiguration = new TestMigrationsConfiguration(); var historyContextFactory = migrationsConfiguration .GetHistoryContextFactory(ProviderRegistry.Sql2008_ProviderInfo.ProviderInvariantName); Assert.NotNull(historyContextFactory); Assert.Same(DbConfiguration.DependencyResolver.GetService <Func <DbConnection, string, HistoryContext> >(), historyContextFactory); }
public void Can_get_and_set_local_history_context_factory() { var migrationsConfiguration = new TestMigrationsConfiguration(); Func <DbConnection, string, HistoryContext> factory = (c, s) => new HistoryContext(c, s); migrationsConfiguration.SetHistoryContextFactory("Foo", factory); Assert.Same(factory, migrationsConfiguration.GetHistoryContextFactory("Foo")); }
public void GetHistoryContextFactory_should_return_per_provider_service_when_not_locally_registered() { var migrationsConfiguration = new TestMigrationsConfiguration(); try { Func <DbConnection, string, HistoryContext> factory = (c, s) => new HistoryContext(c, s); MutableResolver.AddResolver <Func <DbConnection, string, HistoryContext> >(_ => factory); Assert.Same(factory, migrationsConfiguration.GetHistoryContextFactory("Foo")); } finally { MutableResolver.ClearResolvers(); } }
public void GetHistoryContextFactory_should_return_per_provider_service_when_not_locally_registered() { var migrationsConfiguration = new TestMigrationsConfiguration(); try { Func<DbConnection, string, HistoryContext> factory = (c, s) => new HistoryContext(c, s); MutableResolver.AddResolver<Func<DbConnection, string, HistoryContext>>(_ => factory); Assert.Same(factory, migrationsConfiguration.GetHistoryContextFactory("Foo")); } finally { MutableResolver.ClearResolvers(); } }