예제 #1
0
        public void DropCreateDatabaseIfModelChanges_initializes_if_database_exists_and_model_does_not_match_with_Migrations_enabled()
        {
            var tracker = new DatabaseInitializerTracker <FakeNoRegContext, DropCreateDatabaseIfModelChanges <FakeNoRegContext> >(
                databaseExists: true, modelCompatible: false, migrationsConfigured: true);

            tracker.ExecuteStrategy();

            Assert.Equal("Exists Exists Delete CreateDatabase Seed", tracker.Result);
        }
예제 #2
0
        [Fact] // CodePlex 1192
        public void CreateDatabaseIfNotExists_does_nothing_if_database_exists_but_has_no_metadata_with_Migrations_enabled()
        {
            var tracker = new DatabaseInitializerTracker <FakeNoRegContext, CreateDatabaseIfNotExists <FakeNoRegContext> >(
                databaseExists: true, modelCompatible: true, hasMetadata: false, migrationsConfigured: true);

            tracker.ExecuteStrategy();

            Assert.Equal("Exists", tracker.Result);
        }
예제 #3
0
        public void DropCreateDatabaseIfModelChanges_creates_and_seeds_database_if_not_exists()
        {
            var tracker =
                new DatabaseInitializerTracker <FakeNoRegContext, DropCreateDatabaseIfModelChanges <FakeNoRegContext> >(databaseExists: false);

            tracker.ExecuteStrategy();

            Assert.Equal("Exists CreateDatabase Seed", tracker.Result);
        }
예제 #4
0
        public void CreateDatabaseIfNotExists_throws_if_database_exists_and_model_does_not_match()
        {
            var tracker = new DatabaseInitializerTracker <FakeNoRegContext, CreateDatabaseIfNotExists <FakeNoRegContext> >(
                databaseExists: true, modelCompatible: false);

            Assert.Equal(
                Strings.DatabaseInitializationStrategy_ModelMismatch(tracker.Context.GetType().Name),
                Assert.Throws <InvalidOperationException>(() => tracker.ExecuteStrategy()).Message);
        }
예제 #5
0
        public void CreateDatabaseIfNotExists_initializes_if_database_does_not_exist_and_Migrations_is_enabled()
        {
            var tracker = new DatabaseInitializerTracker <FakeNoRegContext, CreateDatabaseIfNotExists <FakeNoRegContext> >(
                databaseExists: false, migrationsConfigured: true);

            tracker.ExecuteStrategy();

            Assert.Equal("Exists CreateDatabase Seed", tracker.Result);
        }
예제 #6
0
        public void DropCreateDatabaseAlways_initializes_if_Migrations_is_configured_and_database_does_not_exist()
        {
            var tracker = new DatabaseInitializerTracker <FakeNoRegContext, DropCreateDatabaseAlways <FakeNoRegContext> >(
                databaseExists: false, migrationsConfigured: true);

            tracker.ExecuteStrategy();

            Assert.Equal("Exists CreateDatabase Seed", tracker.Result);
        }
예제 #7
0
        public void CreateDatabaseIfNotExists_does_nothing_if_database_exists_and_model_matches()
        {
            var tracker = new DatabaseInitializerTracker <FakeNoRegContext, CreateDatabaseIfNotExists <FakeNoRegContext> >(
                databaseExists: true, modelCompatible: true);

            tracker.ExecuteStrategy();

            Assert.Equal("Exists", tracker.Result);
        }
예제 #8
0
        public void DropCreateDatabaseAlways_performs_delete_create_and_seeding()
        {
            var tracker = new DatabaseInitializerTracker <FakeNoRegContext, DropCreateDatabaseAlways <FakeNoRegContext> >(
                databaseExists: false);

            tracker.ExecuteStrategy();

            Assert.Equal("Exists CreateDatabase Seed", tracker.Result);
        }
