internal static Task CreateDocumentsAsync(Database database, int n)
 {
     return(database.RunAsync(db =>
     {
         db.BeginTransaction();
         LiteTestCase.CreateDocuments(db, n);
         db.EndTransaction(true);
     }));
 }
 internal static Task CreateDocumentsAsync(Database database, int n)
 {
     return(database.RunAsync(db =>
     {
         database.RunInTransaction(() =>
         {
             LiteTestCase.CreateDocuments(db, n);
             return true;
         });
     }));
 }
        public void Changed(object sender, ReplicationChangeEventArgs args)
        {
            if (replicationFinished)
            {
                return;
            }

            var replicator = args;

            LiteTestCase.WriteDebug(replicator + " changed: " + replicator.CompletedChangesCount + " / " + replicator.ChangesCount);

            if (replicator.CompletedChangesCount < 0)
            {
                var msg = replicator + ": replicator.CompletedChangesCount < 0";
                Console.WriteLine(msg);
                throw new Exception(msg);
            }

            if (replicator.ChangesCount < 0)
            {
                var msg = replicator + ": replicator.ChangesCount < 0";
                Console.WriteLine(msg);
                throw new Exception(msg);
            }

            if (replicator.CompletedChangesCount > replicator.ChangesCount)
            {
                var msgStr = "replicator.CompletedChangesCount : " + replicator.CompletedChangesCount +
                             " > replicator.ChangesCount : " + replicator.ChangesCount;

                Console.WriteLine(msgStr);
                throw new Exception(msgStr);
            }

            if (args.Status == ReplicationStatus.Idle || args.Status == ReplicationStatus.Stopped)
            {
                this.replicationFinished = true;
                string msg = "ReplicationFinishedObserver.changed called, set replicationFinished to true";
                LiteTestCase.WriteDebug(msg);
                if (doneSignal.CurrentCount > 0)
                {
                    doneSignal.Signal();
                }

                args.Source.Changed -= Changed;
            }
            else
            {
                string msg = string.Format("ReplicationFinishedObserver.changed called, but replicator still running, so ignore it");
                LiteTestCase.WriteDebug(msg);
            }
        }
Ejemplo n.º 4
0
 public bool Run()
 {
     LiteTestCase.CreateDocuments(this._enclosing.database, numDocs);
     countDownLatch.CountDown();
     return(true);
 }
Ejemplo n.º 5
0
 public void Run(Database database)
 {
     db.BeginTransaction();
     LiteTestCase.CreateDocuments(db, n);
     db.EndTransaction(true);
 }