コード例 #1
0
        /// <summary>
        /// Wipe out the current BEP's file(s), since it is about to be created ex-nihilo.
        /// </summary>
        private static void DeleteDatabase(BackendStartupParameter backendParameters, bool assertThatDbWasDeleted = true)
        {
            string pathname = string.Empty;

            if (backendParameters.ProjectId.Type != BackendProviderType.kMemoryOnly)
            {
                pathname = backendParameters.ProjectId.Path;
            }
            if (backendParameters.ProjectId.Type != BackendProviderType.kMemoryOnly &&
                File.Exists(pathname))
            {
                try
                {
                    File.Delete(pathname);
                    //The File.Delete command returns before the OS has actually removed the file,
                    //this causes re-creation of the file to fail intermittently so we'll wait a bit for it to be gone.
                    for (var i = 0; File.Exists(pathname) && i < 5; ++i)
                    {
                        Thread.Sleep(10);
                    }
                }
                catch (IOException)
                {
                    // Don't crash, fail the assert if we couldn't delete the file
                }
                // We want to assert during the setup of test conditions because the test isn't valid if we don't start clean
                // If we fail to delete the files after the test (beause the OS hangs on to the handle too long for instance)
                //  this is not cause to fail the test.
                if (assertThatDbWasDeleted)
                {
                    Assert.That(!File.Exists(pathname), "Database file failed to be deleted.");
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Wipe out the current BEP's file(s), since it is about to be created ex-nihilo.
        /// </summary>
        /// <param name="backendParameters"></param>
        private static void DeleteDatabase(BackendStartupParameter backendParameters)
        {
            // db4o client/server has its own mechanism.
            if (backendParameters.ProjectId.Type == FDOBackendProviderType.kDb4oClientServer)
            {
                return;
            }
            string pathname = string.Empty;

            if (backendParameters.ProjectId.Type != FDOBackendProviderType.kMemoryOnly)
            {
                pathname = backendParameters.ProjectId.Path;
            }
            if (backendParameters.ProjectId.Type != FDOBackendProviderType.kMemoryOnly &&
                File.Exists(pathname))
            {
                File.Delete(pathname);
                //The File.Delete command returns before the OS has actually removed the file,
                //this causes re-creation of the file to fail intermittently so we'll wait a bit for it to be gone.
                for (var i = 0; File.Exists(pathname) && i < 5; ++i)
                {
                    Thread.Sleep(10);
                }
                Assert.That(!File.Exists(pathname), "Database file failed to be deleted.");
            }
        }
コード例 #3
0
        /// <summary>
        /// Wipe out the current BEP's file(s), since it is about to be created ex-nihilo.
        /// </summary>
        /// <param name="backendParameters"></param>
        private static void DeleteDatabase(BackendStartupParameter backendParameters)
        {
            // db4o client/server has its own mechanism.
            if (backendParameters.ProjectId.Type == FDOBackendProviderType.kDb4oClientServer)
            {
                return;
            }
            string pathname = string.Empty;

            if (backendParameters.ProjectId.Type != FDOBackendProviderType.kMemoryOnly)
            {
                pathname = backendParameters.ProjectId.Path;
            }
            if (backendParameters.ProjectId.Type != FDOBackendProviderType.kMemoryOnly && File.Exists(pathname))
            {
                File.Delete(pathname);
            }
        }