예제 #9
0
        public void DropCreateDatabaseAlways_performs_delete_create_and_seeding_even_if_database_exists_and_model_matches()
        {
            var tracker = new DatabaseInitializerTracker <FakeNoRegContext, DropCreateDatabaseAlways <FakeNoRegContext> >(
                databaseExists: true, modelCompatible: true);

            tracker.ExecuteStrategy();

            Assert.Equal("Exists Delete CreateDatabase Seed", tracker.Result);
        }
예제 #10
0
        [Fact] // CodePlex 1192
        public void DropCreateDatabaseIfModelChanges_does_nothing_if_database_exists_and_model_is_up_to_date_with_Migrations_enabled()
        {
            var tracker = new DatabaseInitializerTracker <FakeNoRegContext, DropCreateDatabaseIfModelChanges <FakeNoRegContext> >(
                databaseExists: true, modelCompatible: true, checker: new MigrationsChecker(c => true));

            tracker.ExecuteStrategy();

            Assert.Equal("Exists", tracker.Result);
        }
예제 #11
0
        [Fact] // CodePlex 1192
        public void DropCreateDatabaseAlways_does_nothing_if_Migrations_is_configured_and_database_exists()
        {
            var tracker = new DatabaseInitializerTracker <FakeNoRegContext, DropCreateDatabaseAlways <FakeNoRegContext> >(
                databaseExists: true, modelCompatible: true, checker: new MigrationsChecker(c => true));

            tracker.ExecuteStrategy();

            Assert.Equal("Exists", tracker.Result);
        }
        public void DropCreateDatabaseIfModelChanges_recreates_database_if_database_exists_and_model_does_not_match()
        {
            var tracker =
                new DatabaseInitializerTracker <FakeNoRegContext, DropCreateDatabaseIfModelChanges <FakeNoRegContext> >(
                    databaseExists: true, modelCompatible: false);

            tracker.ExecuteStrategy();

            Assert.Equal("Exists DeleteIfExists CreateDatabase Seed", tracker.Result);
        }
예제 #13
0
        [Fact] // CodePlex 1192
        public void DropCreateDatabaseIfModelChanges_throws_if_database_exists_and_model_does_not_match_with_Migrations_enabled()
        {
            var tracker = new DatabaseInitializerTracker <FakeNoRegContext, DropCreateDatabaseIfModelChanges <FakeNoRegContext> >(
                databaseExists: true, modelCompatible: false, checker: new MigrationsChecker(c => true));

            Assert.Equal(
                Strings.DatabaseInitializationStrategy_ModelMismatch(tracker.Context.GetType().Name),
                Assert.Throws <InvalidOperationException>(() => tracker.ExecuteStrategy()).Message);

            Assert.Equal("Exists", tracker.Result);
        }
예제 #14
0
        [Fact] // CodePlex 1192
        public void DropCreateDatabaseIfModelChanges_throws_if_database_does_not_exist_and_Migrations_is_enabled()
        {
            var tracker = new DatabaseInitializerTracker <FakeNoRegContext, DropCreateDatabaseIfModelChanges <FakeNoRegContext> >(
                databaseExists: false, checker: new MigrationsChecker(c => true));

            Assert.Equal(
                Strings.DatabaseInitializationStrategy_MigrationsEnabled("FakeNoRegContextProxy"),
                Assert.Throws <InvalidOperationException>(() => tracker.ExecuteStrategy()).Message);

            Assert.Equal("Exists", tracker.Result);
        }
예제 #15
0
        [Fact] // CodePlex 1192
        public void DropCreateDatabaseIfModelChanges_throws_if_database_exists_but_has_no_metadata_with_Migrations_enabled()
        {
            var tracker =
                new DatabaseInitializerTracker <FakeNoRegContext, DropCreateDatabaseIfModelChanges <FakeNoRegContext> >(
                    databaseExists: true, modelCompatible: true, hasMetadata: false, migrationsConfigured: true);

            Assert.Equal(
                Strings.Database_NoDatabaseMetadata,
                Assert.Throws <NotSupportedException>(() => tracker.ExecuteStrategy()).Message);

            Assert.Equal("Exists", tracker.Result);
        }