Exemplo n.º 1
0
 /// <exception cref="System.Exception"></exception>
 public virtual void Test()
 {
     Add(Values);
     Trans().Commit();
     BTreeAssert.AssertAllSlotsFreed(FileTransaction(), _btree, new _ICodeBlock_22(this
                                                                                   ));
 }
Exemplo n.º 2
0
 private void FillTransactionWith(Transaction trans, int bar)
 {
     for (int i = 0; i < BTreeAssert.FillSize(Btree()); ++i)
     {
         Store(trans, new FieldIndexItem(bar));
     }
 }
Exemplo n.º 3
0
        public virtual void TestUnionsMerge()
        {
            IBTreeRange range = Range(3, 3).Union(Range(7, 7)).Union(Range(4, 4));

            AssertIsRangeSingle(range);
            BTreeAssert.AssertRange(new int[] { 3, 4, 7 }, range);
        }
        /// <exception cref="System.Exception"></exception>
        private BTree CycleIntKeys(BTree btree)
        {
            AddKeys(btree);
            ExpectKeys(btree, _sortedKeys);
            btree.Commit(Trans());
            ExpectKeys(btree, _sortedKeys);
            RemoveKeys(btree);
            ExpectKeys(btree, _keysOnRemoval);
            btree.Rollback(Trans());
            ExpectKeys(btree, _sortedKeys);
            int id = btree.GetID();

            Reopen();
            btree = BTreeAssert.CreateIntKeyBTree(Container(), id, BtreeNodeSize);
            ExpectKeys(btree, _sortedKeys);
            RemoveKeys(btree);
            ExpectKeys(btree, _keysOnRemoval);
            btree.Commit(Trans());
            ExpectKeys(btree, _keysOnRemoval);
            // remove all but 1
            for (int i = 1; i < _keysOnRemoval.Length; i++)
            {
                btree.Remove(Trans(), _keysOnRemoval[i]);
            }
            ExpectKeys(btree, _one);
            btree.Commit(Trans());
            ExpectKeys(btree, _one);
            btree.Remove(Trans(), 1);
            btree.Rollback(Trans());
            ExpectKeys(btree, _one);
            btree.Remove(Trans(), 1);
            btree.Commit(Trans());
            ExpectKeys(btree, _none);
            return(btree);
        }
        /// <exception cref="System.Exception"></exception>
        public virtual void TestIntKeys()
        {
            BTree btree = BTreeAssert.CreateIntKeyBTree(Container(), 0, BtreeNodeSize);

            for (int i = 0; i < 5; i++)
            {
                btree = CycleIntKeys(btree);
            }
        }
Exemplo n.º 6
0
        /// <exception cref="System.Exception"></exception>
        private void CycleIntKeys(int[] values)
        {
            BTree btree = BTreeAssert.CreateIntKeyBTree(Container(), 0, BtreeNodeSize);

            for (int i = 0; i < 5; i++)
            {
                btree = CycleIntKeys(btree, values);
            }
        }
Exemplo n.º 7
0
 public virtual void Test()
 {
     Add(CommittedValues);
     CommitBTree();
     for (int i = 0; i < 5; i++)
     {
         Add(RolledBackValues);
         RollbackBTree();
     }
     BTreeAssert.AssertKeys(Trans(), _btree, CommittedValues);
 }
Exemplo n.º 8
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestDelete()
        {
            Db4objects.Db4o.Collections.ISet <BigSetTestCase.Item> set = NewBigSet();
            set.Add(ItemOne);
            Db().Store(set);
            Db().Commit();
            BTree bTree = BTree(set);

            BTreeAssert.AssertAllSlotsFreed(FileTransaction(), bTree, new _ICodeBlock_259(this
                                                                                          , set));
            Assert.Expect(typeof(InvalidOperationException), new _ICodeBlock_265(set));
        }
 public virtual void TestMultiTransactionSearch()
 {
     int[] keys = new int[] { 3, 4, 7, 9 };
     Add(Trans(), keys);
     Commit(Trans());
     int[] assorted = new int[] { 1, 2, 11, 13, 21, 52, 51, 66, 89, 10 };
     Add(SystemTrans(), assorted);
     AssertKeys(keys);
     Remove(SystemTrans(), assorted);
     AssertKeys(keys);
     BTreeAssert.AssertRange(new int[] { 7, 9 }, Search(Trans(), 4).Greater());
 }
        public virtual void TestSearchingRemoved()
        {
            int[] keys = new int[] { 3, 4, 7, 9 };
            Add(keys);
            Remove(4);
            IBTreeRange result = Search(4);

            Assert.IsTrue(result.IsEmpty());
            IBTreeRange range = result.Greater();

            BTreeAssert.AssertRange(new int[] { 7, 9 }, range);
        }
