Exemplo n.º 1
0
        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 ToStringIsDescriptive()
        {
            var expression = new ExecuteSqlScriptExpression {
                SqlScript = testSqlScript
            };

            expression.ToString().ShouldBe($"ExecuteSqlScript {testSqlScript}");
        }
        public void ErrorIsReturnWhenSqlScriptIsNullOrEmpty()
        {
            var expression = new ExecuteSqlScriptExpression {
                SqlScript = null
            };
            var errors = ValidationHelper.CollectErrors(expression);

            errors.ShouldContain(ErrorMessages.SqlScriptCannotBeNullOrEmpty);
        }
        public void Script(string pathToSqlScript, IDictionary <string, string> parameters)
        {
            var expression = new ExecuteSqlScriptExpression
            {
                SqlScript  = pathToSqlScript,
                Parameters = parameters,
            };

            _context.Expressions.Add(expression);
        }
        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 CanUseScriptsOnAnotherDriveToWorkingDirectory()
        {
            var scriptOnAnotherDrive = "z" + Path.VolumeSeparatorChar + Path.DirectorySeparatorChar + testSqlScript;
            var expression           = new ExecuteSqlScriptExpression {
                SqlScript = scriptOnAnotherDrive
            };

            var defaultRootPath = "c" + Path.VolumeSeparatorChar + Path.DirectorySeparatorChar + "code";
            var conventionSet   = ConventionSets.CreateNoSchemaName(defaultRootPath);
            var processed       = expression.Apply(conventionSet);

            processed.SqlScript.ShouldBe(scriptOnAnotherDrive);
        }
        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 ExecutesTheStatementWithParameters()
        {
            const string scriptContentsWithParameters = "TEST SCRIPT ParameterValue $(escaped_parameter) $(missing_parameter)";
            var          expression = new ExecuteSqlScriptExpression()
            {
                SqlScript  = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestScriptWithParameters.sql"),
                Parameters = new Dictionary <string, string> {
                    { "parameter", "ParameterValue" }
                }
            };

            var processor = new Mock <IMigrationProcessor>();

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

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