Esempio n. 1
0
 private void StoreAll(PrefetchConfigurationTestCase.Item[] items)
 {
     for (int itemIndex = 0; itemIndex < items.Length; ++itemIndex)
     {
         PrefetchConfigurationTestCase.Item item = items[itemIndex];
         Client().Store(item);
     }
 }
Esempio n. 2
0
        private void PurgeAll(PrefetchConfigurationTestCase.Item[] items)
        {
            HashSet purged = new HashSet();

            for (int itemIndex = 0; itemIndex < items.Length; ++itemIndex)
            {
                PrefetchConfigurationTestCase.Item item = items[itemIndex];
                Purge(purged, item);
            }
        }
Esempio n. 3
0
 private void Purge(Sharpen.Util.ISet purged, PrefetchConfigurationTestCase.Item item
                    )
 {
     if (purged.Contains(item))
     {
         return;
     }
     purged.Add(item);
     Client().Purge(item);
     PrefetchConfigurationTestCase.Item child = item.child;
     if (null != child)
     {
         Purge(purged, child);
     }
 }
Esempio n. 4
0
        public virtual void TestPrefetchingWithCyclesDescending()
        {
            PrefetchConfigurationTestCase.Item a = new PrefetchConfigurationTestCase.Item(1);
            PrefetchConfigurationTestCase.Item b = new PrefetchConfigurationTestCase.Item(2);
            PrefetchConfigurationTestCase.Item c = new PrefetchConfigurationTestCase.Item(3);
            a.child = b;
            b.child = a;
            c.child = b;
            StoreAllAndPurge(new PrefetchConfigurationTestCase.Item[] { a, b, c });
            Client().Config().PrefetchObjectCount(2);
            Client().Config().PrefetchDepth(2);
            IQuery query = QueryForItemsWithChild();

            query.Descend("order").OrderDescending();
            AssertQueryIterationProtocol(query, Msg.QueryExecute, new PrefetchConfigurationTestCase.Stimulus
                                         [] { new PrefetchConfigurationTestCase.Depth2Stimulus(this, new MsgD[] {  }), new
                                              PrefetchConfigurationTestCase.Depth2Stimulus(this, new MsgD[] {  }), new PrefetchConfigurationTestCase.Depth2Stimulus
                                                  (this, new MsgD[] {  }) });
        }
Esempio n. 5
0
        public virtual void TestRefreshIsUnaffectedByPrefetchingBehavior()
        {
            IExtObjectContainer oc1 = Db();
            IExtObjectContainer oc2 = OpenNewSession();

            oc1.Configure().ClientServer().PrefetchDepth(1);
            oc2.Configure().ClientServer().PrefetchDepth(1);
            try
            {
                PrefetchConfigurationTestCase.Item itemFromClient1 = new PrefetchConfigurationTestCase.RootItem
                                                                         (new PrefetchConfigurationTestCase.Item());
                oc1.Store(itemFromClient1);
                oc1.Commit();
                itemFromClient1.child = null;
                oc1.Store(itemFromClient1);
                PrefetchConfigurationTestCase.Item itemFromClient2 = ((PrefetchConfigurationTestCase.RootItem
                                                                       )RetrieveOnlyInstance(oc2, typeof(PrefetchConfigurationTestCase.RootItem)));
                Assert.IsNotNull(itemFromClient2.child);
                oc1.Rollback();
                itemFromClient2 = ((PrefetchConfigurationTestCase.RootItem)RetrieveOnlyInstance(oc2
                                                                                                , typeof(PrefetchConfigurationTestCase.RootItem)));
                oc2.Refresh(itemFromClient2, int.MaxValue);
                Assert.IsNotNull(itemFromClient2.child);
                oc1.Commit();
                itemFromClient2 = ((PrefetchConfigurationTestCase.RootItem)RetrieveOnlyInstance(oc2
                                                                                                , typeof(PrefetchConfigurationTestCase.RootItem)));
                Assert.IsNotNull(itemFromClient2.child);
                oc1.Store(itemFromClient1);
                oc1.Commit();
                oc2.Refresh(itemFromClient2, int.MaxValue);
                itemFromClient2 = ((PrefetchConfigurationTestCase.RootItem)RetrieveOnlyInstance(oc2
                                                                                                , typeof(PrefetchConfigurationTestCase.RootItem)));
                Assert.IsNull(itemFromClient2.child);
            }
            finally
            {
                oc2.Close();
            }
        }
Esempio n. 6
0
 public RootItem(PrefetchConfigurationTestCase.Item child) : base(child)
 {
 }
Esempio n. 7
0
 public Item(PrefetchConfigurationTestCase.Item child)
 {
     this.child = child;
 }
Esempio n. 8
0
 protected virtual void ActUpon(PrefetchConfigurationTestCase.Item item)
 {
     Assert.IsNotNull(item.child);
     this._enclosing.Db().Activate(item.child, 1);
 }
		public virtual void TestPrefetchingWithCyclesDescending()
		{
			PrefetchConfigurationTestCase.Item a = new PrefetchConfigurationTestCase.Item(1);
			PrefetchConfigurationTestCase.Item b = new PrefetchConfigurationTestCase.Item(2);
			PrefetchConfigurationTestCase.Item c = new PrefetchConfigurationTestCase.Item(3);
			a.child = b;
			b.child = a;
			c.child = b;
			StoreAllAndPurge(new PrefetchConfigurationTestCase.Item[] { a, b, c });
			Client().Config().PrefetchObjectCount(2);
			Client().Config().PrefetchDepth(2);
			IQuery query = QueryForItemsWithChild();
			query.Descend("order").OrderDescending();
			AssertQueryIterationProtocol(query, Msg.QueryExecute, new PrefetchConfigurationTestCase.Stimulus
				[] { new PrefetchConfigurationTestCase.Depth2Stimulus(this, new MsgD[] {  }), new 
				PrefetchConfigurationTestCase.Depth2Stimulus(this, new MsgD[] {  }), new PrefetchConfigurationTestCase.Depth2Stimulus
				(this, new MsgD[] {  }) });
		}