public void ExecutesTheStatement()
        {
            var expression = new ExecuteSqlScriptExpression { SqlScript = testSqlScript };

            var processor = new Mock<IMigrationProcessor>();
            processor.Setup(x => x.Execute(scriptContents)).Verifiable();

            expression.ExecuteWith(processor.Object);
            processor.Verify();
        }
        public void Script(string pathToSqlScript, IDictionary<string, string> tokenDictionary)
        {
            var expression = new ExecuteSqlScriptExpression
            {
                SqlScript = pathToSqlScript,
                Parameters = tokenDictionary
            };

            _context.Expressions.Add(expression);
        }
 public void CanUseScriptsOnAnotherDriveToWorkingDirectory()
 {
     var scriptOnAnotherDrive = "z" + Path.VolumeSeparatorChar + Path.DirectorySeparatorChar + testSqlScript;
     var expression = new ExecuteSqlScriptExpression { SqlScript = scriptOnAnotherDrive };
     
     var conventions = new MigrationConventions { GetWorkingDirectory = () => "c" + Path.VolumeSeparatorChar + Path.DirectorySeparatorChar + "code" };
     expression.ApplyConventions(conventions);
     
     expression.SqlScript.ShouldBe(scriptOnAnotherDrive);
 }
 public void Script(string pathToSqlScript)
 {
     var expression = new ExecuteSqlScriptExpression { SqlScript = pathToSqlScript };
     _context.Expressions.Add(expression);
 }
 public void ToStringIsDescriptive()
 {
     var expression = new ExecuteSqlScriptExpression { SqlScript = testSqlScript };
     expression.ToString().ShouldBe("ExecuteSqlScript embeddedtestscript.sql");
 }
 public void ErrorIsReturnWhenSqlScriptIsNullOrEmpty()
 {
     var expression = new ExecuteSqlScriptExpression { SqlScript = null };
     var errors = ValidationHelper.CollectErrors(expression);
     errors.ShouldContain(ErrorMessages.SqlScriptCannotBeNullOrEmpty);
 }
        public void ExecutesTheStatementWithParameters()
        {
            const string scriptContents = "TEST SCRIPT ParameterValue $(escaped_parameter)";
            var expression = new ExecuteSqlScriptExpression
            {
                SqlScript = "testscript-withparameters.sql",
                Parameters = new Dictionary<string, string> {{"parameter", "ParameterValue"}}
            };

            var processor = new Mock<IMigrationProcessor>();

            processor.Setup(x => x.Execute(scriptContents)).Verifiable();

            expression.ExecuteWith(processor.Object);
            processor.Verify();
        }