示例#1
0
 /// <exception cref="System.Exception"></exception>
 public virtual void TestInMemoryDefragment()
 {
     Store();
     Defrag();
     Assert.IsSmaller(BackupLength(), _memoryStorage.Bin(Uri).Length());
     Retrieve();
 }
        public virtual void Test()
        {
            var origStorage         = new MemoryStorage();
            var origConfig          = Config(origStorage);
            IObjectContainer origDb = Db4oEmbedded.OpenFile(origConfig, BinUri);

            origDb.Store(new Item(ItemName));
            origDb.Close();
            var origBin = origStorage.Bin(BinUri);
            var data    = origBin.Data();

            Assert.AreEqual(data.Length, origBin.Length());
            var newBin     = new MemoryBin(data, new DoublingGrowthStrategy());
            var newStorage = new MemoryStorage();

            newStorage.Bin(BinUri, newBin);
            IObjectContainer newDb = Db4oEmbedded.OpenFile(Config(newStorage), BinUri);
            var result             = newDb.Query(typeof(Item));

            Assert.AreEqual(1, result.Count);
            Assert.AreEqual(ItemName, ((Item)result.Next())._name
                            );
            newDb.Close();
        }
示例#3
0
        public virtual void Test()
        {
            MemoryStorage          origStorage = new MemoryStorage();
            IEmbeddedConfiguration origConfig  = Config(origStorage);
            IObjectContainer       origDb      = Db4oEmbedded.OpenFile(origConfig, BinUri);

            origDb.Store(new MemoryBinIsReusableTestCase.Item(ItemName));
            origDb.Close();
            MemoryBin origBin = origStorage.Bin(BinUri);

            byte[] data = origBin.Data();
            Assert.AreEqual(data.Length, origBin.Length());
            MemoryBin     newBin     = new MemoryBin(data, new DoublingGrowthStrategy());
            MemoryStorage newStorage = new MemoryStorage();

            newStorage.Bin(BinUri, newBin);
            IObjectContainer newDb  = Db4oEmbedded.OpenFile(Config(newStorage), BinUri);
            IObjectSet       result = newDb.Query(typeof(MemoryBinIsReusableTestCase.Item));

            Assert.AreEqual(1, result.Count);
            Assert.AreEqual(ItemName, ((MemoryBinIsReusableTestCase.Item)result.Next())._name
                            );
            newDb.Close();
        }