Beispiel #1
0
 public DBTests()
 {
     var tempPath = Path.GetTempPath();
     var randName = Path.GetRandomFileName();
     DatabasePath = Path.Combine(tempPath, randName);
     var options = new Options()
     {
         CreateIfMissing = true
     };
     Database = new LDB(DatabasePath, options);
 }
Beispiel #2
0
 public void Error()
 {
     Assert.Throws<LevelDBException>(() =>
     {
         var options = new Options()
         {
             CreateIfMissing = false
         };
         var db = new LDB("non-existent", options);
         Assert.True(false);
         db.Get("key1");
     });
 }
Beispiel #3
0
        public void Cache()
        {
            Database.Dispose();

            // open the DB with a cache that is not owned by LevelDB, then
            // close DB and then free the cache
            var options = new Options()
            {
                CacheSize = 64
            };
            Database = new LDB(DatabasePath, options);
            options = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();
            Database.Set("key1", "value1");
            Database.Dispose();
            Database = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }