コード例 #1
0
        public void BTree_Enumerate()
        {
            var btree = new BTreeDictionary <string, int>();

            btree.Add("3", 3);
            btree.Add("2", 2);
            var e = btree.GetEnumerator();

            Assert.IsTrue(e.MoveNext());
            Assert.AreEqual("2", e.Current.Key);
            Assert.AreEqual(2, e.Current.Value);
            Assert.IsTrue(e.MoveNext());
            Assert.AreEqual("3", e.Current.Key);
            Assert.AreEqual(3, e.Current.Value);
            Assert.IsFalse(e.MoveNext());
        }
コード例 #2
0
        public void BTree_EnumeratorThrowIfMutated()
        {
            var btree = new BTreeDictionary <string, int>();

            btree.Add("3", 3);
            var e = btree.GetEnumerator();

            Assert.True(e.MoveNext());
            btree.Add("2", 2);
            try
            {
                e.MoveNext();
                Assert.Fail("Should have thrown exception");
            }
            catch (InvalidOperationException)
            {
            }
        }