Bringing C5 1.0 into the main branch.
[mono.git] / mcs / class / Mono.C5 / Test / templates / Events.cs
1 /*\r
2  Copyright (c) 2003-2006 Niels Kokholm and Peter Sestoft\r
3  Permission is hereby granted, free of charge, to any person obtaining a copy\r
4  of this software and associated documentation files (the "Software"), to deal\r
5  in the Software without restriction, including without limitation the rights\r
6  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
7  copies of the Software, and to permit persons to whom the Software is\r
8  furnished to do so, subject to the following conditions:\r
9  \r
10  The above copyright notice and this permission notice shall be included in\r
11  all copies or substantial portions of the Software.\r
12  \r
13  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
14  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
15  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
16  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
17  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
18  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
19  SOFTWARE.\r
20 */\r
21 \r
22 using System;\r
23 using C5;\r
24 using NUnit.Framework;\r
25 using SCG = System.Collections.Generic;\r
26 using System.Reflection;\r
27 \r
28 namespace C5UnitTests.Templates.Events\r
29 {\r
30   public abstract class CollectionValueTester<TCollection, TItem> : GenericCollectionTester<TCollection, EventTypeEnum>\r
31     where TCollection : ICollectionValue<TItem>\r
32   {\r
33     protected TCollection collection;\r
34     protected CollectionEventList<TItem> seen;\r
35     protected EventTypeEnum listenTo;\r
36     protected void listen() { seen.Listen(collection, listenTo); }\r
37 \r
38     public override void SetUp(TCollection list, EventTypeEnum testSpec)\r
39     {\r
40       this.collection = list;\r
41       listenTo = testSpec;\r
42       seen = new CollectionEventList<TItem>(EqualityComparer<TItem>.Default);\r
43     }\r
44 \r
45     public SCG.IEnumerable<EventTypeEnum> SpecsBasic\r
46     {\r
47       get\r
48       {\r
49         CircularQueue<EventTypeEnum> specs = new CircularQueue<EventTypeEnum>();\r
50         //foreach (EventTypeEnum listenTo in Enum.GetValues(typeof(EventTypeEnum)))\r
51         //  if ((listenTo & ~EventTypeEnum.Basic) == 0)\r
52         //    specs.Enqueue(listenTo);\r
53         //specs.Enqueue(EventTypeEnum.Added | EventTypeEnum.Removed);\r
54         for (int spec = 0; spec <= (int)EventTypeEnum.Basic; spec++)\r
55           specs.Enqueue((EventTypeEnum)spec);\r
56         return specs;\r
57       }\r
58     }\r
59     public SCG.IEnumerable<EventTypeEnum> SpecsAll\r
60     {\r
61       get\r
62       {\r
63         CircularQueue<EventTypeEnum> specs = new CircularQueue<EventTypeEnum>();\r
64         //foreach (EventTypeEnum listenTo in Enum.GetValues(typeof(EventTypeEnum)))\r
65         //  specs.Enqueue(listenTo);\r
66         //specs.Enqueue(EventTypeEnum.Added | EventTypeEnum.Removed);\r
67 \r
68         for (int spec = 0; spec <= (int)EventTypeEnum.All; spec++)\r
69           specs.Enqueue((EventTypeEnum)spec);\r
70         return specs;\r
71       }\r
72     }\r
73   }\r
74   public abstract class CollectionValueTester<U> : CollectionValueTester<U, int> where U : ICollectionValue<int>\r
75   {\r
76   }\r
77 \r
78   public class ExtensibleTester<U> : CollectionValueTester<U> where U : IExtensible<int>\r
79   {\r
80     public override SCG.IEnumerable<EventTypeEnum> GetSpecs()\r
81     {\r
82       return SpecsBasic;\r
83     }\r
84     [Test]\r
85     public virtual void Listenable()\r
86     {\r
87       Assert.AreEqual(EventTypeEnum.Basic, collection.ListenableEvents);\r
88       Assert.AreEqual(EventTypeEnum.None, collection.ActiveEvents);\r
89       listen();\r
90       Assert.AreEqual(listenTo, collection.ActiveEvents);\r
91     }\r
92 \r
93     [Test]\r
94     public void Add()\r
95     {\r
96       listen();\r
97       seen.Check(new CollectionEvent<int>[0]);\r
98       collection.Add(23);\r
99       seen.Check(new CollectionEvent<int>[] {\r
100           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(23, 1), collection),\r
101           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
102     }\r
103 \r
104     [Test]\r
105     public void AddAll()\r
106     {\r
107       for (int i = 0; i < 10; i++)\r
108       {\r
109         collection.Add(10 * i + 5);\r
110       }\r
111       listen();\r
112       collection.AddAll<int>(new int[] { 45, 200, 56, 67 });\r
113       seen.Check(collection.AllowsDuplicates ?\r
114         collection.DuplicatesByCounting ?\r
115           new CollectionEvent<int>[] {\r
116           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(45, 1), collection),\r
117           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(200, 1), collection),\r
118           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(55, 1), collection),\r
119           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(65, 1), collection),\r
120           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)}\r
121         :\r
122           new CollectionEvent<int>[] {\r
123           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(45, 1), collection),\r
124           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(200, 1), collection),\r
125           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(56, 1), collection),\r
126           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(67, 1), collection),\r
127           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)}\r
128           :\r
129           new CollectionEvent<int>[] {\r
130           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(200, 1), collection),\r
131           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
132       collection.AddAll<int>(new int[] { });\r
133       seen.Check(new CollectionEvent<int>[] { });\r
134     }\r
135 \r
136   }\r
137 \r
138   public class CollectionTester<U> : ExtensibleTester<U> where U : ICollection<int>\r
139   {\r
140     [Test]\r
141     public void Update()\r
142     {\r
143       collection.Add(4); collection.Add(54); collection.Add(56); collection.Add(8);\r
144       listen();\r
145       collection.Update(53);\r
146       seen.Check(\r
147         collection.AllowsDuplicates ?\r
148         collection.DuplicatesByCounting ?\r
149         new CollectionEvent<int>[] {\r
150           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(54, 2), collection),\r
151           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(53, 2), collection),\r
152           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)\r
153           }\r
154         : new CollectionEvent<int>[] {\r
155           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(54, 1), collection),\r
156           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(53, 1), collection),\r
157           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)\r
158           }\r
159         : new CollectionEvent<int>[] {\r
160           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(54, 1), collection),\r
161           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(53, 1), collection),\r
162           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)\r
163           });\r
164       collection.Update(67);\r
165       seen.Check(new CollectionEvent<int>[] { });\r
166     }\r
167 \r
168     [Test]\r
169     public void FindOrAdd()\r
170     {\r
171       collection.Add(4); collection.Add(56); collection.Add(8);\r
172       listen();\r
173       int val = 53;\r
174       collection.FindOrAdd(ref val);\r
175       seen.Check(new CollectionEvent<int>[] { });\r
176       val = 67;\r
177       collection.FindOrAdd(ref val);\r
178       seen.Check(new CollectionEvent<int>[] { \r
179           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(67, 1), collection),\r
180           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)\r
181         });\r
182     }\r
183 \r
184     [Test]\r
185     public void UpdateOrAdd()\r
186     {\r
187       collection.Add(4); collection.Add(56); collection.Add(8);\r
188       listen();\r
189       int val = 53;\r
190       collection.UpdateOrAdd(val);\r
191       seen.Check(new CollectionEvent<int>[] {\r
192           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(56, 1), collection),\r
193           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(53, 1), collection),\r
194           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)\r
195         });\r
196       val = 67;\r
197       collection.UpdateOrAdd(val);\r
198       seen.Check(new CollectionEvent<int>[] { \r
199           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(67, 1), collection),\r
200           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)\r
201         });\r
202       collection.UpdateOrAdd(51, out val);\r
203       seen.Check(new CollectionEvent<int>[] {\r
204           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(53, 1), collection),\r
205           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(51, 1), collection),\r
206           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)\r
207         });\r
208       val = 67;\r
209       collection.UpdateOrAdd(81, out val);\r
210       seen.Check(new CollectionEvent<int>[] { \r
211           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(81, 1), collection),\r
212           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)\r
213         });\r
214     }\r
215 \r
216     [Test]\r
217     public void RemoveItem()\r
218     {\r
219       collection.Add(4); collection.Add(56); collection.Add(18);\r
220       listen();\r
221       collection.Remove(53);\r
222       seen.Check(new CollectionEvent<int>[] {\r
223           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(56, 1), collection),\r
224           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
225       collection.Remove(11);\r
226       seen.Check(new CollectionEvent<int>[] {\r
227           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(18, 1), collection),\r
228           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
229     }\r
230 \r
231     [Test]\r
232     public void RemoveAll()\r
233     {\r
234       for (int i = 0; i < 10; i++)\r
235       {\r
236         collection.Add(10 * i + 5);\r
237       }\r
238       listen();\r
239       collection.RemoveAll<int>(new int[] { 32, 187, 45 });\r
240       //TODO: the order depends on internals of the HashSet\r
241       seen.Check(new CollectionEvent<int>[] {\r
242           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(35, 1), collection),\r
243           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(45, 1), collection),\r
244           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
245       collection.RemoveAll<int>(new int[] { 200, 300 });\r
246       seen.Check(new CollectionEvent<int>[] { });\r
247     }\r
248 \r
249     [Test]\r
250     public void RetainAll()\r
251     {\r
252       for (int i = 0; i < 10; i++)\r
253       {\r
254         collection.Add(10 * i + 5);\r
255       }\r
256       listen();\r
257       collection.RetainAll<int>(new int[] { 32, 187, 45, 62, 75, 82, 95, 2 });\r
258       seen.Check(new CollectionEvent<int>[] {\r
259           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(15, 1), collection),\r
260           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(25, 1), collection),\r
261           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(55, 1), collection),\r
262           //new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(75, 1), collection),\r
263           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
264       collection.RetainAll<int>(new int[] { 32, 187, 45, 62, 75, 82, 95, 2 });\r
265       seen.Check(new CollectionEvent<int>[] { });\r
266     }\r
267 \r
268     [Test]\r
269     public void RemoveAllCopies()\r
270     {\r
271       for (int i = 0; i < 10; i++)\r
272       {\r
273         collection.Add(3 * i + 5);\r
274       }\r
275       listen();\r
276       collection.RemoveAllCopies(14);\r
277       seen.Check(\r
278         collection.AllowsDuplicates ?\r
279           collection.DuplicatesByCounting ?\r
280             new CollectionEvent<int>[] {\r
281               new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(11, 3), collection),\r
282               new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)}\r
283           :\r
284           new CollectionEvent<int>[] {\r
285             new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(11, 1), collection),\r
286             new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(14, 1), collection),\r
287             new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(17, 1), collection),\r
288             new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)}\r
289         :\r
290         new CollectionEvent<int>[] {\r
291           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(11, 1), collection),\r
292           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
293       collection.RemoveAllCopies(14);\r
294       seen.Check(new CollectionEvent<int>[] { });\r
295     }\r
296 \r
297     [Test]\r
298     public virtual void Clear()\r
299     {\r
300       collection.Add(4); collection.Add(56); collection.Add(8);\r
301       listen();\r
302       collection.Clear();\r
303       seen.Check(new CollectionEvent<int>[] {\r
304           new CollectionEvent<int>(EventTypeEnum.Cleared, new ClearedEventArgs(true, collection.AllowsDuplicates ? 3 : 2), collection),\r
305           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)\r
306         });\r
307       collection.Clear();\r
308       seen.Check(new CollectionEvent<int>[] { });\r
309     }\r
310 \r
311   }\r
312 \r
313   public class IndexedTester<U> : CollectionTester<U> where U : IIndexed<int>\r
314   {\r
315     [Test]\r
316     public void RemoveAt()\r
317     {\r
318       collection.Add(4); collection.Add(16); collection.Add(28);\r
319       listen();\r
320       collection.RemoveAt(1);\r
321       seen.Check(new CollectionEvent<int>[] {\r
322           new CollectionEvent<int>(EventTypeEnum.RemovedAt, new ItemAtEventArgs<int>(16,1), collection),\r
323           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(16, 1), collection),\r
324           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
325     }\r
326 \r
327     [Test]\r
328     public void RemoveInterval()\r
329     {\r
330       collection.Add(4); collection.Add(56); collection.Add(18);\r
331       listen();\r
332       collection.RemoveInterval(1, 2);\r
333       seen.Check(new CollectionEvent<int>[] {\r
334         collection is IList<int> ?\r
335            new CollectionEvent<int>(EventTypeEnum.Cleared, new ClearedRangeEventArgs(false,2,1), collection):\r
336            new CollectionEvent<int>(EventTypeEnum.Cleared, new ClearedEventArgs(false,2), collection),\r
337          new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)\r
338         });\r
339       collection.RemoveInterval(1, 0);\r
340       seen.Check(new CollectionEvent<int>[] { });\r
341     }\r
342   }\r
343 \r
344   public class SortedIndexedTester<U> : IndexedTester<U> where U : IIndexedSorted<int>\r
345   {\r
346     [Test]\r
347     public void DeleteMinMax()\r
348     {\r
349       collection.Add(34);\r
350       collection.Add(56);\r
351       collection.Add(34);\r
352       collection.Add(12);\r
353       listen();\r
354       collection.DeleteMax();\r
355       seen.Check(new CollectionEvent<int>[] {\r
356         new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(56, 1), collection),\r
357         new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection), \r
358       });\r
359       collection.DeleteMin();\r
360       seen.Check(new CollectionEvent<int>[] {\r
361         new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(12, 1), collection), \r
362         new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection), \r
363       });\r
364     }\r
365 \r
366     [Test]\r
367     public void AddSorted()\r
368     {\r
369       listen();\r
370       collection.AddSorted(collection.AllowsDuplicates ? new int[] { 31, 62, 63, 93 } : new int[] { 31, 62, 93 });\r
371       seen.Check(collection.AllowsDuplicates ?\r
372         collection.DuplicatesByCounting ?\r
373           new CollectionEvent<int>[] {\r
374           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(31, 1), collection),\r
375           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(62, 1), collection),\r
376           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(62, 1), collection),\r
377           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(93, 1), collection),\r
378           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)}\r
379         :\r
380           new CollectionEvent<int>[] {\r
381           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(31, 1), collection),\r
382           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(62, 1), collection),\r
383           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(63, 1), collection),\r
384           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(93, 1), collection),\r
385           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)}\r
386           :\r
387           new CollectionEvent<int>[] {\r
388           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(31, 1), collection),\r
389           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(62, 1), collection),\r
390           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(93, 1), collection),\r
391           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
392       collection.AddSorted(new int[] { });\r
393       seen.Check(new CollectionEvent<int>[] { });\r
394     }\r
395 \r
396     [Test]\r
397     public void RemoveRange()\r
398     {\r
399       for (int i = 0; i < 20; i++)\r
400         collection.Add(i * 10 + 5);\r
401       listen();\r
402       collection.RemoveRangeFrom(173);\r
403       //TODO: fix order to remove in:\r
404       seen.Check(\r
405           new CollectionEvent<int>[] {\r
406           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(195, 1), collection),\r
407           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(185, 1), collection),\r
408           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(175, 1), collection),\r
409           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
410       collection.RemoveRangeFromTo(83, 113);\r
411       seen.Check(\r
412           new CollectionEvent<int>[] {\r
413           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(105, 1), collection),\r
414           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(95, 1), collection),\r
415           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(85, 1), collection),\r
416           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
417       collection.RemoveRangeTo(33);\r
418       seen.Check(\r
419           new CollectionEvent<int>[] {\r
420           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(5, 1), collection),\r
421           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(15, 1), collection),\r
422           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(25, 1), collection),\r
423           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
424       collection.RemoveRangeFrom(173);\r
425       seen.Check(new CollectionEvent<int>[] { });\r
426       collection.RemoveRangeFromTo(83, 113);\r
427       seen.Check(new CollectionEvent<int>[] { });\r
428       collection.RemoveRangeTo(33);\r
429       seen.Check(new CollectionEvent<int>[] { });\r
430     }\r
431   }\r
432 \r
433   public class ListTester<U> : IndexedTester<U> where U : IList<int>\r
434   {\r
435     public override SCG.IEnumerable<EventTypeEnum> GetSpecs()\r
436     {\r
437       return SpecsAll;\r
438     }\r
439 \r
440     [Test]\r
441     public override void Listenable()\r
442     {\r
443       Assert.AreEqual(EventTypeEnum.All, collection.ListenableEvents);\r
444       Assert.AreEqual(EventTypeEnum.None, collection.ActiveEvents);\r
445       listen();\r
446       Assert.AreEqual(listenTo, collection.ActiveEvents);\r
447     }\r
448     [Test]\r
449     public void SetThis()\r
450     {\r
451       collection.Add(4); collection.Add(56); collection.Add(8);\r
452       listen();\r
453       collection[1] = 45;\r
454       seen.Check(new CollectionEvent<int>[] {\r
455           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(56, 1), collection),\r
456           new CollectionEvent<int>(EventTypeEnum.RemovedAt, new ItemAtEventArgs<int>(56,1), collection),\r
457           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(45, 1), collection),\r
458           new CollectionEvent<int>(EventTypeEnum.Inserted, new ItemAtEventArgs<int>(45,1), collection),\r
459           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)\r
460           });\r
461     }\r
462 \r
463     [Test]\r
464     public void Insert()\r
465     {\r
466       collection.Add(4); collection.Add(56); collection.Add(8);\r
467       listen();\r
468       collection.Insert(1, 45);\r
469       seen.Check(new CollectionEvent<int>[] {\r
470           new CollectionEvent<int>(EventTypeEnum.Inserted, new ItemAtEventArgs<int>(45,1), collection),\r
471           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(45, 1), collection),\r
472           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)\r
473           });\r
474     }\r
475 \r
476     [Test]\r
477     public void InsertAll()\r
478     {\r
479       collection.Add(4); collection.Add(56); collection.Add(8);\r
480       listen();\r
481       collection.InsertAll<int>(1, new int[] { 666, 777, 888 });\r
482       //seen.Print(Console.Error);\r
483       seen.Check(new CollectionEvent<int>[] {\r
484           new CollectionEvent<int>(EventTypeEnum.Inserted, new ItemAtEventArgs<int>(666,1), collection),\r
485           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(666, 1), collection),\r
486           new CollectionEvent<int>(EventTypeEnum.Inserted, new ItemAtEventArgs<int>(777,2), collection),\r
487           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(777, 1), collection),\r
488           new CollectionEvent<int>(EventTypeEnum.Inserted, new ItemAtEventArgs<int>(888,3), collection),\r
489           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(888, 1), collection),\r
490           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)\r
491           });\r
492       collection.InsertAll<int>(1, new int[] { });\r
493       seen.Check(new CollectionEvent<int>[] { });\r
494     }\r
495 \r
496     [Test]\r
497     public void InsertFirstLast()\r
498     {\r
499       collection.Add(4); collection.Add(56); collection.Add(18);\r
500       listen();\r
501       collection.InsertFirst(45);\r
502       seen.Check(new CollectionEvent<int>[] {\r
503           new CollectionEvent<int>(EventTypeEnum.Inserted, new ItemAtEventArgs<int>(45,0), collection),\r
504           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(45, 1), collection),\r
505           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)\r
506           });\r
507       collection.InsertLast(88);\r
508       seen.Check(new CollectionEvent<int>[] {\r
509           new CollectionEvent<int>(EventTypeEnum.Inserted, new ItemAtEventArgs<int>(88,4), collection),\r
510           new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(88, 1), collection),\r
511           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)\r
512           });\r
513     }\r
514 \r
515     [Test]\r
516     public void Remove()\r
517     {\r
518       collection.FIFO = false;\r
519       collection.Add(4); collection.Add(56); collection.Add(18);\r
520       listen();\r
521       collection.Remove();\r
522       seen.Check(new CollectionEvent<int>[] {\r
523           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(18, 1), collection),\r
524           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
525       collection.FIFO = true;\r
526       collection.Remove();\r
527       seen.Check(new CollectionEvent<int>[] {\r
528           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(4, 1), collection),\r
529           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
530     }\r
531 \r
532     [Test]\r
533     public void RemoveFirst()\r
534     {\r
535       collection.Add(4); collection.Add(56); collection.Add(18);\r
536       listen();\r
537       collection.RemoveFirst();\r
538       seen.Check(new CollectionEvent<int>[] {\r
539           new CollectionEvent<int>(EventTypeEnum.RemovedAt, new ItemAtEventArgs<int>(4,0), collection),\r
540           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(4, 1), collection),\r
541           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
542     }\r
543 \r
544     [Test]\r
545     public void RemoveLast()\r
546     {\r
547       collection.Add(4); collection.Add(56); collection.Add(18);\r
548       listen();\r
549       collection.RemoveLast();\r
550       seen.Check(new CollectionEvent<int>[] {\r
551           new CollectionEvent<int>(EventTypeEnum.RemovedAt, new ItemAtEventArgs<int>(18,2), collection),\r
552           new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(18, 1), collection),\r
553           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
554     }\r
555 \r
556     [Test]\r
557     public void Reverse()\r
558     {\r
559       collection.Add(4); collection.Add(56); collection.Add(8);\r
560       listen();\r
561       collection.Reverse();\r
562       seen.Check(new CollectionEvent<int>[] {\r
563           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)\r
564         });\r
565       collection.View(1, 0).Reverse();\r
566       seen.Check(new CollectionEvent<int>[] { });\r
567     }\r
568 \r
569 \r
570     [Test]\r
571     public void Sort()\r
572     {\r
573       collection.Add(4); collection.Add(56); collection.Add(8);\r
574       listen();\r
575       collection.Sort();\r
576       seen.Check(new CollectionEvent<int>[] {\r
577           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)\r
578         });\r
579       collection.View(1, 0).Sort();\r
580       seen.Check(new CollectionEvent<int>[] { });\r
581     }\r
582 \r
583     [Test]\r
584     public void Shuffle()\r
585     {\r
586       collection.Add(4); collection.Add(56); collection.Add(8);\r
587       listen();\r
588       collection.Shuffle();\r
589       seen.Check(new CollectionEvent<int>[] {\r
590           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)\r
591         });\r
592       collection.View(1, 0).Shuffle();\r
593       seen.Check(new CollectionEvent<int>[] { });\r
594     }\r
595 \r
596     [Test]\r
597     public override void Clear()\r
598     {\r
599       collection.Add(4); collection.Add(56); collection.Add(18);\r
600       listen();\r
601       collection.View(1, 1).Clear();\r
602       seen.Check(new CollectionEvent<int>[] {\r
603           new CollectionEvent<int>(EventTypeEnum.Cleared, new ClearedRangeEventArgs(false,1,1), collection),\r
604           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)\r
605         });\r
606       collection.Clear();\r
607       seen.Check(new CollectionEvent<int>[] {\r
608           new CollectionEvent<int>(EventTypeEnum.Cleared, new ClearedRangeEventArgs(true,2,0), collection),\r
609           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)\r
610         });\r
611       collection.Clear();\r
612       seen.Check(new CollectionEvent<int>[] { });\r
613     }\r
614 \r
615     [Test]\r
616     public void ListDispose()\r
617     {\r
618       collection.Add(4); collection.Add(56); collection.Add(18);\r
619       listen();\r
620       collection.View(1, 1).Dispose();\r
621       seen.Check(new CollectionEvent<int>[] { });\r
622       collection.Dispose();\r
623       seen.Check(new CollectionEvent<int>[] {\r
624           new CollectionEvent<int>(EventTypeEnum.Cleared, new ClearedRangeEventArgs(true,3,0), collection),\r
625           new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)\r
626         });\r
627       collection.Dispose();\r
628       seen.Check(new CollectionEvent<int>[] { });\r
629     }\r
630 \r
631     /* \r
632  \r
633      * /\r
634         //[TearDown]\r
635         //public void Dispose() { list = null; seen = null; }\r
636         /*\r
637         [Test]\r
638         [ExpectedException(typeof(UnlistenableEventException))]\r
639         public void ViewChanged()\r
640         {\r
641           IList<int> w = collection.View(0, 0);\r
642           w.CollectionChanged += new CollectionChangedHandler<int>(w_CollectionChanged);\r
643         }\r
644 \r
645         [Test]\r
646         [ExpectedException(typeof(UnlistenableEventException))]\r
647         public void ViewCleared()\r
648         {\r
649           IList<int> w = collection.View(0, 0);\r
650           w.CollectionCleared += new CollectionClearedHandler<int>(w_CollectionCleared);\r
651         }\r
652 \r
653         [Test]\r
654         [ExpectedException(typeof(UnlistenableEventException))]\r
655         public void ViewAdded()\r
656         {\r
657           IList<int> w = collection.View(0, 0);\r
658           w.ItemsAdded += new ItemsAddedHandler<int>(w_ItemAdded);\r
659         }\r
660 \r
661         [Test]\r
662         [ExpectedException(typeof(UnlistenableEventException))]\r
663         public void ViewInserted()\r
664         {\r
665           IList<int> w = collection.View(0, 0);\r
666           w.ItemInserted += new ItemInsertedHandler<int>(w_ItemInserted);\r
667         }\r
668 \r
669         [Test]\r
670         [ExpectedException(typeof(UnlistenableEventException))]\r
671         public void ViewRemoved()\r
672         {\r
673           IList<int> w = collection.View(0, 0);\r
674           w.ItemsRemoved += new ItemsRemovedHandler<int>(w_ItemRemoved);\r
675         }\r
676 \r
677         [Test]\r
678         [ExpectedException(typeof(UnlistenableEventException))]\r
679         public void ViewRemovedAt()\r
680         {\r
681           IList<int> w = collection.View(0, 0);\r
682           w.ItemRemovedAt += new ItemRemovedAtHandler<int>(w_ItemRemovedAt);\r
683         }\r
684 \r
685         void w_CollectionChanged(object sender)\r
686         {\r
687           throw new NotImplementedException();\r
688         }\r
689 \r
690         void w_CollectionCleared(object sender, ClearedEventArgs eventArgs)\r
691         {\r
692           throw new NotImplementedException();\r
693         }\r
694 \r
695         void w_ItemAdded(object sender, ItemCountEventArgs<int> eventArgs)\r
696         {\r
697           throw new NotImplementedException();\r
698         }\r
699 \r
700         void w_ItemInserted(object sender, ItemAtEventArgs<int> eventArgs)\r
701         {\r
702           throw new NotImplementedException();\r
703         }\r
704 \r
705         void w_ItemRemoved(object sender, ItemCountEventArgs<int> eventArgs)\r
706         {\r
707           throw new NotImplementedException();\r
708         }\r
709 \r
710         void w_ItemRemovedAt(object sender, ItemAtEventArgs<int> eventArgs)\r
711         {\r
712           throw new NotImplementedException();\r
713         }*/\r
714   }\r
715 \r
716   public class StackTester<U> : CollectionValueTester<U> where U : IStack<int>\r
717   {\r
718     public override SCG.IEnumerable<EventTypeEnum> GetSpecs()\r
719     {\r
720       return SpecsBasic;\r
721     }\r
722 \r
723     [Test]\r
724     public void PushPop()\r
725     {\r
726       listen();\r
727       seen.Check(new CollectionEvent<int>[0]);\r
728       collection.Push(23);\r
729       seen.Check(new CollectionEvent<int>[] {\r
730               new CollectionEvent<int>(EventTypeEnum.Inserted, new ItemAtEventArgs<int>(23,0), collection),\r
731               new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(23, 1), collection),\r
732               new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
733       collection.Push(-12);\r
734       seen.Check(new CollectionEvent<int>[] {\r
735               new CollectionEvent<int>(EventTypeEnum.Inserted, new ItemAtEventArgs<int>(-12,1), collection),\r
736               new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(-12, 1), collection),\r
737               new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
738       collection.Pop();\r
739       seen.Check(new CollectionEvent<int>[] {\r
740               new CollectionEvent<int>(EventTypeEnum.RemovedAt, new ItemAtEventArgs<int>(-12,1), collection),\r
741               new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(-12, 1), collection),\r
742               new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
743       collection.Pop();\r
744       seen.Check(new CollectionEvent<int>[] {\r
745               new CollectionEvent<int>(EventTypeEnum.RemovedAt, new ItemAtEventArgs<int>(23,0), collection),\r
746               new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(23, 1), collection),\r
747               new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
748     }\r
749   }\r
750 \r
751   public class QueueTester<U> : CollectionValueTester<U> where U : IQueue<int>\r
752   {\r
753     public override SCG.IEnumerable<EventTypeEnum> GetSpecs()\r
754     {\r
755       return SpecsBasic;\r
756     }\r
757 \r
758     [Test]\r
759     public void EnqueueDequeue()\r
760     {\r
761       listen();\r
762       collection.Enqueue(67);\r
763       seen.Check(new CollectionEvent<int>[] {\r
764               new CollectionEvent<int>(EventTypeEnum.Inserted, new ItemAtEventArgs<int>(67,0), collection),\r
765               new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(67, 1), collection),\r
766               new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
767       collection.Enqueue(2);\r
768       seen.Check(new CollectionEvent<int>[] {\r
769               new CollectionEvent<int>(EventTypeEnum.Inserted, new ItemAtEventArgs<int>(2,1), collection),\r
770               new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(2, 1), collection),\r
771               new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
772       collection.Dequeue();\r
773       seen.Check(new CollectionEvent<int>[] {\r
774               new CollectionEvent<int>(EventTypeEnum.RemovedAt, new ItemAtEventArgs<int>(67,0), collection),\r
775               new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(67, 1), collection),\r
776               new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
777       collection.Dequeue();\r
778       seen.Check(new CollectionEvent<int>[] {\r
779               new CollectionEvent<int>(EventTypeEnum.RemovedAt, new ItemAtEventArgs<int>(2,0), collection),\r
780               new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(2, 1), collection),\r
781               new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
782     }\r
783 \r
784   }\r
785 \r
786   public class PriorityQueueTester<U> : ExtensibleTester<U> where U : IPriorityQueue<int>\r
787   {\r
788     public override System.Collections.Generic.IEnumerable<EventTypeEnum> GetSpecs()\r
789     {\r
790       return SpecsBasic;\r
791     }\r
792 \r
793     [Test]\r
794     public void Direct()\r
795     {\r
796       listen();\r
797       collection.Add(34);\r
798       seen.Check(new CollectionEvent<int>[] {\r
799         new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(34, 1), collection), \r
800         new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection), \r
801       });\r
802       collection.Add(56);\r
803       seen.Check(new CollectionEvent<int>[] {\r
804         new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(56, 1), collection), \r
805         new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection), \r
806       });\r
807       collection.AddAll<int>(new int[] { });\r
808       seen.Check(new CollectionEvent<int>[] {\r
809       });\r
810       collection.Add(34);\r
811       seen.Check(new CollectionEvent<int>[] {\r
812         new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(34, 1), collection), \r
813         new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection), \r
814       });\r
815       collection.Add(12);\r
816       seen.Check(new CollectionEvent<int>[] {\r
817         new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(12, 1), collection), \r
818         new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection), \r
819       });\r
820       collection.DeleteMax();\r
821       seen.Check(new CollectionEvent<int>[] {\r
822         new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(56, 1), collection),\r
823         new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection), \r
824       });\r
825       collection.DeleteMin();\r
826       seen.Check(new CollectionEvent<int>[] {\r
827         new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(12, 1), collection), \r
828         new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection), \r
829       });\r
830       collection.AddAll<int>(new int[] { 4, 5, 6, 2 });\r
831       seen.Check(new CollectionEvent<int>[] {\r
832         new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(4, 1), collection), \r
833         new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(5, 1), collection), \r
834         new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(6, 1), collection), \r
835         new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(2, 1), collection), \r
836         new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection)\r
837       });\r
838     }\r
839 \r
840     [Test]\r
841     public void WithHandles()\r
842     {\r
843       listen();\r
844       IPriorityQueueHandle<int> handle = null, handle2;\r
845       collection.Add(34);\r
846       seen.Check(new CollectionEvent<int>[] {\r
847         new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(34, 1), collection), \r
848         new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection), \r
849       });\r
850       collection.Add(56);\r
851       seen.Check(new CollectionEvent<int>[] {\r
852         new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(56, 1), collection), \r
853         new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection), \r
854       });\r
855       collection.Add(ref handle, 34);\r
856       seen.Check(new CollectionEvent<int>[] {\r
857         new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(34, 1), collection), \r
858         new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection), \r
859       });\r
860       collection.Add(12);\r
861       seen.Check(new CollectionEvent<int>[] {\r
862         new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(12, 1), collection), \r
863         new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection), \r
864       });\r
865       collection.DeleteMax(out handle2);\r
866       seen.Check(new CollectionEvent<int>[] {\r
867         new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(56, 1), collection),\r
868         new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection), \r
869       });\r
870       collection.DeleteMin(out handle2);\r
871       seen.Check(new CollectionEvent<int>[] {\r
872         new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(12, 1), collection), \r
873         new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection), \r
874       });\r
875 \r
876       collection.Replace(handle, 117);\r
877       seen.Check(new CollectionEvent<int>[] {\r
878         new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(34, 1), collection), \r
879         new CollectionEvent<int>(EventTypeEnum.Added, new ItemCountEventArgs<int>(117, 1), collection), \r
880         new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection), \r
881       });\r
882 \r
883       collection.Delete(handle);\r
884       seen.Check(new CollectionEvent<int>[] {\r
885         new CollectionEvent<int>(EventTypeEnum.Removed, new ItemCountEventArgs<int>(117, 1), collection), \r
886         new CollectionEvent<int>(EventTypeEnum.Changed, new EventArgs(), collection), \r
887       });\r
888     }\r
889   }\r
890 \r
891   public class DictionaryTester<U> : CollectionValueTester<U, KeyValuePair<int, int>> where U : IDictionary<int, int>\r
892   {\r
893     public override SCG.IEnumerable<EventTypeEnum> GetSpecs()\r
894     {\r
895       return SpecsBasic;\r
896     }\r
897 \r
898     [Test]\r
899     public virtual void Listenable()\r
900     {\r
901       Assert.AreEqual(EventTypeEnum.Basic, collection.ListenableEvents);\r
902       Assert.AreEqual(EventTypeEnum.None, collection.ActiveEvents);\r
903       listen();\r
904       Assert.AreEqual(listenTo, collection.ActiveEvents);\r
905     }\r
906 \r
907     [Test]\r
908     public void AddAndREmove()\r
909     {\r
910       listen();\r
911       seen.Check(new CollectionEvent<KeyValuePair<int, int>>[0]);\r
912       collection.Add(23, 45);\r
913       seen.Check(new CollectionEvent<KeyValuePair<int,int>>[] {\r
914           new CollectionEvent<KeyValuePair<int,int>>(EventTypeEnum.Added, new ItemCountEventArgs<KeyValuePair<int,int>>(new KeyValuePair<int,int>(23,45), 1), collection),\r
915           new CollectionEvent<KeyValuePair<int,int>>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
916       collection.Remove(25);\r
917       seen.Check(new CollectionEvent<KeyValuePair<int, int>>[] {\r
918           new CollectionEvent<KeyValuePair<int,int>>(EventTypeEnum.Removed, new ItemCountEventArgs<KeyValuePair<int,int>>(new KeyValuePair<int,int>(23,45), 1), collection),\r
919           new CollectionEvent<KeyValuePair<int,int>>(EventTypeEnum.Changed, new EventArgs(), collection)});\r
920     }\r
921 \r
922 \r
923 \r
924   }\r
925 \r
926 }\r
927 \r
928 \r