Esempio n. 1
0
        public static void CreateAndInstallDatabase(ConnectionString connectionString, string databaseName, string directory)
        {
            DeleteDatabase(connectionString.Server, databaseName, directory);
            CreateDatabase(connectionString.Server, databaseName, directory);

            SqlInstaller installer = new SqlInstaller(connectionString);
            installer.Install(VersionInfo.FrameworkVersion);
        }
Esempio n. 2
0
        protected override void ExecuteCommand(Arguments arguments)
        {
            if (arguments.Contains("recreate-db"))
            {
                DropDatabase(arguments["connect"]);
            }

            if (arguments.Contains("create-db") || arguments.Contains("recreate-db"))
            {
                CreateDatabase(arguments["connect"]);
            }

            SqlInstaller installer = new SqlInstaller(arguments["connect"]);
            installer.Install(VersionInfo.FrameworkVersion);
        }
        public void ListInstallationScriptsReturnsCorrectScripts()
        {
            SqlInstaller installer = new SqlInstaller("null");
            string[] scripts = installer.ListInstallationScripts(null, new Version(1, 5, 0, 0));
            Assert.AreEqual(2, scripts.Length, "We expected to see two scripts.");
            Assert.AreEqual("Installation.01.00.00.sql", scripts[0], "Expected the initial 1.0 installation file.");
            Assert.AreEqual("Installation.01.05.00.sql", scripts[1], "Expected the bugfix 1.5 installation file.");

            scripts = installer.ListInstallationScripts(null, new Version(1, 0, 3, 0));
            Assert.AreEqual(1, scripts.Length, "We expected to see one script.");
            Assert.AreEqual("Installation.01.00.00.sql", scripts[0], "Expected the initial 1.0 installation file.");

            scripts = installer.ListInstallationScripts(null, new Version(0, 0, 3, 0));
            Assert.AreEqual(0, scripts.Length, "We expected to see no scripts.");

            scripts = installer.ListInstallationScripts(new Version(1, 1, 0, 0), new Version(1, 5, 0, 0));
            Assert.AreEqual(1, scripts.Length, "We expected to see one script.");
            Assert.AreEqual("Installation.01.05.00.sql", scripts[0], "Expected the bugfix 1.5.0 installation file.");

            scripts = installer.ListInstallationScripts(new Version(1, 1, 0, 0), new Version(1, 9, 0, 0));
            Assert.AreEqual(2, scripts.Length, "We expected to see two script.");
            Assert.AreEqual("Installation.01.09.00.sql", scripts[1], "Expected the 1.9.0 installation file.");
        }
Esempio n. 4
0
 public static void InstallDatabase(string connectionString)
 {
     SqlInstaller installer = new SqlInstaller(connectionString);
     installer.Install(VersionInfo.FrameworkVersion);
 }