public void GetUpgradeOperations_should_return_nothing_when_table_not_present()
        {
            ResetDatabase();

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

            Assert.False(historyRepository.GetUpgradeOperations().Any());
        }
예제 #2
0
        public void GetUpgradeOperations_should_return_nothing_when_table_not_present()
        {
            ResetDatabase();

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

            Assert.False(historyRepository.GetUpgradeOperations().Any());
        }
예제 #3
0
        public void GetUpgradeOperations_should_return_nothing_when_table_not_present()
        {
            ResetDatabase();

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

            Assert.False(historyRepository.GetUpgradeOperations().Any());
        }
예제 #4
0
        public void GetUpgradeOperations_should_return_alter_migration_id_column_when_5_to_6()
        {
            ResetDatabase();

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

            var createTableOperation = GetCreateHistoryTableOperation();

            createTableOperation.Columns.Remove(createTableOperation.Columns.Single(c => c.Name == "ContextKey"));
            createTableOperation.PrimaryKey.Columns.RemoveAt(1);

            ExecuteOperations(createTableOperation);

            var alterColumnOperation = historyRepository.GetUpgradeOperations().OfType <AlterColumnOperation>().Single();

            Assert.Equal("MigrationId", alterColumnOperation.Column.Name);
            Assert.Equal(150, alterColumnOperation.Column.MaxLength);
        }
예제 #5
0
        public void GetUpgradeOperations_should_return_alter_migration_id_column_when_5_to_6()
        {
            ResetDatabase();

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

            var createTableOperation = GetCreateHistoryTableOperation();

            createTableOperation.Columns.Remove(createTableOperation.Columns.Single(c => c.Name == "ContextKey"));
            createTableOperation.PrimaryKey.Columns.RemoveAt(1);

            ExecuteOperations(createTableOperation);

            var alterColumnOperation = historyRepository.GetUpgradeOperations().OfType<AlterColumnOperation>().Single();

            Assert.Equal("MigrationId", alterColumnOperation.Column.Name);
            Assert.Equal(150, alterColumnOperation.Column.MaxLength);
        }
        public void GetUpgradeOperations_should_return_context_key_column_when_not_present()
        {
            ResetDatabase();

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

            var createTableOperation = GetCreateHistoryTableOperation();

            createTableOperation.Columns.Remove(createTableOperation.Columns.Single(c => c.Name == "ContextKey"));
            createTableOperation.PrimaryKey.Columns.RemoveAt(1);
            ExecuteOperations(createTableOperation);

            var addColumnOperation = historyRepository.GetUpgradeOperations().OfType<AddColumnOperation>().Single();

            Assert.Equal("ContextKey", addColumnOperation.Column.Name);
            Assert.Equal("MyKey", addColumnOperation.Column.DefaultValue);
            Assert.Equal(512, addColumnOperation.Column.MaxLength);
            Assert.False(addColumnOperation.Column.IsNullable.Value);
        }
        public void GetUpgradeOperations_should_return_add_product_version_column_when_not_present()
        {
            ResetDatabase();

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

            var createTableOperation = GetCreateHistoryTableOperation();

            createTableOperation.Columns.Remove(createTableOperation.Columns.Last());

            ExecuteOperations(createTableOperation);

            var addColumnOperation = (AddColumnOperation)historyRepository.GetUpgradeOperations().Last();

            Assert.Equal("ProductVersion", addColumnOperation.Column.Name);
            Assert.Equal("0.7.0.0", addColumnOperation.Column.DefaultValue);
            Assert.Equal(32, addColumnOperation.Column.MaxLength);
            Assert.False(addColumnOperation.Column.IsNullable.Value);
        }
예제 #8
0
        public void GetUpgradeOperations_should_return_context_key_column_when_not_present()
        {
            ResetDatabase();

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

            var createTableOperation = GetCreateHistoryTableOperation();

            createTableOperation.Columns.Remove(createTableOperation.Columns.Single(c => c.Name == "ContextKey"));
            createTableOperation.PrimaryKey.Columns.RemoveAt(1);
            ExecuteOperations(createTableOperation);

            var addColumnOperation = historyRepository.GetUpgradeOperations().OfType <AddColumnOperation>().Single();

            Assert.Equal("ContextKey", addColumnOperation.Column.Name);
            Assert.Equal("MyKey", addColumnOperation.Column.DefaultValue);
            Assert.Equal(300, addColumnOperation.Column.MaxLength);
            Assert.False(addColumnOperation.Column.IsNullable.Value);
        }
        public void GetUpgradeOperations_should_return_add_product_version_column_when_not_present()
        {
            ResetDatabase();

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

            var createTableOperation = GetCreateHistoryTableOperation();

            createTableOperation.Columns.Remove(createTableOperation.Columns.Last());

            ExecuteOperations(createTableOperation);

            var addColumnOperation = (AddColumnOperation)historyRepository.GetUpgradeOperations().Last();

            Assert.Equal("ProductVersion", addColumnOperation.Column.Name);
            Assert.Equal("0.7.0.0", addColumnOperation.Column.DefaultValue);
            Assert.Equal(32, addColumnOperation.Column.MaxLength);
            Assert.False(addColumnOperation.Column.IsNullable.Value);
        }
        public void Should_throw_when_upgrading_5_6_and_custom_history_context_factory_specified()
        {
            ResetDatabase();

            var historyRepository
                = new HistoryRepository(
                      ConnectionString,
                      ProviderFactory,
                      "MyKey",
                      null,
                      historyContextFactory: (c, s) => new HistoryContext(c, s));

            var createTableOperation = GetCreateHistoryTableOperation();

            createTableOperation.Columns.Remove(createTableOperation.Columns.Single(c => c.Name == "ContextKey"));
            createTableOperation.PrimaryKey.Columns.RemoveAt(1);

            ExecuteOperations(createTableOperation);

            Assert.Equal(
                Strings.UnableToUpgradeHistoryWhenCustomFactory,
                Assert.Throws <MigrationsException>(() => historyRepository.GetUpgradeOperations().ToList()).Message);
        }
예제 #11
0
        public void Should_throw_when_upgrading_5_6_and_custom_history_context_factory_specified()
        {
            ResetDatabase();

            var historyRepository
                = new HistoryRepository(
                    ConnectionString,
                    ProviderFactory,
                    "MyKey",
                    null,
                    historyContextFactory: (c, s) => new HistoryContext(c, s));

            var createTableOperation = GetCreateHistoryTableOperation();

            createTableOperation.Columns.Remove(createTableOperation.Columns.Single(c => c.Name == "ContextKey"));
            createTableOperation.PrimaryKey.Columns.RemoveAt(1);

            ExecuteOperations(createTableOperation);

            Assert.Equal(
                Strings.UnableToUpgradeHistoryWhenCustomFactory,
                Assert.Throws<MigrationsException>(() => historyRepository.GetUpgradeOperations().ToList()).Message);
        }
예제 #12
0
        public void GetUpgradeOperations_should_return_nothing_when_table_not_present()
        {
            ResetDatabase();

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

            Assert.False(historyRepository.GetUpgradeOperations().Any());
        }