Ejemplo n.º 1
0
        public void Try_Extract_Dacpac()
        {
            var dbName            = "DacpacTestDb";
            var resultingFilePath = "NsagaCreated.dacpac";
            var settings          = new ExtractDacpacSettings("TestApp", "1.0.0.0")
            {
                OutputFile = resultingFilePath
            };

            try
            {
                // Arrange
                SqlHelpers.ExecuteSql(ConnectionString, $"create database {dbName}");
                var sql = $@"use {dbName}
                GO
                create table [{dbName}].[dbo].[Table1] (id int null, name nvarchar(max) null);
                Go";
                context.ExecuteSqlCommand(ConnectionString, sql);

                // Act
                SqlDacpacImpl.ExtractDacpacFile(context, ConnectionString, dbName, settings);

                // Assert
                File.Exists(resultingFilePath).Should().BeTrue();
            }
            finally
            {
                SqlHelpers.DropDatabase(ConnectionString, dbName);
                File.Delete(resultingFilePath);
            }
        }
Ejemplo n.º 2
0
        public void GetPublishOptions_MapsDictionary_Correctly()
        {
            //Arrange
            var publishSettings = new PublishDacpacSettings();

            publishSettings.SqlCommandVariableValues["Hello"] = "World";
            publishSettings.SqlCommandVariableValues["31Oct"] = "25Dec";

            // Act
            var publishOptions = SqlDacpacImpl.GetPublishOptions(publishSettings);

            // Assert
            var result = publishOptions.DeployOptions.SqlCommandVariableValues;

            result["Hello"].Should().Be("World");
            result["31Oct"].Should().Be("25Dec");
        }
Ejemplo n.º 3
0
        public void Try_Publish_Dacpac()
        {
            var dbName = "DacpacTestDb";

            try
            {
                // Arrange
                SqlHelpers.ExecuteSql(ConnectionString, $"create database {dbName}");

                // Act
                SqlDacpacImpl.PublishDacpacFile(context, ConnectionString, dbName, GetDacpacFilePath());

                // Assert
                SqlHelpers.TableExists(ConnectionString, dbName, "Table1").Should().BeTrue();
            }
            finally
            {
                SqlHelpers.DropDatabase(ConnectionString, dbName);
            }
        }