Пример #1
0
        private void VerifySchema(Migration migration, string?schema)
        {
            SchemaSetterMock.Verify(s => s.SetSchema(migration.UpOperations, schema), Times.Once);
            SchemaSetterMock.Verify(s => s.SetSchema(migration.DownOperations, schema), Times.Once);

            migration.UpOperations[0].Should().BeOfType <AddColumnOperation>().Subject.Schema.Should().Be(schema);
            migration.DownOperations[0].Should().BeOfType <DropColumnOperation>().Subject.Schema.Should().Be(schema);
        }
Пример #2
0
        public void Should_set_schema_of_migration_having_schema_aware_ctx()
        {
            CurrentCtxMock.Setup(c => c.Context).Returns(CreateContextWithSchema("Schema1"));
            SchemaSetterMock.Setup(s => s.SetSchema(It.IsAny <IReadOnlyList <MigrationOperation> >(), It.IsAny <string>()))
            .Callback <IReadOnlyList <MigrationOperation>, string>((ops, schema) => new MigrationOperationSchemaSetter().SetSchema(ops, schema));

            var migration = SUT.CreateMigration(typeof(MigrationWithoutSchema).GetTypeInfo(), "DummyProvider");

            VerifySchema(migration, "Schema1");
        }
Пример #3
0
        public void Should_not_set_schema_on_schema_unaware_migration_having_schema_unaware_ctx()
        {
            CurrentCtxMock.Setup(c => c.Context).Returns(CreateContextWithoutSchema());

            var migration = SUT.CreateMigration(typeof(MigrationWithoutSchema).GetTypeInfo(), "DummyProvider");

            SchemaSetterMock.Verify(s => s.SetSchema(It.IsAny <IReadOnlyList <MigrationOperation> >(), It.IsAny <string>()), Times.Never);
            migration.UpOperations[0].Should().BeOfType <AddColumnOperation>().Subject.Schema.Should().BeNull();
            migration.DownOperations[0].Should().BeOfType <DropColumnOperation>().Subject.Schema.Should().BeNull();
        }