public void SqlString_Install()
        {
            string sourceFile = Path.Combine(SqlStringTests.TestDataDirectory, @"product.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixSqlExtension");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            Assert.IsTrue(SqlVerifier.DatabaseExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB10"), "Database '{0}' was not created on Install", "BlankDB10");
            Assert.IsTrue(SqlVerifier.TableExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "ScottDB22", "TestTable1"), "Table '{0}:{1}' was not created on Install", "ScottDB22", "TestTable1");
            Assert.IsTrue(SqlVerifier.TableExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB10", "TestTable2"), "Table '{0}:{1}' was not created on Install", "BlankDB10", "TestTable2");
            string sqlQuery = "Select * from TestTable2 where name ='FIRST' and value ='Kurtzeborn'";

            Assert.IsTrue(SqlVerifier.SqlObjectExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB10", sqlQuery), "Query '{0}' Results were not created on Install", sqlQuery);


            // Verify The Database BlankDB4 was not created
            Assert.IsFalse(SqlVerifier.DatabaseExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB44"), "Database '{0}' was created on Install", "BlankDB44");

            MSIExec.RepairProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            // Verify The Database was added
            Assert.IsTrue(SqlVerifier.DatabaseExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB44"), "Database '{0}' was Not created on Repair", "BlankDB44");

            MSIExec.UninstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            Assert.IsTrue(SqlVerifier.DatabaseExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB10"), "Database '{0}' was dropped on Uninstall", "BlankDB10");

            Assert.IsFalse(SqlVerifier.DatabaseExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB44"), "Database '{0}' was not dropped on Uninstall", "BlankDB44");

            SqlStringTests.DropDatabase("BlankDB10");
        }
        public void SqlString_ReInstall()
        {
            string sourceFile = Path.Combine(SqlStringTests.TestDataDirectory, @"product.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixSqlExtension");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            Assert.IsTrue(SqlVerifier.DatabaseExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB15"), "Database '{0}' was not created on Install", "BlankDB15");
            Assert.IsTrue(SqlVerifier.TableExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB15", "TestTable1"), "Table '{0}:{1}' was not created on Install", "BlankDB15", "TestTable1");

            // insert a record in the new database
            string sqlInsertString = "INSERT INTO TestTable1(name, value) Values('test', 'nooverwrite')";

            SqlVerifier.ExecuteSQlCommand(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB15", sqlInsertString);

            string sqlqueryString = "Select * from TestTable1 where name ='test' and value ='nooverwrite'";

            Assert.IsTrue(SqlVerifier.SqlObjectExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB15", sqlqueryString), "Query '{0}' Results were not created on Install", sqlqueryString);

            MSIExec.RepairProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            // verify the change is still in the database
            Assert.IsTrue(SqlVerifier.SqlObjectExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB15", sqlqueryString), "Query '{0}' Results were not created on Install", sqlqueryString);

            MSIExec.UninstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            SqlStringTests.DropDatabase("BlankDB10");
        }
示例#3
0
        public void SqlScript_Install()
        {
            string sourceFile = Path.Combine(SqlScriptTests.TestDataDirectory, @"product.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixSqlExtension");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            Assert.IsTrue(SqlVerifier.DatabaseExists(SqlScriptTests.SQLServerHostName, SqlScriptTests.SQLServerInstanceName, "BlankDB12"), "Database '{0}' was not created on Install", "BlankDB12");
            Assert.IsTrue(SqlVerifier.TableExists(SqlScriptTests.SQLServerHostName, SqlScriptTests.SQLServerInstanceName, "BlankDB12", "TestTable2"), "Table '{0}:{1}' was not created on Install", "BlankDB12", "TestTable2");

            MSIExec.UninstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            Assert.IsFalse(SqlVerifier.DatabaseExists(SqlScriptTests.SQLServerHostName, SqlScriptTests.SQLServerInstanceName, "BlankDB12"), "Database '{0}' was not dropped on Uninstall", "BlankDB12");
        }