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 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 ExecuteThrowsArgumentExceptionForNullTransaction() { var script = new Script(""); UnitTestHelper.AssertThrowsArgumentNullException(() => script.Execute(null)); }
public SqlScriptExecutionException(string message, Subtext.Scripting.Script script, int returnValue, Exception innerException) : base(message, innerException) { this._script = script; this._returnValue = returnValue; }
private SqlScriptExecutionException(SerializationInfo info, StreamingContext context) : base(info, context) { this._script = info.GetValue("Script", typeof(string)) as Subtext.Scripting.Script; }
public void ToStringWithScriptWithNoTokensDisplaysNoTokensMessage() { var script = new Script("/*nothing*/"); Assert.AreEqual("Script has no tokens.", script.ToString()); }