public override void When()
        {
            var testConnectionManager = new TestConnectionManager();

            testConnectionManager.UpgradeStarting(new ConsoleUpgradeLog());
            scriptsToExecute = Subject.GetScripts(testConnectionManager).ToArray();
        }
示例#2
0
            public override UpgradeEngine Given()
            {
                scriptProvider = Substitute.For <IScriptProvider>();
                scriptProvider.GetScripts(Arg.Any <IConnectionManager>()).Returns(new List <SqlScript> {
                    new SqlScript("1234", "foo")
                });
                versionTracker = Substitute.For <IJournal>();
                dbConnection   = Substitute.For <IDbConnection>();
                dbCommand      = Substitute.For <IDbCommand>();
                dbConnection.CreateCommand().Returns(dbCommand);
                var connectionManager = new TestConnectionManager(dbConnection);

                scriptExecutor = new SqlScriptExecutor(() => connectionManager, () => new TraceUpgradeLog(), null, () => true, null);

                var builder = new UpgradeEngineBuilder()
                              .WithScript(new SqlScript("1234", "create table $var$ (Id int)"))
                              .JournalTo(versionTracker)
                              .WithVariable("var", "sub");

                builder.Configure(c => c.ScriptExecutor    = scriptExecutor);
                builder.Configure(c => c.ConnectionManager = connectionManager);

                var upgrader = builder.Build();

                return(upgrader);
            }