public void dbversion_is_zero_when_journal_table_not_exist()
        {
            // Given
            var dbConnection = Substitute.For<IDbConnection>();
            var command = Substitute.For<IDbCommand>();
            dbConnection.CreateCommand().Returns(command);
            var connectionManager = Substitute.For<IConnectionManager>();
            command.ExecuteScalar().Returns(x => { throw new SQLiteException("table not found"); });
            var consoleUpgradeLog = new ConsoleUpgradeLog();
            var journal = new SQLiteTableJournal(() => connectionManager, () => consoleUpgradeLog, "SchemaVersions");

            // When
            var scripts = journal.GetExecutedScripts();

            // Expect
            command.DidNotReceive().ExecuteReader();
            Assert.AreEqual(0, scripts.Length);
        }
Example #2
0
        public void creates_a_new_journal_table_when_not_exist()
        {
            // Given
            var dbConnection = Substitute.For<IDbConnection>();
            var connectionManager = new TestConnectionManager(dbConnection, true);
            var command = Substitute.For<IDbCommand>();
            var param = Substitute.For<IDbDataParameter>();
            dbConnection.CreateCommand().Returns(command);
            command.CreateParameter().Returns(param);
            command.ExecuteScalar().Returns(x => { throw new SQLiteException("table not found"); });
            var consoleUpgradeLog = new ConsoleUpgradeLog();
            var journal = new SQLiteTableJournal(() => connectionManager, () => consoleUpgradeLog, "SchemaVersions");

            // When
            journal.StoreExecutedScript(new SqlScript("test", "select 1"));

            // Expect
            command.Received().CreateParameter();
            Assert.AreEqual("scriptName", param.ParameterName);
            command.Received().ExecuteNonQuery();
        }
 private SQLiteTableJournal GetJournal()
 {
     var sqLiteConnectionManager = new SQLiteConnectionManager(database.SharedConnection);
     sqLiteConnectionManager.OperationStarting(log, new List<SqlScript>());
     var journal = new SQLiteTableJournal(() => sqLiteConnectionManager, () => log, "SchemaVersions");
     return journal;
 }
Example #4
0
 private SQLiteTableJournal GetJournal()
 {
     var sqLiteConnectionManager = new SQLiteConnectionManager(database.ConnectionString);
     sqLiteConnectionManager.UpgradeStarting(log);
     var journal = new SQLiteTableJournal(() => sqLiteConnectionManager, () => log, "SchemaVersions");
     return journal;
 }