Represents a single executable script within the full SQL script.
Inheritance: IScript, ITemplateScript
Ejemplo n.º 1
0
 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()));
     }
 }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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;
 }
Ejemplo n.º 6
0
 public void ToStringWithScriptWithNoTokensDisplaysNoTokensMessage()
 {
     var script = new Script("/*nothing*/");
     Assert.AreEqual("Script has no tokens.", script.ToString());
 }