public void ExecuteThrowsScriptExceptionForBadSql() { var script = new Script("SELECT * FROM BLAHBLAH"); using(var connection = new SqlConnection(Config.ConnectionString)) { connection.Open(); UnitTestHelper.AssertThrows<SqlScriptExecutionException>(() => script.Execute(connection.BeginTransaction())); } }
public void ExecuteThrowsScriptExceptionForBadSql() { Script script = new Script("SELECT * FROM BLAHBLAH"); using (SqlConnection connection = new SqlConnection(Config.ConnectionString)) { connection.Open(); script.Execute(connection.BeginTransaction()); } }
public void ExecuteThrowsProperScriptExceptionForBadSql() { var script = new Script("SELECT * FROM BLAHBLAH"); using(var connection = new SqlConnection(Config.ConnectionString)) { connection.Open(); var e = UnitTestHelper.AssertThrows<SqlScriptExecutionException>(() => script.Execute(connection.BeginTransaction())); Assert.IsTrue(e.Message.Length > 0); Assert.AreEqual(0, e.ReturnValue); Assert.AreEqual("SELECT * FROM BLAHBLAH", e.Script.ScriptText); } }
public void ExecuteThrowsProperScriptExceptionForBadSql() { Script script = new Script("SELECT * FROM BLAHBLAH"); using (SqlConnection connection = new SqlConnection(Config.ConnectionString)) { connection.Open(); try { script.Execute(connection.BeginTransaction()); } catch(SqlScriptExecutionException e) { Assert.IsTrue(e.Message.Length > 0); Assert.AreEqual(0, e.ReturnValue); Assert.AreEqual("SELECT * FROM BLAHBLAH", e.Script.ScriptText); throw; } } }
public void ExecuteThrowsArgumentExceptionForNullTransaction() { var script = new Script(""); UnitTestHelper.AssertThrowsArgumentNullException(() => script.Execute(null)); }
/// <summary> /// Temporarily set NOCOUNT OFF on the connection. We must do this b/c the SqlScriptRunner /// depends on all CRUD statements returning the number of effected rows to determine if an /// error occured. This isn't a perfect solution, but it's what we've got. /// </summary> /// <param name="transaction"></param> private static void SetNoCountOff(SqlTransaction transaction) { Script noCount = new Script("SET NOCOUNT OFF"); noCount.Execute(transaction); }
/// <summary> /// Temporarily set NOCOUNT OFF on the connection. We must do this b/c the SqlScriptRunner /// depends on all CRUD statements returning the number of effected rows to determine if an /// error occured. This isn't a perfect solution, but it's what we've got. /// </summary> /// <param name="transaction"></param> private static void SetNoCountOff(SqlTransaction transaction) { var noCount = new Script("SET NOCOUNT OFF"); noCount.Execute(transaction); }
public void ExecuteThrowsArgumentExceptionForNullTransaction() { Script script = new Script(""); script.Execute(null); }