Beispiel #1
0
        public void RemoveVersionTableShouldBehaveAsExpected()
        {
            var runnerContext = new Mock <IRunnerContext>();
            var processor     = new Mock <IMigrationProcessor>();
            var runner        = new Mock <IMigrationRunner>();

            runner.SetupGet(r => r.Processor).Returns(processor.Object);
            runner.SetupGet(r => r.RunnerContext).Returns(runnerContext.Object);

            var conventions = new MigrationRunnerConventions();
            var asm         = Assembly.GetExecutingAssembly();
            var loader      = new VersionLoader(runner.Object, asm, ConventionSets.NoSchemaName, conventions, runnerContext.Object);

            processor.Setup(p => p.Process(It.Is <DeleteTableExpression>(expression =>
                                                                         expression.SchemaName == loader.VersionTableMetaData.SchemaName &&
                                                                         expression.TableName == loader.VersionTableMetaData.TableName)))
            .Verifiable();

            processor.Setup(p => p.Process(It.Is <DeleteSchemaExpression>(expression =>
                                                                          expression.SchemaName == loader.VersionTableMetaData.SchemaName)))
            .Verifiable();

            loader.RemoveVersionTable();

            processor.VerifyAll();
        }
        public void RemoveVersionTableShouldNotRemoveSchemaIfItDidNotOwnTheSchema()
        {
            var processor = new Mock <IMigrationProcessor>();
            var runner    = new Mock <IMigrationRunner>();

            runner.SetupGet(r => r.Processor).Returns(processor.Object);

            var conventions = new MigrationConventions();
            var asm         = Assembly.GetExecutingAssembly();
            var loader      = new VersionLoader(runner.Object, asm, conventions);

            ((TestVersionTableMetaData)loader.VersionTableMetaData).OwnsSchema = false;

            processor.Setup(p => p.Process(It.Is <DeleteTableExpression>(expression =>
                                                                         expression.SchemaName == loader.VersionTableMetaData.SchemaName &&
                                                                         expression.TableName == loader.VersionTableMetaData.TableName)))
            .Verifiable();

            loader.RemoveVersionTable();

            processor.Verify(p => p.Process(It.IsAny <DeleteSchemaExpression>()), Times.Never());
        }