Exemplo n.º 11
0
        public virtual void TestUnionsOfUnions()
        {
            IBTreeRange union1 = Range(3, 4).Union(Range(8, 9));

            BTreeAssert.AssertRange(new int[] { 3, 4, 9 }, union1);
            BTreeAssert.AssertRange(new int[] { 3, 4, 7, 9 }, union1.Union(Range(7, 7)));
            IBTreeRange union2 = Range(3, 3).Union(Range(7, 7));

            AssertUnion(new int[] { 3, 4, 7, 9 }, union1, union2);
            AssertIsRangeSingle(union1.Union(union2));
            AssertIsRangeSingle(union2.Union(union1));
            IBTreeRange union3 = Range(3, 3).Union(Range(9, 9));

            AssertUnion(new int[] { 3, 7, 9 }, union2, union3);
        }
Exemplo n.º 12
0
        private void ExpectKeysSearch(Transaction trans, BTree btree, int[] keys)
        {
            int lastValue = int.MinValue;

            for (int i = 0; i < keys.Length; i++)
            {
                if (keys[i] != lastValue)
                {
                    ExpectingVisitor expectingVisitor = ExpectingVisitor.CreateExpectingVisitor(keys[
                                                                                                    i], IntArrays4.Occurences(keys, keys[i]));
                    IBTreeRange range = btree.SearchRange(trans, keys[i]);
                    BTreeAssert.TraverseKeys(range, expectingVisitor);
                    expectingVisitor.AssertExpectations();
                    lastValue = keys[i];
                }
            }
        }
Exemplo n.º 13
0
        private void ExpectKeysSearch(BTree btree, int[] values)
        {
            int lastValue = int.MinValue;

            for (int i = 0; i < values.Length; i++)
            {
                if (values[i] != lastValue)
                {
                    ExpectingVisitor expectingVisitor = ExpectingVisitor.CreateExpectingVisitor(values
                                                                                                [i], IntArrays4.Occurences(values, values[i]));
                    IBTreeRange range = FieldIndexKeySearch(Trans(), btree, values[i]);
                    BTreeAssert.TraverseKeys(range, new _IVisitor4_62(expectingVisitor));
                    expectingVisitor.AssertExpectations();
                    lastValue = values[i];
                }
            }
        }
Exemplo n.º 14
0
        /// <exception cref="System.Exception"></exception>
        private BTree CycleIntKeys(BTree btree, int[] values)
        {
            for (int i = 0; i < values.Length; i++)
            {
                btree.Add(Trans(), values[i]);
            }
            ExpectKeysSearch(Trans(), btree, values);
            btree.Commit(Trans());
            int id = btree.GetID();

            Container().Commit(Trans());
            Reopen();
            btree = BTreeAssert.CreateIntKeyBTree(Container(), id, BtreeNodeSize);
            ExpectKeysSearch(Trans(), btree, values);
            for (int i = 0; i < values.Length; i++)
            {
                btree.Remove(Trans(), values[i]);
            }
            BTreeAssert.AssertEmpty(Trans(), btree);
            btree.Commit(Trans());
            BTreeAssert.AssertEmpty(Trans(), btree);
            return(btree);
        }
Exemplo n.º 15
0
 private void AssertIntersection(int[] expectedKeys, IBTreeRange range1, IBTreeRange
                                 range2)
 {
     BTreeAssert.AssertRange(expectedKeys, range1.Intersect(range2));
     BTreeAssert.AssertRange(expectedKeys, range2.Intersect(range1));
 }
Exemplo n.º 16
0
 private void AssertUnion(int[] expectedKeys, IBTreeRange range1, IBTreeRange range2
                          )
 {
     BTreeAssert.AssertRange(expectedKeys, range1.Union(range2));
     BTreeAssert.AssertRange(expectedKeys, range2.Union(range1));
 }
Exemplo n.º 17
0
 public virtual void TestExtendToLastOf()
 {
     BTreeAssert.AssertRange(new int[] { 3, 4, 7 }, Range(3, 7));
     BTreeAssert.AssertRange(new int[] { 4, 7, 9 }, Range(4, 9));
 }
 private void AssertKeys(int[] keys)
 {
     BTreeAssert.AssertKeys(Trans(), _btree, keys);
 }
Exemplo n.º 19
0
 protected virtual void AssertEmpty(Transaction transaction)
 {
     BTreeAssert.AssertEmpty(transaction, _btree);
 }
Exemplo n.º 20
0
        private int[] NewBTreeNodeSizedArray(int value)
        {
            BTree btree = Btree();

            return(BTreeAssert.NewBTreeNodeSizedArray(btree, value));
        }
Exemplo n.º 21
0
 private void ExpectKeys(BTree btree, int[] keys)
 {
     BTreeAssert.AssertKeys(Trans(), btree, keys);
 }
Exemplo n.º 22
0
 protected virtual void AssertSingleElement(Transaction trans, int element)
 {
     BTreeAssert.AssertSingleElement(trans, _btree, element);
 }
Exemplo n.º 23
0
 protected virtual BTree NewBTree()
 {
     return(BTreeAssert.CreateIntKeyBTree(Container(), 0, BtreeNodeSize));
 }
Exemplo n.º 24
0
 private BTree NewBTreeWithNoNodeCaching()
 {
     return(BTreeAssert.CreateIntKeyBTree(Container(), 0, BtreeNodeSize));
 }