Beispiel #1
0
        public void GetPendingMigrations_should_return_migrations_based_on_context_key()
        {
            ResetDatabase();

            var historyRepository1 = new HistoryRepository(Mock.Of <InternalContextForMock>(), ConnectionString, ProviderFactory, "MyKey1", null, HistoryContext.DefaultFactory);
            var historyRepository2 = new HistoryRepository(Mock.Of <InternalContextForMock>(), ConnectionString, ProviderFactory, "MyKey2", null, HistoryContext.DefaultFactory);

            using (var context = CreateContext <ShopContext_v1>())
            {
                var model = new VersionedModel(context.GetModel());

                ExecuteOperations(
                    GetCreateHistoryTableOperation(),
                    historyRepository1.CreateInsertOperation("Migration 1", model),
                    historyRepository2.CreateInsertOperation("Migration 1", model),
                    historyRepository1.CreateInsertOperation("Migration 3", model),
                    historyRepository1.CreateInsertOperation("Migration 5", model));
            }

            var pendingMigrations =
                historyRepository1.GetPendingMigrations(
                    new[] { "Migration 1", "Migration 2", "Migration 3", "Migration 4", "Migration 5" });

            Assert.Equal("Migration 2", pendingMigrations.First());
            Assert.Equal("Migration 4", pendingMigrations.Last());
        }
Beispiel #2
0
        public void GetPendingMigrations_should_return_empty_set_when_no_data()
        {
            ResetDatabase();

            var historyRepository = new HistoryRepository(Mock.Of <InternalContextForMock>(), ConnectionString, ProviderFactory, "MyKey", null, HistoryContext.DefaultFactory);

            Assert.False(historyRepository.GetPendingMigrations(Enumerable.Empty <string>()).Any());
        }
        public void GetPendingMigrations_should_return_empty_set_when_no_data()
        {
            ResetDatabase();

            var historyRepository = new HistoryRepository(ConnectionString, ProviderFactory, "MyKey");

            Assert.False(historyRepository.GetPendingMigrations(Enumerable.Empty <string>()).Any());
        }
        public void GetPendingMigrations_should_return_empty_set_when_no_database()
        {
            var historyRepository
                = new HistoryRepository(
                      ConnectionString.Replace(DatabaseProviderFixture.DefaultDatabaseName, "NoSuchDatabase"),
                      ProviderFactory, "MyKey", null, HistoryContext.DefaultFactory);

            Assert.False(historyRepository.GetPendingMigrations(Enumerable.Empty <string>()).Any());
        }
        public void GetPendingMigrations_should_ignore_InitialCreate_timestamps()
        {
            ResetDatabase();

            var historyRepository = new HistoryRepository(ConnectionString, ProviderFactory, "MyKey");

            var model = CreateContext <ShopContext_v1>().GetModel();

            ExecuteOperations(
                GetCreateHistoryTableOperation(),
                historyRepository.CreateInsertOperation("000000000000001_InitialCreate", model));

            var pendingMigrations = historyRepository.GetPendingMigrations(
                new[] { "000000000000002_InitialCreate", "Migration 1" });

            Assert.Equal("Migration 1", pendingMigrations.Single());
        }
