2 // MonoTests.System.Collections.Generic.DictionaryTest
5 // Sureshkumar T (tsureshkumar@novell.com)
6 // Ankit Jain (radical@corewars.org)
7 // David Waite (mass@akuma.org)
9 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
10 // Copyright (C) 2005 David Waite (mass@akuma.org)
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 using System.Collections;
36 using System.Collections.Generic;
38 using System.Runtime.Serialization.Formatters.Binary;
40 using System.Threading;
42 using NUnit.Framework;
44 namespace MonoTests.System.Collections.Generic {
46 public class DictionaryTest {
50 public MyClass (int a, int b)
55 public override int GetHashCode ()
60 public override bool Equals (object obj)
62 if (!(obj is MyClass))
64 return ((MyClass)obj).Value == a;
74 Dictionary <string, object> _dictionary = null;
75 Dictionary <MyClass, MyClass> _dictionary2 = null;
76 Dictionary <int, int> _dictionary3 = null;
81 _dictionary = new Dictionary <string, object> ();
82 _dictionary2 = new Dictionary <MyClass, MyClass> ();
83 _dictionary3 = new Dictionary <int, int>();
87 public void AddTest ()
89 _dictionary.Add ("key1", "value");
90 Assert.AreEqual ("value", _dictionary ["key1"].ToString (), "Add failed!");
94 public void AddTest2 ()
96 MyClass m1 = new MyClass (10,5);
97 MyClass m2 = new MyClass (20,5);
98 MyClass m3 = new MyClass (12,3);
99 _dictionary2.Add (m1,m1);
100 _dictionary2.Add (m2, m2);
101 _dictionary2.Add (m3, m3);
102 Assert.AreEqual (20, _dictionary2 [m2].Value, "#1");
103 Assert.AreEqual (10, _dictionary2 [m1].Value, "#2");
104 Assert.AreEqual (12, _dictionary2 [m3].Value, "#3");
108 public void AddTest3 ()
110 _dictionary3.Add (1, 2);
111 _dictionary3.Add (2, 3);
112 _dictionary3.Add (3, 4);
113 Assert.AreEqual (2, _dictionary3[1], "#1");
114 Assert.AreEqual (3, _dictionary3[2], "#2");
115 Assert.AreEqual (4, _dictionary3[3], "#3");
118 [Test, ExpectedException(typeof(ArgumentNullException))]
119 public void AddNullTest ()
121 _dictionary.Add (null, "");
124 [Test, ExpectedException(typeof(ArgumentException))]
125 public void AddDuplicateTest ()
127 _dictionary.Add("foo", "bar");
128 _dictionary.Add("foo", "bar");
131 //Tests Add when resize takes place
133 public void AddLargeTest ()
135 int i, numElems = 50;
137 for (i = 0; i < numElems; i++)
139 _dictionary3.Add (i, i);
143 foreach (KeyValuePair <int, int> entry in _dictionary3)
148 Assert.AreEqual (i, numElems, "Add with resize failed!");
152 public void IndexerGetExistingTest ()
154 _dictionary.Add ("key1", "value");
155 Assert.AreEqual ("value", _dictionary ["key1"].ToString (), "Add failed!");
158 [Test, ExpectedException(typeof(KeyNotFoundException))]
159 public void IndexerGetNonExistingTest ()
161 object foo = _dictionary ["foo"];
164 [Test, ExpectedException(typeof(ArgumentNullException))]
165 public void IndexerGetNullTest()
167 object s = _dictionary[null];
171 public void IndexerSetExistingTest ()
173 _dictionary.Add ("key1", "value1");
174 _dictionary ["key1"] = "value2";
175 Assert.AreEqual (1, _dictionary.Count);
176 Assert.AreEqual ("value2", _dictionary ["key1"]);
180 public void IndexerSetNonExistingTest ()
182 _dictionary ["key1"] = "value1";
183 Assert.AreEqual (1, _dictionary.Count);
184 Assert.AreEqual ("value1", _dictionary ["key1"]);
188 public void RemoveTest ()
190 _dictionary.Add ("key1", "value1");
191 _dictionary.Add ("key2", "value2");
192 _dictionary.Add ("key3", "value3");
193 _dictionary.Add ("key4", "value4");
194 Assert.IsTrue (_dictionary.Remove ("key3"));
195 Assert.IsFalse (_dictionary.Remove ("foo"));
196 Assert.AreEqual (3, _dictionary.Count);
197 Assert.IsFalse (_dictionary.ContainsKey ("key3"));
201 public void RemoveTest2 ()
203 MyClass m1 = new MyClass (10, 5);
204 MyClass m2 = new MyClass (20, 5);
205 MyClass m3 = new MyClass (12, 3);
206 _dictionary2.Add (m1, m1);
207 _dictionary2.Add (m2, m2);
208 _dictionary2.Add (m3, m3);
209 _dictionary2.Remove (m1); // m2 is in rehash path
210 Assert.AreEqual (20, _dictionary2 [m2].Value, "#4");
215 [Category ("NotWorking")]
216 public void Remove_ZeroOut ()
218 object key = new object ();
219 object value = new object ();
221 WeakReference wrKey = new WeakReference (key);
222 WeakReference wrValue = new WeakReference (value);
224 Dictionary <object, object> dictionary = new Dictionary <object, object> ();
225 dictionary.Add (key, value);
226 dictionary.Remove (key);
233 Assert.IsNull (wrKey.Target, "#1");
234 Assert.IsNull (wrValue.Target, "#2");
237 [Test, ExpectedException(typeof(ArgumentNullException))]
238 public void IndexerSetNullTest()
240 _dictionary[null] = "bar";
244 public void ClearTest ()
246 _dictionary.Add ("key1", "value1");
247 _dictionary.Add ("key2", "value2");
248 _dictionary.Add ("key3", "value3");
249 _dictionary.Add ("key4", "value4");
250 _dictionary.Clear ();
251 Assert.AreEqual (0, _dictionary.Count, "Clear method failed!");
252 Assert.IsFalse (_dictionary.ContainsKey ("key2"));
256 [Category ("NotWorking")]
257 public void Clear_ZeroOut ()
259 object key = new object ();
260 object value = new object ();
262 WeakReference wrKey = new WeakReference (key);
263 WeakReference wrValue = new WeakReference (value);
265 Dictionary <object, object> dictionary = new Dictionary <object, object> ();
266 dictionary.Add (key, value);
274 Assert.IsNull (wrKey.Target, "#1");
275 Assert.IsNull (wrValue.Target, "#2");
279 public void ContainsKeyTest ()
281 _dictionary.Add ("key1", "value1");
282 _dictionary.Add ("key2", "value2");
283 _dictionary.Add ("key3", "value3");
284 _dictionary.Add ("key4", "value4");
285 bool contains = _dictionary.ContainsKey ("key4");
286 Assert.IsTrue (contains, "ContainsKey does not return correct value!");
287 contains = _dictionary.ContainsKey ("key5");
288 Assert.IsFalse (contains, "ContainsKey for non existant does not return correct value!");
292 public void ContainsValueTest ()
294 _dictionary.Add ("key1", "value1");
295 _dictionary.Add ("key2", "value2");
296 _dictionary.Add ("key3", "value3");
297 _dictionary.Add ("key4", "value4");
298 bool contains = _dictionary.ContainsValue ("value2");
299 Assert.IsTrue(contains, "ContainsValue does not return correct value!");
300 contains = _dictionary.ContainsValue ("@@daisofja@@");
301 Assert.IsFalse (contains, "ContainsValue for non existant does not return correct value!");
305 public void TryGetValueTest()
307 _dictionary.Add ("key1", "value1");
308 _dictionary.Add ("key2", "value2");
309 _dictionary.Add ("key3", "value3");
310 _dictionary.Add ("key4", "value4");
312 bool retrieved = _dictionary.TryGetValue ("key4", out value);
313 Assert.IsTrue (retrieved);
314 Assert.AreEqual ("value4", (string)value, "TryGetValue does not return value!");
316 retrieved = _dictionary.TryGetValue ("key7", out value);
317 Assert.IsFalse (retrieved);
318 Assert.IsNull (value, "value for non existant value should be null!");
322 public void ValueTypeTest ()
324 Dictionary <int, float> dict = new Dictionary <int, float> ();
325 dict.Add (10, 10.3f);
326 dict.Add (11, 10.4f);
327 dict.Add (12, 10.5f);
328 Assert.AreEqual (10.4f, dict [11], "#5");
336 public MyTest (string name, int number)
342 public override int GetHashCode ()
344 return Name.GetHashCode () ^ RollNo;
347 public override bool Equals (object obj)
349 MyTest myt = obj as MyTest;
350 return myt.Name.Equals (this.Name) &&
351 myt.RollNo.Equals (this.RollNo);
356 public void ObjectAsKeyTest ()
358 Dictionary <object, object> dict = new Dictionary <object, object> ();
359 MyTest key1, key2, key3;
360 dict.Add ( (key1 = new MyTest ("key1", 234)), "value1");
361 dict.Add ( (key2 = new MyTest ("key2", 444)), "value2");
362 dict.Add ( (key3 = new MyTest ("key3", 5655)), "value3");
364 Assert.AreEqual ("value2", dict [key2], "value is not returned!");
365 Assert.AreEqual ("value3", dict [key3], "neg: exception should not be thrown!");
368 [Test, ExpectedException (typeof (ArgumentException))]
369 public void IDictionaryAddTest ()
371 IDictionary iDict = _dictionary as IDictionary;
372 iDict.Add ("key1", "value1");
373 iDict.Add ("key2", "value3");
374 Assert.AreEqual (2, iDict.Count, "IDictioanry interface add is not working!");
377 iDict.Add (12, "value");
378 iDict.Add ("key", 34);
382 public void IEnumeratorTest ()
384 _dictionary.Add ("key1", "value1");
385 _dictionary.Add ("key2", "value2");
386 _dictionary.Add ("key3", "value3");
387 _dictionary.Add ("key4", "value4");
388 IEnumerator itr = ((IEnumerable)_dictionary).GetEnumerator ();
389 while (itr.MoveNext ()) {
390 object o = itr.Current;
391 Assert.AreEqual (typeof (KeyValuePair<string,object>), o.GetType (), "Current should return a type of KeyValuePair");
392 KeyValuePair<string,object> entry = (KeyValuePair<string,object>) itr.Current;
394 Assert.AreEqual ("value4", _dictionary ["key4"].ToString (), "");
399 public void IEnumeratorGenericTest ()
401 _dictionary.Add ("key1", "value1");
402 _dictionary.Add ("key2", "value2");
403 _dictionary.Add ("key3", "value3");
404 _dictionary.Add ("key4", "value4");
405 IEnumerator <KeyValuePair <string, object>> itr = ((IEnumerable <KeyValuePair <string, object>>)_dictionary).GetEnumerator ();
406 while (itr.MoveNext ()) {
407 object o = itr.Current;
408 Assert.AreEqual (typeof (KeyValuePair <string, object>), o.GetType (), "Current should return a type of KeyValuePair<object,string>");
409 KeyValuePair <string, object> entry = (KeyValuePair <string, object>)itr.Current;
411 Assert.AreEqual ("value4", _dictionary ["key4"].ToString (), "");
415 public void IDictionaryEnumeratorTest ()
417 _dictionary.Add ("key1", "value1");
418 _dictionary.Add ("key2", "value2");
419 _dictionary.Add ("key3", "value3");
420 _dictionary.Add ("key4", "value4");
421 IDictionaryEnumerator itr = ((IDictionary)_dictionary).GetEnumerator ();
422 while (itr.MoveNext ()) {
423 object o = itr.Current;
424 Assert.AreEqual (typeof (DictionaryEntry), o.GetType (), "Current should return a type of DictionaryEntry");
425 DictionaryEntry entry = (DictionaryEntry) itr.Current;
427 Assert.AreEqual ("value4", _dictionary ["key4"].ToString (), "");
431 public void ForEachTest ()
433 _dictionary.Add ("key1", "value1");
434 _dictionary.Add ("key2", "value2");
435 _dictionary.Add ("key3", "value3");
436 _dictionary.Add ("key4", "value4");
439 foreach (KeyValuePair <string, object> entry in _dictionary)
441 Assert.AreEqual(4, i, "fail1: foreach entry failed!");
444 foreach (KeyValuePair <string, object> entry in ((IEnumerable)_dictionary))
446 Assert.AreEqual(4, i, "fail2: foreach entry failed!");
449 foreach (DictionaryEntry entry in ((IDictionary)_dictionary))
451 Assert.AreEqual (4, i, "fail3: foreach entry failed!");
455 public void ResizeTest ()
457 Dictionary <string, object> dictionary = new Dictionary <string, object> (3);
458 dictionary.Add ("key1", "value1");
459 dictionary.Add ("key2", "value2");
460 dictionary.Add ("key3", "value3");
462 Assert.AreEqual (3, dictionary.Count);
464 dictionary.Add ("key4", "value4");
465 Assert.AreEqual (4, dictionary.Count);
466 Assert.AreEqual ("value1", dictionary ["key1"].ToString (), "");
467 Assert.AreEqual ("value2", dictionary ["key2"].ToString (), "");
468 Assert.AreEqual ("value4", dictionary ["key4"].ToString (), "");
469 Assert.AreEqual ("value3", dictionary ["key3"].ToString (), "");
473 public void KeyCollectionTest ()
475 _dictionary.Add ("key1", "value1");
476 _dictionary.Add ("key2", "value2");
477 _dictionary.Add ("key3", "value3");
478 _dictionary.Add ("key4", "value4");
480 ICollection <string> keys = ((IDictionary <string, object>)_dictionary).Keys;
481 Assert.AreEqual (4, keys.Count);
483 foreach (string key in keys)
487 Assert.AreEqual(4, i);
491 public void KeyValueEnumeratorTest ()
493 IDictionary<int, int> d = new Dictionary<int, int>();
495 // Values are chosen such that two keys map to the same bucket.
496 // Default dictionary table size == 10
501 Assert.AreEqual (d.Count, d.Keys.Count, "d and d.Keys don't appear to match");
502 Assert.AreEqual (d.Values.Count, d.Keys.Count, "d.Keys and d.Values don't appear to match");
505 foreach (int i in d.Values)
507 Assert.AreEqual (count, d.Values.Count, "d.Values doesn't have the correct number of elements");
510 foreach (int i in d.Keys)
512 Assert.AreEqual (count, d.Keys.Count, "d.Keys doesn't have the correct number of elements");
516 foreach (int i in d.Keys) {
518 if (count++ >= nkeys)
519 Assert.Fail ("Reading a value appears to trash enumerator state");
524 public void SliceCollectionsEnumeratorTest ()
526 Dictionary<string, int> values = new Dictionary<string, int> ();
528 IEnumerator <string> ke = values.Keys.GetEnumerator ();
529 IEnumerator <int> ve = values.Values.GetEnumerator ();
531 Assert.IsTrue (ke is Dictionary<string, int>.KeyCollection.Enumerator);
532 Assert.IsTrue (ve is Dictionary<string, int>.ValueCollection.Enumerator);
536 public void PlainEnumeratorReturnTest ()
538 // Test that we return a KeyValuePair even for non-generic dictionary iteration
539 _dictionary["foo"] = "bar";
540 IEnumerator<KeyValuePair<string, object>> enumerator = _dictionary.GetEnumerator();
541 Assert.IsTrue(enumerator.MoveNext(), "#1");
542 Assert.AreEqual (typeof (KeyValuePair<string,object>), ((IEnumerator)enumerator).Current.GetType (), "#2");
543 Assert.AreEqual (typeof (DictionaryEntry), ((IDictionaryEnumerator)enumerator).Entry.GetType (), "#3");
544 Assert.AreEqual (typeof (KeyValuePair<string,object>), ((IDictionaryEnumerator)enumerator).Current.GetType (), "#4");
545 Assert.AreEqual (typeof (KeyValuePair<string,object>), ((object) enumerator.Current).GetType (), "#5");
548 [Test, ExpectedException (typeof (InvalidOperationException))]
549 public void FailFastTest1 ()
551 Dictionary<int, int> d = new Dictionary<int, int> ();
554 foreach (KeyValuePair<int, int> kv in d) {
555 d [kv.Key + 1] = kv.Value + 1;
557 Assert.Fail ("Should not be reached");
559 Assert.Fail ("Should not be reached");
562 [Test, ExpectedException (typeof (InvalidOperationException))]
563 public void FailFastTest2 ()
565 Dictionary<int, int> d = new Dictionary<int, int> ();
568 foreach (int i in d.Keys) {
571 Assert.Fail ("Should not be reached");
573 Assert.Fail ("Should not be reached");
576 [Test, ExpectedException (typeof (InvalidOperationException))]
577 public void FailFastTest3 ()
579 Dictionary<int, int> d = new Dictionary<int, int> ();
582 foreach (int i in d.Keys) {
585 Assert.Fail ("Should not be reached");
587 Assert.Fail ("Should not be reached");
591 [Category ("TargetJvmNotWorking")] // BUGBUG Very very slow on TARGET_JVM.
592 public void SerializationTest()
594 for (int i = 0; i < 50; i++)
596 _dictionary3.Add(i, i);
599 BinaryFormatter formatter = new BinaryFormatter();
600 MemoryStream stream = new MemoryStream();
601 formatter.Serialize(stream, _dictionary3);
604 object deserialized = formatter.Deserialize(stream);
606 Assert.IsNotNull(deserialized);
607 Assert.IsFalse(deserialized == _dictionary3);
609 Assert.IsTrue(deserialized is Dictionary<int, int>);
610 Dictionary<int, int> d3 = deserialized as Dictionary<int, int>;
612 Assert.AreEqual(50, d3.Count);
613 for (int i = 0; i < 50; i++)
615 Assert.AreEqual(i, d3[i]);
620 public void ZeroCapacity ()
622 Dictionary<int, int> x = new Dictionary <int, int> (0);
625 x = new Dictionary <int, int> (0);
628 x = new Dictionary <int, int> (0);
631 x = new Dictionary <int, int> (0);
634 } catch (KeyNotFoundException){
638 b = x.ContainsKey (10);
639 b = x.ContainsValue (10);
641 x = new Dictionary <int, int> (0);
644 x = new Dictionary <int, int> (0);
646 x.TryGetValue (1, out intv);
649 object ob = x.Values;
650 foreach (KeyValuePair<int,int> a in x){
655 public void Empty_KeysValues_CopyTo ()
657 Dictionary<int, int> d = new Dictionary<int, int> ();
658 int[] array = new int[1];
659 d.Keys.CopyTo (array, array.Length);
660 d.Values.CopyTo (array, array.Length);
664 public void Empty_CopyTo ()
666 Dictionary<int, int> d = new Dictionary<int, int> ();
667 ICollection c = (ICollection) d;
668 DictionaryEntry [] array = new DictionaryEntry [1];
669 c.CopyTo (array, array.Length);
671 ICollection<KeyValuePair<int,int>> c2 = d;
672 KeyValuePair<int,int> [] array2 = new KeyValuePair<int,int> [1];
673 c2.CopyTo (array2, array2.Length);
677 public void IDictionary_Contains ()
679 IDictionary d = new Dictionary<int, int> ();
681 Assert.IsTrue (d.Contains (1));
682 Assert.IsFalse (d.Contains (2));
683 Assert.IsFalse (d.Contains ("x"));
686 [Test, ExpectedException (typeof (ArgumentNullException))]
687 public void IDictionary_Contains2 ()
689 IDictionary d = new Dictionary<int, int> ();
693 [Test, ExpectedException (typeof (ArgumentNullException))]
694 public void IDictionary_Add1 ()
696 IDictionary d = new Dictionary<int, int> ();
700 [Test, ExpectedException (typeof (ArgumentException))]
701 public void IDictionary_Add2 ()
703 IDictionary d = new Dictionary<int, int> ();
707 [Test, ExpectedException (typeof (ArgumentException))]
708 public void IDictionary_Add3 ()
710 IDictionary d = new Dictionary<int, int> ();
715 public void IDictionary_Add_Null ()
717 IDictionary d = new Dictionary<int, string> ();
721 Assert.IsNull (d [1]);
722 Assert.IsNull (d [2]);
726 [ExpectedException (typeof (ArgumentException))]
727 public void IDictionary_Add_Null_2 ()
729 IDictionary d = new Dictionary<int, int> ();
734 public void IDictionary_Remove1 ()
736 IDictionary d = new Dictionary<int, int> ();
743 [Test, ExpectedException (typeof (ArgumentNullException))]
744 public void IDictionary_Remove2 ()
746 IDictionary d = new Dictionary<int, int> ();
751 public void IDictionary_IndexerGetNonExistingTest ()
753 IDictionary d = new Dictionary<int, int> ();
756 Assert.IsNull(d["foo"]);
759 [Test] // bug #332534
760 public void Dictionary_MoveNext ()
762 Dictionary<int,int> a = new Dictionary<int,int>();
766 IEnumerator en = a.GetEnumerator();
767 for (int i = 1; i < 10; i++)
772 public void CopyToArray ()
774 Dictionary<string, string> test = new Dictionary<string, string> ();
775 test.Add ("monkey", "singe");
776 test.Add ("singe", "mono");
777 test.Add ("mono", "monkey");
778 Assert.AreEqual (3, test.Keys.Count, "Dictionary.Count");
780 ArrayList list = new ArrayList (test.Keys);
781 Assert.AreEqual (3, list.Count, "ArrayList.Count");
782 Assert.IsTrue (list.Contains ("monkey"), "monkey");
783 Assert.IsTrue (list.Contains ("singe"), "singe");
784 Assert.IsTrue (list.Contains ("mono"), "mono");
788 public void KeyObjectMustNotGetChangedIfKeyAlreadyExists ()
790 Dictionary<String, int> d = new Dictionary<string, int> ();
792 string s2 = "Tes" + "T".ToLowerInvariant();
795 string comp = String.Empty;
796 foreach (String s in d.Keys)
798 Assert.IsTrue (Object.ReferenceEquals (s1, comp));
802 public void ResetKeysEnumerator ()
804 Dictionary<string, string> test = new Dictionary<string, string> ();
805 test.Add ("monkey", "singe");
806 test.Add ("singe", "mono");
807 test.Add ("mono", "monkey");
809 IEnumerator enumerator = test.Keys.GetEnumerator ();
811 Assert.IsTrue (enumerator.MoveNext ());
812 Assert.IsTrue (enumerator.MoveNext ());
816 Assert.IsTrue (enumerator.MoveNext ());
817 Assert.IsTrue (enumerator.MoveNext ());
818 Assert.IsTrue (enumerator.MoveNext ());
819 Assert.IsFalse (enumerator.MoveNext ());
823 public void ResetValuesEnumerator ()
825 Dictionary<string, string> test = new Dictionary<string, string> ();
826 test.Add ("monkey", "singe");
827 test.Add ("singe", "mono");
828 test.Add ("mono", "monkey");
830 IEnumerator enumerator = test.Values.GetEnumerator ();
832 Assert.IsTrue (enumerator.MoveNext ());
833 Assert.IsTrue (enumerator.MoveNext ());
837 Assert.IsTrue (enumerator.MoveNext ());
838 Assert.IsTrue (enumerator.MoveNext ());
839 Assert.IsTrue (enumerator.MoveNext ());
840 Assert.IsFalse (enumerator.MoveNext ());
844 public void ResetShimEnumerator ()
846 IDictionary test = new Dictionary<string, string> ();
847 test.Add ("monkey", "singe");
848 test.Add ("singe", "mono");
849 test.Add ("mono", "monkey");
851 IEnumerator enumerator = test.GetEnumerator ();
853 Assert.IsTrue (enumerator.MoveNext ());
854 Assert.IsTrue (enumerator.MoveNext ());
858 Assert.IsTrue (enumerator.MoveNext ());
859 Assert.IsTrue (enumerator.MoveNext ());
860 Assert.IsTrue (enumerator.MoveNext ());
861 Assert.IsFalse (enumerator.MoveNext ());