public virtual void TestExistsWithZeroLengthFile()
        {
            IBin storage = subject.Open(new BinConfiguration(TempFile(), false, 0, false));

            storage.Close();
            Assert.IsFalse(subject.Exists(TempFile()));
        }
Пример #2
0
 public virtual void Close()
 {
     lock (this)
     {
         _bin.Close();
     }
 }
        /// <exception cref="System.Exception"></exception>
        public virtual void SetUp()
        {
            storage = new MemoryStorage();
            IBin bin = storage.Open(new BinConfiguration(DbPath, false, 0, false));

            bin.Write(0, new byte[] { 1, 2, 3 }, 3);
            bin.Close();
        }
 protected virtual void Close()
 {
     if (null != _bin)
     {
         _bin.Sync();
         _bin.Close();
         _bin = null;
     }
 }
Пример #5
0
            private long BackupLength()
            {
                IBin backupBin = BackupStorage().Open(new BinConfiguration(TempFile(), true, 0, true
                                                                           ));
                long backupLength = backupBin.Length();

                backupBin.Sync();
                backupBin.Close();
                return(backupLength);
            }
 private void SyncAndClose(IBin bin)
 {
     try
     {
         bin.Sync();
     }
     finally
     {
         bin.Close();
     }
 }
Пример #7
0
 private static void SyncAndClose(IBin bin)
 {
     if (bin != null)
     {
         try
         {
             bin.Sync();
         }
         finally
         {
             bin.Close();
         }
     }
 }
Пример #8
0
        public virtual void TestInitialLength()
        {
            Storage().Open(new BinConfiguration(TempFile(), false, 1000, false)).Close();
            IBin bin = Storage().Open(new BinConfiguration(TempFile(), false, 0, false));

            try
            {
                Assert.AreEqual(1000, bin.Length());
            }
            finally
            {
                bin.Close();
            }
        }
Пример #9
0
        public void TestRetrievingSizeOnAOpenFileDoenstThrow()
        {
            IBin bin = _storage.Open(new BinConfiguration(TempFile(), true, 0, false));

            try
            {
                byte[] bytes = System.Text.Encoding.UTF8.GetBytes("Test String");
                bin.Write(0, bytes, bytes.Length);

                Assert.AreEqual(bytes.Length, IsolatedStorageStorage.FileSize(TempFile()));
            }
            finally
            {
                bin.Close();
            }
        }
Пример #10
0
        /// <exception cref="IOException"></exception>
        private void BenchmarkCommand(string command, int itemCount, string dbFileName, TextWriter@out)
        {
            var   commands    = CommandSet(command);
            IBin  bin         = Bin(dbFileName);
            var   replayer    = new LogReplayer(CrudApplication.LogFileName(itemCount), bin, commands);
            List4 commandList = replayer.ReadCommandList();
            var   watch       = new StopWatch();

            watch.Start();
            replayer.PlayCommandList(commandList);
            watch.Stop();
            bin.Close();

            var timeElapsed    = watch.Elapsed();
            var operationCount = ((long)replayer.OperationCounts()[command]);

            PrintStatisticsForCommand(@out, command, timeElapsed, operationCount);
        }
        public void TestLockedBin()
        {
            IBin bin = OpenBin();

            try
            {
                OpenBin().Close();
            }
            catch (DatabaseFileLockedException)
            {
                _exceptionCaught = true;
                if (!IsLocked())
                {
                    throw;
                }
            }
            bin.Close();
            Assert.AreEqual(IsLocked(), _exceptionCaught, "Exceptions are expected in locked mode.");
        }
        public void TestReadOnlyBin()
        {
            IBin bin = OpenBin();

            try
            {
                bin.Write(0, new byte[] { 1, 2, 3 }, 3);
            }
            catch (Db4oIOException)
            {
                _exceptionCaught = true;
                if (!IsReadOnly())
                {
                    throw;
                }
            }
            finally
            {
                bin.Close();
            }
            Assert.AreEqual(IsReadOnly(), _exceptionCaught, "Exceptions are expected in ReadOnly mode.");
        }
Пример #13
0
 /// <summary>
 /// closes the BinDecorator and the underlying
 /// <see cref="IBin">IBin</see>
 /// .
 /// </summary>
 public virtual void Close()
 {
     _bin.Close();
 }
		private static void SyncAndClose(IBin bin)
		{
			if (bin != null)
			{
				try
				{
					bin.Sync();
				}
				finally
				{
					bin.Close();
				}
			}
		}
		private void SyncAndClose(IBin bin)
		{
			try
			{
				bin.Sync();
			}
			finally
			{
				bin.Close();
			}
		}