public Log4NetAndConsoleUpgradeLog(ILog log) { Ensure.That(() => log).IsNotNull(); this.log = log; console = new ConsoleUpgradeLog(); }
public Log4NetAndConsoleUpgradeLog(ILog log) { if (log == null) { throw new ArgumentNullException("log"); } this.log = log; console = new ConsoleUpgradeLog(); }
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); }
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(); }