public virtual void Test()
            {
                CollectionHolder h1 = Subject();

                StoreNewAndCommit(A().Provider(), h1);
                ReplicateAll(A().Provider(), B().Provider());
                IEnumerator it = B().Provider().GetStoredObjects(typeof(CollectionHolder)).GetEnumerator
                                     ();

                Assert.IsTrue(it.MoveNext());
                CollectionHolder replica = (CollectionHolder)it.Current;

                B().Provider().Activate(replica);
                AssertSameClassIfDb4o(h1.Map(), replica.Map());
                foreach (object key in h1.Map().Keys)
                {
                    B().Provider().Activate(replica.Map());
                    Assert.AreEqual(h1.Map()[key], replica.Map()[key]);
                }
                AssertSameClassIfDb4o(h1.Set(), replica.Set());
                foreach (object element in h1.Set())
                {
                    Assert.IsTrue(replica.Set().Contains(element));
                }
                AssertSameClassIfDb4o(h1.List(), replica.List());
                Assert.AreEqual(h1.List().Count, replica.List().Count);
                CollectionAssert.AreEqual(h1.List(), replica.List());
            }
 private CollectionHolder Initialize(CollectionHolder h1)
 {
     h1.Map()["1"] = "one";
     h1.Map()["2"] = "two";
     h1.Set().Add("two");
     h1.List().Add("three");
     return(h1);
 }
示例#3
0
 private void CheckH1(CollectionHolder holder)
 {
     Assert.AreEqual("value", holder.Map()["key"]);
     Assert.AreEqual(holder, holder.Map()["key2"]);
     Assert.AreEqual("value2", holder.Map()[holder]);
     Assert.AreEqual("one", holder.List()[0]);
     Assert.AreEqual(holder, holder.List()[1]);
     Assert.IsTrue(holder.Set().Contains("one"));
     Assert.IsTrue(holder.Set().Contains(holder));
 }
示例#4
0
        private void CheckH2(CollectionHolder holder)
        {
            Assert.AreEqual("h1", ((CollectionHolder)holder.Map()["key"]).Name());
            Assert.AreEqual("h1", ((CollectionHolder)holder.Map()[holder]).Name());
            Assert.AreEqual("two", holder.List()[0]);
            Assert.AreEqual("h1", ((CollectionHolder)holder.List()[1]).Name());
            Assert.AreEqual(holder, holder.List()[2]);
            Assert.IsTrue(holder.Set().Remove("two"));
            Assert.IsTrue(holder.Set().Remove(holder));
            CollectionHolder remaining = NextCollectionHolder(holder.Set().GetEnumerator());

            Assert.AreEqual("h1", remaining.Name());
        }
示例#5
0
        protected virtual void ActualTest()
        {
            if (!A().Provider().SupportsHybridCollection())
            {
                return;
            }
            if (!B().Provider().SupportsHybridCollection())
            {
                return;
            }
            CollectionHolder h1 = new CollectionHolder("h1");
            CollectionHolder h2 = new CollectionHolder("h2");

            h1.Map()["key"]  = "value";
            h1.Map()["key2"] = h1;
            h1.Map()[h1]     = "value2";
            h2.Map()["key"]  = h1;
            h2.Map()[h2]     = h1;
            h1.List().Add("one");
            h1.List().Add(h1);
            h2.List().Add("two");
            h2.List().Add(h1);
            h2.List().Add(h2);
            h1.Set().Add("one");
            h1.Set().Add(h1);
            h2.Set().Add("two");
            h2.Set().Add(h1);
            h2.Set().Add(h2);
            B().Provider().StoreNew(h2);
            B().Provider().StoreNew(h1);
            IReplicationSession replication = new GenericReplicationSession(A().Provider(), B
                                                                                ().Provider());

            replication.Replicate(h2);
            //Traverses to h1.
            replication.Commit();
            IEnumerator objects = A().Provider().GetStoredObjects(typeof(CollectionHolder)).GetEnumerator
                                      ();

            Check(NextCollectionHolder(objects), h1, h2);
            Check(NextCollectionHolder(objects), h1, h2);
        }