Пример #1
0
        public void TestDeleteFileWithRetryWhenFileDoesNotExist()
        {
            string file = Path.GetRandomFileName();

            Assert.IsFalse(File.Exists(file));
            Cleanup.DeleteFileWithRetry(file);
        }
Пример #2
0
        /// <summary>
        /// Compact the database.
        /// </summary>
        private void CompactDatabase()
        {
            string defraggedDatabase = Path.Combine(this.databaseDirectory, "defragged.edb");

            using (var instance = this.CreateInstance())
            {
                instance.Init();
                using (var session = new Session(instance))
                {
                    // For JetCompact to work the database has to be attached, but not opened
                    Api.JetAttachDatabase(session, this.database, AttachDatabaseGrbit.None);
                    if (this.useStatusCallback)
                    {
                        this.statusCallbackWasCalled = false;
                        Api.JetCompact(session, this.database, defraggedDatabase, this.StatusCallback, null, CompactGrbit.None);
                        Assert.IsTrue(
                            this.statusCallbackWasCalled, "expected the status callback to be called during compact");
                    }
                    else
                    {
                        Api.JetCompact(session, this.database, defraggedDatabase, null, null, CompactGrbit.None);
                    }
                }
            }

            Assert.IsTrue(EseInteropTestHelper.FileExists(defraggedDatabase));
            Cleanup.DeleteFileWithRetry(this.database);
            File.Move(defraggedDatabase, this.database);
        }
Пример #3
0
        public void TestDeleteFileWithRetryWhenFileDoesNotExist()
        {
            string file = EseInteropTestHelper.PathGetRandomFileName();

            Assert.IsFalse(EseInteropTestHelper.FileExists(file));
            Cleanup.DeleteFileWithRetry(file);
        }
Пример #4
0
        public void VerifyDeleteFileWithRetryRemovesFile()
        {
            // Create a random file
            string file = Path.GetRandomFileName();

            File.WriteAllText(file, "hello");
            Assert.IsTrue(File.Exists(file));

            // Delete the file
            Cleanup.DeleteFileWithRetry(file);

            // The file should no longer exist
            Assert.IsFalse(File.Exists(file));
        }
Пример #5
0
        public void VerifyDeleteFileWithRetryRemovesFile()
        {
            // Create a random file
            string file = EseInteropTestHelper.PathGetRandomFileName();

            EseInteropTestHelper.FileWriteAllText(file, "hello");
            Assert.IsTrue(EseInteropTestHelper.FileExists(file));

            // Delete the file
            Cleanup.DeleteFileWithRetry(file);

            // The file should no longer exist
            Assert.IsFalse(EseInteropTestHelper.FileExists(file));
        }