Beispiel #6
0
        public void GetPendingMigrations_should_ignore_InitialCreate_timestamps()
        {
            ResetDatabase();

            var historyRepository = new HistoryRepository(Mock.Of <InternalContextForMock>(), ConnectionString, ProviderFactory, "MyKey", null, HistoryContext.DefaultFactory);

            using (var context = CreateContext <ShopContext_v1>())
            {
                var model = new VersionedModel(context.GetModel());

                ExecuteOperations(
                    GetCreateHistoryTableOperation(),
                    historyRepository.CreateInsertOperation("000000000000001_InitialCreate", model));
            }

            var pendingMigrations = historyRepository.GetPendingMigrations(
                new[] { "000000000000002_InitialCreate", "Migration 1" });

            Assert.Equal("Migration 1", pendingMigrations.Single());
        }
        public void GetPendingMigrations_should_return_migrations_not_in_input_set()
        {
            ResetDatabase();

            var historyRepository = new HistoryRepository(ConnectionString, ProviderFactory, "MyKey");

            var model = CreateContext <ShopContext_v1>().GetModel();

            ExecuteOperations(
                GetCreateHistoryTableOperation(),
                historyRepository.CreateInsertOperation("Migration 1", model),
                historyRepository.CreateInsertOperation("Migration 3", model),
                historyRepository.CreateInsertOperation("Migration 5", model));

            var pendingMigrations =
                historyRepository.GetPendingMigrations(
                    new[] { "Migration 1", "Migration 2", "Migration 3", "Migration 4", "Migration 5" });

            Assert.Equal("Migration 2", pendingMigrations.First());
            Assert.Equal("Migration 4", pendingMigrations.Last());
        }
        public void GetPendingMigrations_should_ignore_InitialCreate_timestamps()
        {
            ResetDatabase();

            var historyRepository = new HistoryRepository(ConnectionString, ProviderFactory, "MyKey", null);

            var model = CreateContext<ShopContext_v1>().GetModel();

            ExecuteOperations(
                GetCreateHistoryTableOperation(),
                historyRepository.CreateInsertOperation("000000000000001_InitialCreate", model));

            var pendingMigrations = historyRepository.GetPendingMigrations(
                new[] { "000000000000002_InitialCreate", "Migration 1" });

            Assert.Equal("Migration 1", pendingMigrations.Single());
        }
        public void GetPendingMigrations_should_return_migrations_based_on_context_key()
        {
            ResetDatabase();

            var historyRepository1 = new HistoryRepository(ConnectionString, ProviderFactory, "MyKey1", null);
            var historyRepository2 = new HistoryRepository(ConnectionString, ProviderFactory, "MyKey2", null);

            var model = CreateContext<ShopContext_v1>().GetModel();

            ExecuteOperations(
                GetCreateHistoryTableOperation(),
                historyRepository1.CreateInsertOperation("Migration 1", model),
                historyRepository2.CreateInsertOperation("Migration 1", model),
                historyRepository1.CreateInsertOperation("Migration 3", model),
                historyRepository1.CreateInsertOperation("Migration 5", model));

            var pendingMigrations =
                historyRepository1.GetPendingMigrations(
                    new[] { "Migration 1", "Migration 2", "Migration 3", "Migration 4", "Migration 5" });

            Assert.Equal("Migration 2", pendingMigrations.First());
            Assert.Equal("Migration 4", pendingMigrations.Last());
        }
        public void GetPendingMigrations_should_return_empty_set_when_no_data()
        {
            ResetDatabase();

            var historyRepository = new HistoryRepository(ConnectionString, ProviderFactory, "MyKey", null);

            Assert.False(historyRepository.GetPendingMigrations(Enumerable.Empty<string>()).Any());
        }
        public void GetPendingMigrations_should_return_empty_set_when_no_database()
        {
            var historyRepository
                = new HistoryRepository(
                    ConnectionString.Replace(DatabaseProviderFixture.DefaultDatabaseName, "NoSuchDatabase"),
                    ProviderFactory, "MyKey", null);

            Assert.False(historyRepository.GetPendingMigrations(Enumerable.Empty<string>()).Any());
        }
        public void GetPendingMigrations_should_return_migrations_not_in_input_set()
        {
            ResetDatabase();

            var historyRepository = new HistoryRepository(Mock.Of<InternalContextForMock>(), ConnectionString, ProviderFactory, "MyKey", null, HistoryContext.DefaultFactory);

            using (var context = CreateContext<ShopContext_v1>())
            {
                var model = context.GetModel();

                ExecuteOperations(
                    GetCreateHistoryTableOperation(),
                    historyRepository.CreateInsertOperation("Migration 1", model),
                    historyRepository.CreateInsertOperation("Migration 3", model),
                    historyRepository.CreateInsertOperation("Migration 5", model));
            }

            var pendingMigrations =
                historyRepository.GetPendingMigrations(
                    new[] { "Migration 1", "Migration 2", "Migration 3", "Migration 4", "Migration 5" });

            Assert.Equal("Migration 2", pendingMigrations.First());
            Assert.Equal("Migration 4", pendingMigrations.Last());
        }
        public void GetPendingMigrations_should_return_empty_set_when_no_data()
        {
            ResetDatabase();

            var historyRepository = new HistoryRepository(Mock.Of<InternalContextForMock>(), ConnectionString, ProviderFactory, "MyKey", null, HistoryContext.DefaultFactory);

            Assert.False(historyRepository.GetPendingMigrations(Enumerable.Empty<string>()).Any());
        }
        public void GetPendingMigrations_should_ignore_InitialCreate_timestamps()
        {
            ResetDatabase();

            var historyRepository = new HistoryRepository(Mock.Of<InternalContextForMock>(), ConnectionString, ProviderFactory, "MyKey", null, HistoryContext.DefaultFactory);

            using (var context = CreateContext<ShopContext_v1>())
            {
                var model = new VersionedModel(context.GetModel());

                ExecuteOperations(
                    GetCreateHistoryTableOperation(),
                    historyRepository.CreateInsertOperation("000000000000001_InitialCreate", model));
            }

            var pendingMigrations = historyRepository.GetPendingMigrations(
                new[] { "000000000000002_InitialCreate", "Migration 1" });

            Assert.Equal("Migration 1", pendingMigrations.Single());
        }