コード例 #1
0
        public void VerifyCreateDictionaryFromConfigSetWithRecoveryFlags()
        {
            const string DictionaryLocation = "ConfigSetDictForNewRecoveryFlags";
            string       dictionaryFilename = Path.Combine(DictionaryLocation, "ConfigSetDict.edb");
            var          config             = new DatabaseConfig()
            {
                SystemPath            = DictionaryLocation,
                LogFilePath           = DictionaryLocation,
                TempPath              = DictionaryLocation,
                DatabaseFilename      = dictionaryFilename,
                TableClass1Name       = "_test_",
                DatabaseRecoveryFlags = VistaGrbits.LogStreamMustExist,
            };

            PersistentDictionary <int, Guid?> pd;
            bool grbitWorked = false;

            try
            {
                using (pd = new PersistentDictionary <int, Guid?>(config))
                {
                }
            }
            catch (EsentMissingLogFileException)
            {
                grbitWorked = true;
            }

            Assert.IsTrue(grbitWorked);
            Assert.IsTrue(!File.Exists(dictionaryFilename));
            Cleanup.DeleteDirectoryWithRetry(DictionaryLocation);
        }
コード例 #2
0
        public void VerifyCreateDictionaryFromConfigSetWithTermFlags()
        {
            const string DictionaryLocation = "ConfigSetDictForTermFlags";
            string       dictionaryFilename = Path.Combine(DictionaryLocation, "ConfigSetDict.edb");
            var          config             = new DatabaseConfig()
            {
                SystemPath        = DictionaryLocation,
                LogFilePath       = DictionaryLocation,
                TempPath          = DictionaryLocation,
                DatabaseFilename  = dictionaryFilename,
                TableClass1Name   = "_testX_",
                DatabaseStopFlags = Windows7Grbits.Dirty,
            };

            using (var pd = new PersistentDictionary <int, Guid?>(config))
            {
                for (int i = 0; i < 256; i++)
                {
                    pd[i] = Guid.NewGuid();
                }

                Assert.IsTrue(File.Exists(dictionaryFilename));

                pd.Dispose();
            }

            JET_dbstate dbstate = GetDbState(dictionaryFilename);

            Console.WriteLine("Dbstate after TermDirty: {0}", dbstate);
            Assert.AreEqual(JET_dbstate.DirtyShutdown, dbstate);

            Cleanup.DeleteDirectoryWithRetry(DictionaryLocation);
        }
コード例 #3
0
        public void VerifyCreateDictionaryFromConfigSet()
        {
            const string DictionaryLocation = "ConfigSetDictionary";
            string       dictionaryFilename = Path.Combine(DictionaryLocation, "configsetDict.edb");
            var          config             = new DatabaseConfig()
            {
                DatabasePageSize = 32 * 1024,
                DatabaseFilename = dictionaryFilename,
                SystemPath       = DictionaryLocation,
                LogFilePath      = DictionaryLocation,
                TempPath         = DictionaryLocation,
                TableClass1Name  = "_test_",
            };

            var pd = new PersistentDictionary <int, Guid?>(config);

            for (int i = 0; i < 256; i++)
            {
                pd[i] = Guid.NewGuid();
            }

            Assert.AreEqual(pd.Database.Config.DatabasePageSize, 32 * 1024);
            Assert.AreEqual(pd.Database.Config.TableClass1Name, "_test_");

            pd.Dispose();

            Assert.IsTrue(File.Exists(dictionaryFilename));
            Cleanup.DeleteDirectoryWithRetry(DictionaryLocation);
        }
コード例 #4
0
        public void VerifyCreateDictionaryFromDirectoryAndConfigSet()
        {
            const string DictionaryLocation = "ConfigSetDictionary";
            var          config             = new DatabaseConfig()
            {
                DatabasePageSize = 32 * 1024,
                TableClass1Name  = "_test_",
            };

            var pd = new PersistentDictionary <int, Guid?>(DictionaryLocation, config);

            for (int i = 0; i < 256; i++)
            {
                pd[i] = Guid.NewGuid();
            }

            Assert.AreEqual(pd.Database.Config.DatabasePageSize, 32 * 1024);
            Assert.AreEqual(pd.Database.Config.TableClass1Name, "_test_");

            pd.Dispose();

            Assert.IsTrue(Directory.Exists(DictionaryLocation));
            Assert.AreEqual(DictionaryLocation, pd.DatabasePath);
            Cleanup.DeleteDirectoryWithRetry(DictionaryLocation);
        }
