Exemple #1
0
        public void InstallTest_InstallParams()
        {
            DBInstallParams dbParams;
            string          sysDrive;
            int             pos;

            sysDrive = Environment.SystemDirectory;
            pos      = sysDrive.IndexOf(':');
            sysDrive = sysDrive.Substring(0, pos + 1);

            dbParams = new DBInstallParams("App", "Foo");
            Assert.AreEqual("Foo", dbParams.Database);
            Assert.AreEqual(sysDrive + @"\LillTek\Data\Foo.mdf", dbParams.DBPath);
            Assert.AreEqual(sysDrive + @"\LillTek\Data\Foo.ldf", dbParams.LogPath);
        }
Exemple #2
0
        public void SentinelServiceDB_DeployDB()
        {
            SqlTestDatabase    dbTest;
            Package            dbPackage = null;
            DBPackageInstaller dbInstaller;
            DBInstallParams    dbParams;
            DBInstallResult    result;

            using (dbTest = SqlTestDatabase.Create())
            {
                SqlConnectionInfo conInfo;
                SqlContext        ctx = null;
                SqlCommand        cmd;
                DataTable         dt;

                try
                {
                    // Deploy to a non-existent database

                    dbPackage   = new Package(EnvironmentVars.Expand("$(LT_BUILD)\\LillTek.SentinelService.dbpack"));
                    dbParams    = new DBInstallParams("SentinelService", dbTest.ConnectionInfo.Database);
                    dbInstaller = new DBPackageInstaller(dbPackage);

                    result = dbInstaller.Install(dbParams);
                    Assert.AreEqual(DBInstallResult.Installed, result);

                    conInfo = SqlConnectionInfo.Parse(dbInstaller.ConnectionString);
                    ctx     = new SqlContext(conInfo);
                    ctx.Open();

                    cmd = ctx.CreateSPCall("GetProductInfo");
                    dt  = ctx.ExecuteTable(cmd);
                    Assert.AreEqual(1, dt.Rows.Count);

                    cmd = ctx.CreateSPCall("Ping");
                    dt  = ctx.ExecuteTable(cmd);
                    Assert.AreEqual(1, dt.Rows.Count);
                    Assert.AreEqual("OK", SqlHelper.AsString(dt.Rows[0]["STATUS"]));

                    ctx.Close();
                    ctx = null;

                    // Deploy again and we should see that the database is up-to-date.

                    SqlConnection.ClearAllPools();
                    result = dbInstaller.Install(dbParams);
                    Assert.AreEqual(DBInstallResult.UpToDate, result);
                }
                finally
                {
                    if (dbPackage != null)
                    {
                        dbPackage.Close();
                    }

                    if (ctx != null)
                    {
                        ctx.Close();
                    }
                }
            }
        }