[Fact] // CodePlex 1192 public void CreateDatabase_throws_if_Migrations_is_configured() { var creator = new DatabaseCreator( DbConfiguration.DependencyResolver, new MigrationsChecker(c => true)); Assert.Equal( Strings.DatabaseInitializationStrategy_MigrationsEnabled("FakeContextProxy"), Assert.Throws <InvalidOperationException>( () => creator.CreateDatabase(CreateMockContextForMigrator().Object, (_, __) => null, null)).Message); }
public void GetMigrationsConfiguration_creates_a_new_configuration() { var mockContext = new Mock <InternalContext>(new FakeContext(), null); mockContext.Setup(m => m.OwnerShortTypeName).Returns("Key"); mockContext.Setup(m => m.OriginalConnectionString).Returns("Database=Foo"); mockContext.Setup(m => m.ProviderName).Returns("Some.Provider"); mockContext.Setup(m => m.CommandTimeout).Returns(123); var configuration = DatabaseCreator.GetMigrationsConfiguration(mockContext.Object); Assert.Same(typeof(FakeContext), configuration.ContextType); Assert.True(configuration.AutomaticMigrationsEnabled); Assert.False(configuration.AutomaticMigrationDataLossAllowed); Assert.Same(typeof(FakeContext).Assembly, configuration.MigrationsAssembly); Assert.Equal(typeof(FakeContext).Namespace, configuration.MigrationsNamespace); Assert.Equal("Key", configuration.ContextKey); Assert.Equal(123, configuration.CommandTimeout); }
public void IsMigrationsConfigured_returns_false_if_no_DbMigrationsConfiguration_can_be_discovered() { Assert.False(DatabaseCreator.IsMigrationsConfigured(typeof(FakeContext))); }
public void IsMigrationsConfigured_returns_true_if_DbMigrationsConfiguration_is_discovered() { Assert.True(DatabaseCreator.IsMigrationsConfigured(typeof(ContextWithMigrations))); }