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

            var installer = new SqlInstaller(connectionString);

            installer.Install(VersionInfo.CurrentAssemblyVersion);
        }
        public void ListInstallationScriptsReturnsCorrectScripts()
        {
            ReadOnlyCollection <string> scripts = SqlInstaller.ListInstallationScripts(null, new Version(1, 5, 0, 0));

            Assert.AreEqual(2, scripts.Count, "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 = SqlInstaller.ListInstallationScripts(null, new Version(1, 0, 3, 0));
            Assert.AreEqual(1, scripts.Count, "We expected to see one script.");
            Assert.AreEqual("Installation.01.00.00.sql", scripts[0], "Expected the initial 1.0 installation file.");

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

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

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

            installer.Install(VersionInfo.CurrentAssemblyVersion);
        }