コード例 #5
0
 public void Teardown()
 {
     this.actual.Dispose();
     if (Directory.Exists(DictionaryLocation))
     {
         Cleanup.DeleteDirectoryWithRetry(DictionaryLocation);
     }
 }
コード例 #6
0
        public void TestPersistentDictionaryRandomInsertAndLookupSpeed()
        {
            using (var dictionary = new PersistentDictionary <long, string>(DictionaryLocation))
            {
                MeasureRandomInsertAndLookupSpeed(dictionary);
            }

            Cleanup.DeleteDirectoryWithRetry(DictionaryLocation);
        }
コード例 #7
0
        public void VerifyOpenFailsOnMismatchedValueTypes()
        {
            const string DictionaryLocation = "IntIntDictionary";
            var          dict = new PersistentDictionary <int, int>(DictionaryLocation);

            dict.Dispose();
            var wrongDict = new PersistentDictionary <int, string>(DictionaryLocation);

            Cleanup.DeleteDirectoryWithRetry(DictionaryLocation);
        }
コード例 #8
0
        public void TestPersistentDictionary()
        {
            const string Directory = "IDictionary";

            using (var dictionary = new PersistentDictionary <string, string>(Directory))
            {
                IDictionaryTest(dictionary);
            }

            Cleanup.DeleteDirectoryWithRetry(Directory);
        }
コード例 #9
0
        public void Teardown()
        {
            if (this.dictionary != null)
            {
                this.dictionary.Dispose();
            }

            if (Directory.Exists(DictionaryLocation))
            {
                Cleanup.DeleteDirectoryWithRetry(DictionaryLocation);
            }
        }
コード例 #10
0
        public void VerifyConstructorCanCopyDictionary()
        {
            const string DictionaryLocation = "CopiedDictionary";
            var          expected           = new Dictionary <int, Guid?>();

            for (int i = 0; i < 256; ++i)
            {
                expected[i] = Guid.NewGuid();
            }

            var actual = new PersistentDictionary <int, Guid?>(expected, DictionaryLocation);

            DictionaryAssert.AreEqual(expected, actual);
            actual.Dispose();
            Cleanup.DeleteDirectoryWithRetry(DictionaryLocation);
        }
コード例 #11
0
        public void VerifyDeleteLeavesUnrelatedFiles()
        {
            const string TestDirectory = "testdirectory";
            string       testFile      = Path.Combine(TestDirectory, "myfile.log");

            if (Directory.Exists(TestDirectory))
            {
                Directory.Delete(TestDirectory);
            }

            Directory.CreateDirectory(TestDirectory);
            File.WriteAllText(testFile, "hello world");
            PersistentDictionaryFile.DeleteFiles(TestDirectory);
            Assert.IsTrue(File.Exists(testFile));
            Cleanup.DeleteDirectoryWithRetry(TestDirectory);
        }
コード例 #12
0
 public void Teardown()
 {
     Cleanup.DeleteDirectoryWithRetry(DictionaryPath);
 }
コード例 #13
0
 public void Teardown()
 {
     this.dictionary.Dispose();
     Cleanup.DeleteDirectoryWithRetry(Directory);
 }
コード例 #14
0
 public void Setup()
 {
     Cleanup.DeleteDirectoryWithRetry(Directory);
     this.dictionary    = new PersistentDictionary <int, int>(Directory);
     this.dictionary[1] = 1;
 }
コード例 #15
0
 public void Teardown()
 {
     Trace.Listeners.Remove(this.traceListener);
     Cleanup.DeleteDirectoryWithRetry(DictionaryLocation);
 }
コード例 #16
0
 public void Setup()
 {
     Cleanup.DeleteDirectoryWithRetry(DictionaryLocation);
     CreateTestData();
     this.dictionary = new PersistentDictionary <string, string>(data, DictionaryLocation);
 }