예제 #1
0
        public void ChangeLogicalNamesDefaultLocation()
        {
            DestroyDatabase();
            String connectionString = StackHashSqlConfiguration.DefaultMaster.ToConnectionString();

            SqlCommands commands = new SqlCommands(m_ProviderFactory, connectionString, connectionString, 1);

            commands.CreateDatabase(m_ErrorIndexPath, SqlUtils.UnitTestDatabase, true); // Create in default location.

            Assert.AreEqual(true, commands.DatabaseExists(SqlUtils.UnitTestDatabase));

            Collection <String> logicalFileNames = commands.GetLogicalFileNames(SqlUtils.UnitTestDatabase);

            Assert.AreNotEqual(null, logicalFileNames);
            Assert.AreEqual(2, logicalFileNames.Count);

            String expectedDatLogicalFile = SqlUtils.UnitTestDatabase;
            String expectedLogLogicalFile = SqlUtils.UnitTestDatabase + "_log";

            Assert.AreEqual(0, String.Compare(expectedDatLogicalFile, logicalFileNames[0], StringComparison.OrdinalIgnoreCase));
            Assert.AreEqual(0, String.Compare(expectedLogLogicalFile, logicalFileNames[1], StringComparison.OrdinalIgnoreCase));

            // Now change the logical filenames.
            String newDatabaseName = "ChangeTest";

            Assert.AreEqual(true, commands.ChangeDatabaseLogicalNames(SqlUtils.UnitTestDatabase, newDatabaseName, false));

            logicalFileNames = commands.GetLogicalFileNames(SqlUtils.UnitTestDatabase);

            Assert.AreNotEqual(null, logicalFileNames);
            Assert.AreEqual(2, logicalFileNames.Count);

            expectedDatLogicalFile = newDatabaseName;
            expectedLogLogicalFile = newDatabaseName + "_log";

            Assert.AreEqual(0, String.Compare(expectedDatLogicalFile, logicalFileNames[0], StringComparison.OrdinalIgnoreCase));
            Assert.AreEqual(0, String.Compare(expectedLogLogicalFile, logicalFileNames[1], StringComparison.OrdinalIgnoreCase));



            commands.DeleteDatabase(SqlUtils.UnitTestDatabase);
        }