Esempio n. 1
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestUpgradeOldDatabaseFiles()
        {
            string          directoryName = "test-directory-" + Runtime.CurrentTimeMillis();
            LiteTestContext context       = new LiteTestContext(directoryName);
            FilePath        directory     = context.GetFilesDir();

            if (!directory.Exists())
            {
                bool result = directory.Mkdir();
                if (!result)
                {
                    throw new IOException("Unable to create directory " + directory);
                }
            }
            FilePath oldTouchDbFile = new FilePath(directory, string.Format("old%s", Manager.
                                                                            DatabaseSuffixOld));

            oldTouchDbFile.CreateNewFile();
            FilePath newCbLiteFile = new FilePath(directory, string.Format("new%s", Manager.DatabaseSuffix
                                                                           ));

            newCbLiteFile.CreateNewFile();
            FilePath migratedOldFile = new FilePath(directory, string.Format("old%s", Manager
                                                                             .DatabaseSuffix));

            migratedOldFile.CreateNewFile();
            base.StopCBLite();
            manager = new Manager(context, Manager.DefaultOptions);
            NUnit.Framework.Assert.IsTrue(migratedOldFile.Exists());
            //cannot rename old.touchdb to old.cblite, because old.cblite already exists
            NUnit.Framework.Assert.IsTrue(oldTouchDbFile.Exists());
            NUnit.Framework.Assert.IsTrue(newCbLiteFile.Exists());
            NUnit.Framework.Assert.AreEqual(3, directory.ListFiles().Length);
            base.StopCBLite();
            migratedOldFile.Delete();
            manager = new Manager(context, Manager.DefaultOptions);
            //rename old.touchdb in old.cblite, previous old.cblite already doesn't exist
            NUnit.Framework.Assert.IsTrue(migratedOldFile.Exists());
            NUnit.Framework.Assert.IsTrue(oldTouchDbFile.Exists() == false);
            NUnit.Framework.Assert.IsTrue(newCbLiteFile.Exists());
            NUnit.Framework.Assert.AreEqual(2, directory.ListFiles().Length);
        }
Esempio n. 2
0
        /// <exception cref="System.IO.IOException"></exception>
        protected internal virtual void StartCBLite()
        {
            LiteTestContext context        = new LiteTestContext();
            string          serverPath     = context.GetRootDirectory().GetAbsolutePath();
            FilePath        serverPathFile = new FilePath(serverPath);

            FileDirUtils.DeleteRecursive(serverPathFile);
            serverPathFile.Mkdir();
            Manager.EnableLogging(Log.Tag, Log.Verbose);
            Manager.EnableLogging(Log.TagSync, Log.Verbose);
            Manager.EnableLogging(Log.TagQuery, Log.Verbose);
            Manager.EnableLogging(Log.TagView, Log.Verbose);
            Manager.EnableLogging(Log.TagChangeTracker, Log.Verbose);
            Manager.EnableLogging(Log.TagBlobStore, Log.Verbose);
            Manager.EnableLogging(Log.TagDatabase, Log.Verbose);
            Manager.EnableLogging(Log.TagListener, Log.Verbose);
            Manager.EnableLogging(Log.TagMultiStreamWriter, Log.Verbose);
            Manager.EnableLogging(Log.TagRemoteRequest, Log.Verbose);
            Manager.EnableLogging(Log.TagRouter, Log.Verbose);
            manager = new Manager(context, Manager.DefaultOptions);
        }
 /// <exception cref="System.Exception"></exception>
 public virtual void TestUpgradeOldDatabaseFiles()
 {
     string directoryName = "test-directory-" + Runtime.CurrentTimeMillis();
     LiteTestContext context = new LiteTestContext(directoryName);
     FilePath directory = context.GetFilesDir();
     if (!directory.Exists())
     {
         bool result = directory.Mkdir();
         if (!result)
         {
             throw new IOException("Unable to create directory " + directory);
         }
     }
     FilePath oldTouchDbFile = new FilePath(directory, string.Format("old%s", Manager.
         DatabaseSuffixOld));
     oldTouchDbFile.CreateNewFile();
     FilePath newCbLiteFile = new FilePath(directory, string.Format("new%s", Manager.DatabaseSuffix
         ));
     newCbLiteFile.CreateNewFile();
     FilePath migratedOldFile = new FilePath(directory, string.Format("old%s", Manager
         .DatabaseSuffix));
     migratedOldFile.CreateNewFile();
     base.StopCBLite();
     manager = new Manager(context, Manager.DefaultOptions);
     NUnit.Framework.Assert.IsTrue(migratedOldFile.Exists());
     //cannot rename old.touchdb to old.cblite, because old.cblite already exists
     NUnit.Framework.Assert.IsTrue(oldTouchDbFile.Exists());
     NUnit.Framework.Assert.IsTrue(newCbLiteFile.Exists());
     NUnit.Framework.Assert.AreEqual(3, directory.ListFiles().Length);
     base.StopCBLite();
     migratedOldFile.Delete();
     manager = new Manager(context, Manager.DefaultOptions);
     //rename old.touchdb in old.cblite, previous old.cblite already doesn't exist
     NUnit.Framework.Assert.IsTrue(migratedOldFile.Exists());
     NUnit.Framework.Assert.IsTrue(oldTouchDbFile.Exists() == false);
     NUnit.Framework.Assert.IsTrue(newCbLiteFile.Exists());
     NUnit.Framework.Assert.AreEqual(2, directory.ListFiles().Length);
 }
 internal TestNetworkReachabilityManager(LiteTestContext _enclosing)
 {
     this._enclosing = _enclosing;
 }
Esempio n. 5
0
 internal TestNetworkReachabilityManager(LiteTestContext _enclosing)
 {
     this._enclosing = _enclosing;
 }