public void SingleServerReaderSingleServerUpdater2(bool useReaderCommit)
 {
   const UInt32 dbNum = 567;
   using (ServerClientSession updater = new ServerClientSession(systemDir))
   using (ServerClientSession reader = new ServerClientSession(systemDir, null, 2000, true, false, CacheEnum.No)) // CacheEnum.No or cache validating on session.Begin() - makes test fail
   {
     updater.BeginUpdate();
     Database db = updater.OpenDatabase(dbNum, true, false);
     if (db != null)
       updater.DeleteDatabase(db);
     updater.Commit();
     updater.BeginUpdate();
     Man man;
     Placement place = new Placement(dbNum, 1, 1, 2);
     for (int i = 0; i < 100; i++)
     {
       man = new Man();
       man.Persist(place, updater);
     }
     updater.Commit();
     reader.BeginRead();
     db = reader.OpenDatabase(dbNum);
     foreach (Page page in db)
       Assert.True(page.PageInfo.VersionNumber == 1);
     if (useReaderCommit)
       reader.Commit();
     updater.BeginUpdate();
     if (useReaderCommit)
       reader.BeginRead();
     else
       reader.ForceDatabaseCacheValidation();
     for (int i = 1; i < 25; i++)
     {
       db = reader.OpenDatabase(dbNum);
       foreach (Page page in db)
       {
         if (page.PageNumber > 0)
         {
           Assert.True(page.PageInfo.VersionNumber == (ulong)i);
           Man man2 = (Man)reader.Open(dbNum, page.PageNumber, 1, false);
           Man manUpdated = (Man)updater.Open(dbNum, page.PageNumber, 1, true);
         }
       }
       if (useReaderCommit)
       {
         reader.Commit();
         reader.BeginRead();
       }
       else
         reader.ForceDatabaseCacheValidation();
       updater.Commit();
       updater.BeginUpdate();
     }
     Database db2 = reader.OpenDatabase(dbNum);
     db = updater.OpenDatabase(dbNum);
     for (int i = 25; i < 50; i++)
     {
       foreach (Page page in db)
       {
         if (page.PageNumber > 0)
         {
           Assert.True(page.PageInfo.VersionNumber == (ulong)i);
           Man manUpdated = (Man)updater.Open(dbNum, page.PageNumber, 1, true);
         }
       }
       updater.FlushUpdates(); // now server will see updated version of pages
       foreach (Page page in db2)
       {
         if (page.PageNumber > 0)
         {                           // BUG Nov 8, 2011 1.0.4.0 reader sees version 28 when it should see version 27 
           Assert.True(page.PageInfo.VersionNumber == (ulong)i); // reader should see the commited version of the page, not the uncommited updated version
           Man man2 = (Man)reader.Open(dbNum, page.PageNumber, 1, false);
         }
       }
       reader.ClearPageCache(); // required or else we will use cached page and Assert (see line above) will fail
       System.GC.Collect(); // force weak referenced pages to be garbage collected (again to avoid Assert failure)
       updater.Commit();
       updater.BeginUpdate();
     }
     reader.Commit();
     updater.DeleteDatabase(db);
     updater.Commit();
   }
 }
        public void SingleServerReaderSingleServerUpdater2(bool useReaderCommit)
        {
            const UInt32 dbNum = 567;

            using (ServerClientSession updater = new ServerClientSession(systemDir))
                using (ServerClientSession reader = new ServerClientSession(systemDir, null, 2000, true, false, CacheEnum.No)) // CacheEnum.No or cache validating on session.Begin() - makes test fail
                {
                    updater.BeginUpdate();
                    Database db = updater.OpenDatabase(dbNum, true, false);
                    if (db != null)
                    {
                        updater.DeleteDatabase(db);
                    }
                    updater.Commit();
                    updater.BeginUpdate();
                    Man       man;
                    Placement place = new Placement(dbNum, 1, 1, 2);
                    for (int i = 0; i < 100; i++)
                    {
                        man = new Man();
                        man.Persist(place, updater);
                    }
                    updater.Commit();
                    reader.BeginRead();
                    db = reader.OpenDatabase(dbNum);
                    foreach (Page page in db)
                    {
                        Assert.True(page.PageInfo.VersionNumber == 1);
                    }
                    if (useReaderCommit)
                    {
                        reader.Commit();
                    }
                    updater.BeginUpdate();
                    if (useReaderCommit)
                    {
                        reader.BeginRead();
                    }
                    else
                    {
                        reader.ForceDatabaseCacheValidation();
                    }
                    for (int i = 1; i < 25; i++)
                    {
                        db = reader.OpenDatabase(dbNum);
                        foreach (Page page in db)
                        {
                            if (page.PageNumber > 0)
                            {
                                Assert.True(page.PageInfo.VersionNumber == (ulong)i);
                                Man man2       = (Man)reader.Open(dbNum, page.PageNumber, 1, false);
                                Man manUpdated = (Man)updater.Open(dbNum, page.PageNumber, 1, true);
                            }
                        }
                        if (useReaderCommit)
                        {
                            reader.Commit();
                            reader.BeginRead();
                        }
                        else
                        {
                            reader.ForceDatabaseCacheValidation();
                        }
                        updater.Commit();
                        updater.BeginUpdate();
                    }
                    Database db2 = reader.OpenDatabase(dbNum);
                    db = updater.OpenDatabase(dbNum);
                    for (int i = 25; i < 50; i++)
                    {
                        foreach (Page page in db)
                        {
                            if (page.PageNumber > 0)
                            {
                                Assert.True(page.PageInfo.VersionNumber == (ulong)i);
                                Man manUpdated = (Man)updater.Open(dbNum, page.PageNumber, 1, true);
                            }
                        }
                        updater.FlushUpdates(); // now server will see updated version of pages
                        foreach (Page page in db2)
                        {
                            if (page.PageNumber > 0)
                            {                                                         // BUG Nov 8, 2011 1.0.4.0 reader sees version 28 when it should see version 27
                                Assert.True(page.PageInfo.VersionNumber == (ulong)i); // reader should see the commited version of the page, not the uncommited updated version
                                Man man2 = (Man)reader.Open(dbNum, page.PageNumber, 1, false);
                            }
                        }
                        reader.ClearPageCache(); // required or else we will use cached page and Assert (see line above) will fail
                        System.GC.Collect();     // force weak referenced pages to be garbage collected (again to avoid Assert failure)
                        updater.Commit();
                        updater.BeginUpdate();
                    }
                    reader.Commit();
                    updater.DeleteDatabase(db);
                    updater.Commit();
                }
        }
 public void SingleServerReaderSingleServerUpdater1()
 {
   ServerClientSession updater = new ServerClientSession(systemDir);
   ServerClientSession reader = new ServerClientSession(systemDir);
   const UInt32 dbNum = 345;
   try
   {
     updater.BeginUpdate();
     Man man;
     Placement place = new Placement(dbNum, 1, 1, 2);
     for (int i = 0; i < 100; i++)
     {
       man = new Man();
       man.Persist(place, updater);
     }
     updater.Commit();
     reader.BeginRead();
     Database db = reader.OpenDatabase(dbNum);
     foreach (Page page in db)
       Assert.True(page.PageInfo.VersionNumber == 1);
     reader.Commit();
     updater.BeginUpdate();
     reader.BeginRead();
     for (int i = 1; i < 25; i++)
     {
       db = reader.OpenDatabase(dbNum);
       foreach (Page page in db)
       {
         if (page.PageNumber > 0)
         {
           Assert.True(page.PageInfo.VersionNumber == (ulong)i);
           Man man2 = (Man)reader.Open(dbNum, page.PageNumber, 1, false);
           Man manUpdated = (Man)updater.Open(dbNum, page.PageNumber, 1, true);
         }
       }
       reader.Commit();
       reader.BeginRead();
       updater.Commit();
       updater.BeginUpdate();
       reader.ForceDatabaseCacheValidation(); // we now validate on BeginRead so to make this test pass, we need to add this call after updater commit.
     }
     Database db2 = reader.OpenDatabase(dbNum);
     db = updater.OpenDatabase(dbNum);
     for (int i = 25; i < 50; i++)
     {
       foreach (Page page in db)
       {
         if (page.PageNumber > 0)
         {
           Assert.True(page.PageInfo.VersionNumber == (ulong)i);
           Man manUpdated = (Man)updater.Open(dbNum, page.PageNumber, 1, true);
         }
       }
       updater.Commit();
       updater.BeginUpdate();
       foreach (Page page in db2)
       {
         if (page.PageNumber > 0)
         {
           Assert.True(page.PageInfo.VersionNumber == (ulong)i + 1);
           Man man2 = (Man)reader.Open(dbNum, page.PageNumber, 1, false);
         }
       }
       reader.ClearPageCache(); // required or else we will use cached page and Assert (see line above) will fail
       System.GC.Collect(); // force weak referenced pages to be garbage collected (again to avoid Assert failure)
     }
     reader.Commit();
     updater.DeleteDatabase(db);
     updater.Commit();
   }
   finally
   {
     updater.Dispose();
     reader.Dispose();
   }
 }
        public void SingleServerReaderSingleServerUpdater1()
        {
            ServerClientSession updater = new ServerClientSession(systemDir);
            ServerClientSession reader  = new ServerClientSession(systemDir);
            const UInt32        dbNum   = 345;

            try
            {
                updater.BeginUpdate();
                Man       man;
                Placement place = new Placement(dbNum, 1, 1, 2);
                for (int i = 0; i < 100; i++)
                {
                    man = new Man();
                    man.Persist(place, updater);
                }
                updater.Commit();
                reader.BeginRead();
                Database db = reader.OpenDatabase(dbNum);
                foreach (Page page in db)
                {
                    Assert.True(page.PageInfo.VersionNumber == 1);
                }
                reader.Commit();
                updater.BeginUpdate();
                reader.BeginRead();
                for (int i = 1; i < 25; i++)
                {
                    db = reader.OpenDatabase(dbNum);
                    foreach (Page page in db)
                    {
                        if (page.PageNumber > 0)
                        {
                            Assert.True(page.PageInfo.VersionNumber == (ulong)i);
                            Man man2       = (Man)reader.Open(dbNum, page.PageNumber, 1, false);
                            Man manUpdated = (Man)updater.Open(dbNum, page.PageNumber, 1, true);
                        }
                    }
                    reader.Commit();
                    reader.BeginRead();
                    updater.Commit();
                    updater.BeginUpdate();
                    reader.ForceDatabaseCacheValidation(); // we now validate on BeginRead so to make this test pass, we need to add this call after updater commit.
                }
                Database db2 = reader.OpenDatabase(dbNum);
                db = updater.OpenDatabase(dbNum);
                for (int i = 25; i < 50; i++)
                {
                    foreach (Page page in db)
                    {
                        if (page.PageNumber > 0)
                        {
                            Assert.True(page.PageInfo.VersionNumber == (ulong)i);
                            Man manUpdated = (Man)updater.Open(dbNum, page.PageNumber, 1, true);
                        }
                    }
                    updater.Commit();
                    updater.BeginUpdate();
                    foreach (Page page in db2)
                    {
                        if (page.PageNumber > 0)
                        {
                            Assert.True(page.PageInfo.VersionNumber == (ulong)i + 1);
                            Man man2 = (Man)reader.Open(dbNum, page.PageNumber, 1, false);
                        }
                    }
                    reader.ClearPageCache(); // required or else we will use cached page and Assert (see line above) will fail
                    System.GC.Collect();     // force weak referenced pages to be garbage collected (again to avoid Assert failure)
                }
                reader.Commit();
                updater.DeleteDatabase(db);
                updater.Commit();
            }
            finally
            {
                updater.Dispose();
                reader.Dispose();
            }
        }