예제 #1
0
        private void Verify(Expression <Action <IMigrationRunner> > func, string task, long version, int steps)
        {
            _migrationRunner.Setup(func).Verifiable();

            var          processor = new Mock <IMigrationProcessor>();
            const string profile   = "Debug";
            var          dataSet   = new DataSet();

            dataSet.Tables.Add(new DataTable());
            processor.Setup(x => x.ReadTableData(null, It.IsAny <string>())).Returns(dataSet);

            var announcer     = new Mock <IAnnouncer>();
            var stopWatch     = new Mock <IStopWatch>();
            var runnerContext = new Mock <IRunnerContext>();

            runnerContext.SetupGet(x => x.Announcer).Returns(announcer.Object);
            runnerContext.SetupGet(x => x.StopWatch).Returns(stopWatch.Object);
            runnerContext.SetupGet(x => x.Database).Returns("sqlserver2008");
            runnerContext.SetupGet(x => x.Connection).Returns(IntegrationTestOptions.SqlServer2008.ConnectionString);
            runnerContext.SetupGet(x => x.Task).Returns(task);
            runnerContext.SetupGet(x => x.Version).Returns(version);
            runnerContext.SetupGet(x => x.Steps).Returns(steps);
            runnerContext.SetupGet(x => x.Target).Returns(GetType().Assembly.Location);
            runnerContext.SetupGet(x => x.Profile).Returns(profile);
            runnerContext.SetupGet(x => x.Namespace).Returns("FluentMigrator.Tests.Integration.Migrations.Interleaved.Pass3");

            var taskExecutor = new FakeTaskExecutor(runnerContext.Object, _migrationRunner.Object);

            taskExecutor.Execute();

            _migrationRunner.VerifyAll();
        }
        private void Verify(Expression<Action<IMigrationRunner>> func, string task, long version, int steps)
        {
            _migrationRunner.Setup(func).Verifiable();

            var processor = new Mock<IMigrationProcessor>();
            const string profile = "Debug";
            var dataSet = new DataSet();
            dataSet.Tables.Add(new DataTable());
            processor.Setup(x => x.ReadTableData(null, It.IsAny<string>())).Returns(dataSet);

            _migrationRunner.SetupGet(x => x.Processor).Returns(processor.Object);

            var announcer = new Mock<IAnnouncer>();
            var stopWatch = new Mock<IStopWatch>();
            var runnerContext = new Mock<IRunnerContext>();
            runnerContext.SetupGet(x => x.Announcer).Returns(announcer.Object);
            runnerContext.SetupGet(x => x.StopWatch).Returns(stopWatch.Object);
            runnerContext.SetupGet(x => x.Database).Returns("sqlserver2008");
            runnerContext.SetupGet(x => x.Connection).Returns(IntegrationTestOptions.SqlServer2008.ConnectionString);
            runnerContext.SetupGet(x => x.Task).Returns(task);
            runnerContext.SetupGet(x => x.Version).Returns(version);
            runnerContext.SetupGet(x => x.Steps).Returns(steps);
            runnerContext.SetupGet(x => x.Target).Returns(GetType().Assembly.Location);
            runnerContext.SetupGet(x => x.Profile).Returns(profile);
            runnerContext.SetupGet(x => x.Namespace).Returns("FluentMigrator.Tests.Integration.Migrations.Interleaved.Pass3");

            var taskExecutor = new FakeTaskExecutor(runnerContext.Object, _migrationRunner.Object);
            taskExecutor.Execute();

            _migrationRunner.VerifyAll();
        }
예제 #3
0
        private void VerifyHasMigrationsToApply(Expression <Func <IMigrationRunner, bool> > func, string task, long version)
        {
            _migrationRunner.Setup(func).Verifiable();

            var processor = new Mock <IMigrationProcessor>();
            var dataSet   = new DataSet();

            dataSet.Tables.Add(new DataTable());
            processor.Setup(x => x.ReadTableData(null, It.IsAny <string>())).Returns(dataSet);
            _migrationRunner.SetupGet(x => x.Processor).Returns(processor.Object);

            var runnerContext = new Mock <IRunnerContext>();

            runnerContext.SetupGet(x => x.Task).Returns(task);
            runnerContext.SetupGet(rc => rc.Version).Returns(version);
            var taskExecutor = new FakeTaskExecutor(runnerContext.Object, _migrationRunner.Object);

            taskExecutor.HasMigrationsToApply();
            _migrationRunner.Verify(func, Times.Once());
        }