public void EmbeddedScript(string EmbeddedSqlScriptName)
        {

            var expression = new ExecuteEmbeddedSqlScriptExpression { SqlScript = EmbeddedSqlScriptName, MigrationAssembly = _context.MigrationAssembly };

            _context.Expressions.Add(expression);
        }
        public void ResourceFinderFindThrowsExceptionIfFoundMoreThenOneResource()
        {
            var expression = new ExecuteEmbeddedSqlScriptExpression { SqlScript = "NotUniqueResource.sql", MigrationAssembly = Assembly.GetExecutingAssembly() };
            var processor = new Mock<IMigrationProcessor>();

            Assert.Throws<InvalidOperationException>(() => expression.ExecuteWith(processor.Object));
            processor.Verify(x => x.Execute("NotUniqueResource"), Times.Never());
        }
        public void ResourceFinderIsCaseInsensitive()
        {
            var expression = new ExecuteEmbeddedSqlScriptExpression { SqlScript = testSqlScript.ToUpper(), MigrationAssembly = Assembly.GetExecutingAssembly() };
            var processor = new Mock<IMigrationProcessor>();
            processor.Setup(x => x.Execute(scriptContents)).Verifiable();

            expression.ExecuteWith(processor.Object);
            processor.Verify();
        }
        public void ResourceFinderFindFileWithFullNameAndNamespace()
        {
            var expression = new ExecuteEmbeddedSqlScriptExpression { SqlScript = "FluentMigrator.Tests.EmbeddedResources.InitialSchema.sql", MigrationAssembly = Assembly.GetExecutingAssembly() };
            var processor = new Mock<IMigrationProcessor>();
            processor.Setup(x => x.Execute("InitialSchema")).Verifiable();

            expression.ExecuteWith(processor.Object);
            processor.Verify();
        }
        public void ExecutesTheStatement()
        {
            var expression = new ExecuteEmbeddedSqlScriptExpression { SqlScript = testSqlScript, MigrationAssembly = Assembly.GetExecutingAssembly() };

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

            expression.ExecuteWith(processor.Object);
            processor.Verify();
        }
Esempio n. 6
0
        public void CanExecuteEmbeddedResource()
        {
            Mock<IMigrationProcessor> mockProcessor = new Mock<IMigrationProcessor>();

            ExecuteEmbeddedSqlScriptExpression expression = new ExecuteEmbeddedSqlScriptExpression { MigrationAssembly = Assembly.GetExecutingAssembly(), SqlScript = "EmbeddedScript.txt" };

            expression.ExecuteWith(mockProcessor.Object);

            mockProcessor.Verify(mock => mock.Execute("TEST SQL"));
        }
 public void ErrorIsReturnWhenSqlScriptIsNullOrEmpty()
 {
     var expression = new ExecuteEmbeddedSqlScriptExpression { SqlScript = null };
     var errors = ValidationHelper.CollectErrors(expression);
     errors.ShouldContain(ErrorMessages.SqlScriptCannotBeNullOrEmpty);
 }