Merge pull request #1304 from slluis/mac-proxy-autoconfig
[mono.git] / mcs / class / corlib / Test / System.Collections / SortedListTest.cs
1 // SortedListTest.cs - NUnit Test Cases for the System.Collections.SortedList class
2 //
3 // Authors:
4 //      Jaak Simm
5 //      Duncan Mak (duncan@ximian.com)
6 //
7 // Thanks go to David Brandt (bucky@keystreams.com),
8 // because this file is based on his ArrayListTest.cs
9 //
10 // (C) Ximian, Inc.  http://www.ximian.com
11 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
12 // 
13 // main TODO: additional tests for functions affected by
14 //            fixedsize and read-only properties 
15
16
17 using System;
18 using System.Collections;
19 using System.IO;
20 using System.Runtime.Serialization.Formatters;
21 using System.Runtime.Serialization.Formatters.Binary;
22
23 using NUnit.Framework;
24
25 namespace MonoTests.System.Collections
26 {
27         public class SortedListComparer : IComparer
28         {
29                 public int Compare (object x, object y)
30                 {
31                         return x.GetHashCode () - y.GetHashCode ();
32                 }
33         }
34
35         [TestFixture]
36         public class SortedListTest
37         {
38                 protected SortedList sl1;
39                 protected SortedList sl2;
40                 protected SortedList emptysl;
41                 protected const int icap = 16;
42
43                 public void TestConstructor1 ()
44                 {
45                         SortedList temp1 = new SortedList ();
46                         Assert.IsNotNull (temp1, "#1");
47 #if !NET_2_0 // no such expectation as it is broken in .NET 2.0
48                         Assert.AreEqual (icap, temp1.Capacity, "#2");
49 #endif
50                 }
51
52                 [Test]
53                 public void TestConstructor2 ()
54                 {
55                         Comparer c = Comparer.Default;
56                         SortedList temp1 = new SortedList (c);
57                         Assert.IsNotNull (temp1, "#1");
58 #if !NET_2_0 // no such expectation as it is broken in .NET 2.0
59                         Assert.AreEqual (icap, temp1.Capacity, "#2");
60 #endif
61                 }
62
63                 [Test]
64                 public void TestConstructor3 ()
65                 {
66                         Hashtable d = new Hashtable ();
67                         d.Add ("one", "Mircosoft");
68                         d.Add ("two", "will");
69                         d.Add ("three", "rule");
70                         d.Add ("four", "the world");
71
72                         SortedList temp1 = new SortedList (d);
73                         Assert.IsNotNull (temp1, "#A1");
74                         Assert.AreEqual (4, temp1.Capacity, "#A2");
75                         Assert.AreEqual (4, temp1.Count, "#A3");
76
77                         try {
78                                 new SortedList ((Hashtable) null);
79                                 Assert.Fail ("#B");
80                         } catch (ArgumentNullException) {
81                         }
82
83                         try {
84                                 d = new Hashtable ();
85                                 d.Add ("one", "Mircosoft");
86                                 d.Add ("two", "will");
87                                 d.Add ("three", "rule");
88                                 d.Add ("four", "the world");
89                                 d.Add (7987, "lkj");
90                                 new SortedList (d);
91                                 Assert.Fail ("#C");
92                         } catch (InvalidOperationException) {
93                         }
94                 }
95
96                 [Test]
97                 public void TestConstructor4 ()
98                 {
99                         SortedList temp1 = new SortedList (17);
100                         Assert.IsNotNull (temp1, "#A1");
101                         Assert.AreEqual (17, temp1.Capacity, "#A2");
102
103                         try {
104                                 new SortedList (-6);
105                                 Assert.Fail ("#B");
106                         } catch (ArgumentOutOfRangeException) {
107                         }
108
109                         temp1 = new SortedList (0);
110                         Assert.IsNotNull (temp1, "#C");
111                 }
112
113                 [Test]
114                 public void TestConstructor5 ()
115                 {
116                         Comparer c = Comparer.Default;
117                         SortedList temp1 = new SortedList (c, 27);
118                         Assert.IsNotNull (temp1, "#A1");
119                         Assert.AreEqual (27, temp1.Capacity, "#A2");
120
121                         try {
122                                 new SortedList (-12);
123                                 Assert.Fail ("#B");
124                         } catch (ArgumentOutOfRangeException) {
125                         }
126                 }
127
128 #if !NET_2_0 // no such expectation as it is broken in .NET 2.0
129                 [Test]
130                 public void Constructor_Capacity ()
131                 {
132                         SortedList sl = new SortedList (0);
133                         Assert.AreEqual (0, sl.Capacity, "#A1");
134                         sl.Capacity = 0;
135                         // doesn't reset to class default (16)
136                         Assert.AreEqual (0, sl.Capacity, "#A2");
137
138                         for (int i = 1; i <= 16; i++) {
139                                 sl = new SortedList (i);
140                                 Assert.AreEqual (i, sl.Capacity, "#B1:" + i);
141                                 sl.Capacity = 0;
142                                 // reset to class default (16)
143                                 Assert.AreEqual (16, sl.Capacity, "#B2:" + i);
144                         }
145                 }
146 #endif
147
148                 [Test]
149                 public void TestIsSynchronized ()
150                 {
151                         SortedList sl1 = new SortedList ();
152                         Assert.IsFalse (sl1.IsSynchronized, "#1");
153                         SortedList sl2 = SortedList.Synchronized (sl1);
154                         Assert.IsTrue (sl2.IsSynchronized, "#2");
155                 }
156
157                 [Test]
158                 public void TestCapacity ()
159                 {
160                         for (int i = 0; i < 100; i++) {
161                                 SortedList sl1 = new SortedList (i);
162                                 Assert.AreEqual (i, sl1.Capacity, i.ToString ());
163                         }
164                 }
165
166                 [Test]
167                 public void TestCapacity2 ()
168                 {
169                         SortedList list = new SortedList ();
170
171                         list.Capacity = 5;
172                         Assert.AreEqual (5, list.Capacity, "#1");
173
174                         SortedList sync = SortedList.Synchronized (list);
175                         Assert.AreEqual (5, sync.Capacity, "#2");
176
177                         list.Capacity = 20;
178                         Assert.AreEqual (20, list.Capacity, "#3");
179                         Assert.AreEqual (20, sync.Capacity, "#4");
180                 }
181
182                 [Test]
183                 public void TestCapacity3 ()
184                 {
185                         int new_capacity = 5;
186                         SortedList list = new SortedList (1000);
187                         list.Capacity = new_capacity;
188
189                         Assert.AreEqual (new_capacity, list.Capacity);
190                 }
191
192                 [Test]
193                 public void Capacity_BackTo0 ()
194                 {
195                         SortedList list = new SortedList (42);
196                         Assert.AreEqual (42, list.Capacity, "#1");
197                         list.Capacity = 0;
198                 }
199
200                 // This doesn't fail on 64 bit systems
201                 /*
202                 [Test]
203                 [ExpectedException (typeof (OutOfMemoryException))]
204                 public void TestCapacity4 ()
205                 {
206                         SortedList list = new SortedList ();
207                         list.Capacity = Int32.MaxValue;
208                 }
209                 */
210
211                 [Test]
212                 public void TestCount ()
213                 {
214                         SortedList sl1 = new SortedList ();
215                         Assert.AreEqual (0, sl1.Count, "#1");
216                         for (int i = 1; i <= 100; i++) {
217                                 sl1.Add ("" + i, "" + i);
218                                 Assert.AreEqual (i, sl1.Count, "#2:" + i);
219                         }
220                 }
221
222                 [Test]
223                 public void TestIsFixed ()
224                 {
225                         SortedList sl1 = new SortedList ();
226                         Assert.IsFalse (sl1.IsFixedSize);
227                 }
228
229                 [Test]
230                 public void TestIsReadOnly ()
231                 {
232                         SortedList sl1 = new SortedList ();
233                         Assert.IsFalse (sl1.IsReadOnly);
234                 }
235
236                 [Test]
237                 public void TestItem ()
238                 {
239                         SortedList sl1 = new SortedList ();
240
241                         object o = sl1 [-1];
242                         Assert.IsNull (o, "#A");
243
244                         try {
245                                 o = sl1 [(string) null];
246                                 Assert.Fail ("#B");
247                         } catch (ArgumentNullException) {
248                         }
249
250                         for (int i = 0; i <= 100; i++)
251                                 sl1.Add ("kala " + i, i);
252                         for (int i = 0; i <= 100; i++)
253                                 Assert.AreEqual (i, sl1 ["kala " + i], "#C:" + i);
254                 }
255
256                 [Test]
257                 public void TestSyncRoot ()
258                 {
259                         SortedList sl1 = new SortedList ();
260                         Assert.IsNotNull (sl1.SyncRoot);
261                         /*
262                         lock( sl1.SyncRoot ) {
263                                 foreach ( Object item in sl1 ) {
264                                         item="asdf";
265                                         Assert ("sl.SyncRoot: item not read-only",item.IsReadOnly);
266                                 }
267                         }
268                         */
269                 }
270
271                 [Test]
272                 public void TestValues ()
273                 {
274                         SortedList sl1 = new SortedList ();
275                         ICollection ic1 = sl1.Values;
276                         for (int i = 0; i <= 100; i++) {
277                                 sl1.Add ("kala " + i, i);
278                                 Assert.AreEqual (ic1.Count, sl1.Count);
279                         }
280                 }
281
282
283                 // TODO: Add with IComparer
284                 [Test]
285                 public void TestAdd ()
286                 {
287                         // seems SortedList cannot be set fixedsize or readonly
288                         SortedList sl1 = new SortedList ();
289
290                         try {
291                                 sl1.Add ((string) null, "kala");
292                                 Assert.Fail ("#A");
293                         } catch (ArgumentNullException) {
294                         }
295
296                         for (int i = 1; i <= 100; i++) {
297                                 sl1.Add ("kala " + i, i);
298                                 Assert.AreEqual (i, sl1.Count, "#B1:" + i);
299                                 Assert.AreEqual (i, sl1 ["kala " + i], "#B2:" + i);
300                         }
301
302                         try {
303                                 sl1.Add ("kala", 10);
304                                 sl1.Add ("kala", 11);
305                                 Assert.Fail ("#C");
306                         } catch (ArgumentException) {
307                         }
308                 }
309
310                 [Test]
311                 public void TestClear ()
312                 {
313                         SortedList sl1 = new SortedList (10);
314                         sl1.Add ("kala", 'c');
315                         sl1.Add ("kala2", 'd');
316                         Assert.AreEqual (10, sl1.Capacity, "#A1");
317                         Assert.AreEqual (2, sl1.Count, "#A2");
318                         sl1.Clear ();
319                         Assert.AreEqual (0, sl1.Count, "#B1");
320 #if !NET_2_0 // no such expectation as it is broken in .NET 2.0
321                         Assert.AreEqual (16, sl1.Capacity, "#B2");
322 #endif
323                 }
324
325 #if !NET_2_0 // no such expectation as it is broken in .NET 2.0
326                 [Test]
327                 public void Clear_Capacity ()
328                 {
329                         // strangely Clear change the default capacity (while Capacity doesn't)
330                         for (int i = 0; i <= 16; i++) {
331                                 SortedList sl = new SortedList (i);
332                                 Assert.AreEqual (i, sl.Capacity, "#1:"+ i);
333                                 sl.Clear ();
334                                 // reset to class default (16)
335                                 Assert.AreEqual (16, sl.Capacity, "#2:" + i);
336                         }
337                 }
338
339                 [Test]
340                 public void Clear_Capacity_Reset ()
341                 {
342                         SortedList sl = new SortedList (0);
343                         Assert.AreEqual (0, sl.Capacity, "#1");
344                         sl.Clear ();
345                         // reset to class default (16)
346                         Assert.AreEqual (16, sl.Capacity, "#2");
347                         sl.Capacity = 0;
348                         Assert.AreEqual (16, sl.Capacity, "#3");
349                         // note: we didn't return to 0 - so Clear cahnge the default capacity
350                 }
351 #endif
352
353                 [Test]
354                 public void ClearDoesNotTouchCapacity ()
355                 {
356                         SortedList sl = new SortedList ();
357                         // according to MSDN docs Clear () does not change capacity
358                         for (int i = 0; i < 18; i++) {
359                                 sl.Add (i, i);
360                         }
361                         int capacityBeforeClear = sl.Capacity;
362                         sl.Clear ();
363                         int capacityAfterClear = sl.Capacity;
364                         Assert.AreEqual (capacityBeforeClear, capacityAfterClear);
365                 }
366
367                 [Test]
368                 public void TestClone ()
369                 {
370                         {
371                                 SortedList sl1 = new SortedList (10);
372                                 for (int i = 0; i <= 50; i++)
373                                         sl1.Add ("kala " + i, i);
374                                 SortedList sl2 = (SortedList) sl1.Clone ();
375                                 for (int i = 0; i <= 50; i++)
376                                         Assert.AreEqual (sl1 ["kala " + i], sl2 ["kala " + i], "#A:" + i);
377                         }
378                         {
379                                 char [] d10 = { 'a', 'b' };
380                                 char [] d11 = { 'a', 'c' };
381                                 char [] d12 = { 'b', 'c' };
382                                 //char[][] d1 = {d10, d11, d12};
383                                 SortedList sl1 = new SortedList ();
384                                 sl1.Add ("d1", d10);
385                                 sl1.Add ("d2", d11);
386                                 sl1.Add ("d3", d12);
387                                 SortedList sl2 = (SortedList) sl1.Clone ();
388                                 Assert.AreEqual (sl1 ["d1"], sl2 ["d1"], "#B1");
389                                 Assert.AreEqual (sl1 ["d2"], sl2 ["d2"], "#B2");
390                                 Assert.AreEqual (sl1 ["d3"], sl2 ["d3"], "#B3");
391                                 ((char []) sl1 ["d1"]) [0] = 'z';
392                                 Assert.AreEqual (sl1 ["d1"], sl2 ["d1"], "#B4");
393                         }
394                 }
395
396                 [Test]
397                 public void TestContains ()
398                 {
399                         SortedList sl1 = new SortedList (55);
400                         for (int i = 0; i <= 50; i++) { sl1.Add ("kala " + i, i); }
401
402                         try {
403                                 if (sl1.Contains (null)) {
404                                 }
405                                 Assert.Fail ("#A");
406                         } catch (ArgumentNullException) {
407                         }
408
409                         Assert.IsTrue (sl1.Contains ("kala 17"), "#B1");
410                         Assert.IsFalse (sl1.Contains ("ohoo"), "#B2");
411                 }
412
413                 [Test]
414                 public void TestContainsKey ()
415                 {
416                         SortedList sl1 = new SortedList (55);
417                         for (int i = 0; i <= 50; i++) { sl1.Add ("kala " + i, i); }
418
419                         try {
420                                 if (sl1.ContainsKey (null)) {
421                                 }
422                                 Assert.Fail ("#A");
423                         } catch (ArgumentNullException) {
424                         }
425
426                         Assert.IsTrue (sl1.ContainsKey ("kala 17"), "#B1");
427                         Assert.IsFalse (sl1.ContainsKey ("ohoo"), "#B2");
428                 }
429
430                 [Test]
431                 public void TestContainsValue ()
432                 {
433                         SortedList sl1 = new SortedList (55);
434                         sl1.Add (0, "zero");
435                         sl1.Add (1, "one");
436                         sl1.Add (2, "two");
437                         sl1.Add (3, "three");
438                         sl1.Add (4, "four");
439
440                         Assert.IsTrue (sl1.ContainsValue ("zero"), "#1");
441                         Assert.IsFalse (sl1.ContainsValue ("ohoo"), "#2");
442                         Assert.IsFalse (sl1.ContainsValue (null), "#3");
443                 }
444
445                 [Test]
446                 public void TestCopyTo ()
447                 {
448                         SortedList sl1 = new SortedList ();
449                         for (int i = 0; i <= 10; i++) { sl1.Add ("kala " + i, i); }
450                         {
451                                 try {
452                                         sl1.CopyTo (null, 2);
453                                         Assert.Fail ("sl.CopyTo: does not throw ArgumentNullException when target null");
454                                 } catch (ArgumentNullException) {
455                                 }
456                         }
457                         {
458                                 try {
459                                         Char [,] c2 = new Char [2, 2];
460                                         sl1.CopyTo (c2, 2);
461                                         Assert.Fail ("sl.CopyTo: does not throw ArgumentException when target is multiarray");
462                                 } catch (ArgumentException) {
463                                 }
464                         }
465                         {
466                                 try {
467                                         Char [] c1 = new Char [2];
468                                         sl1.CopyTo (c1, -2);
469                                         Assert.Fail ("sl.CopyTo: does not throw ArgumentOutOfRangeException when index is negative");
470                                 } catch (ArgumentOutOfRangeException) {
471                                 }
472                         }
473                         {
474                                 try {
475                                         Char [] c1 = new Char [2];
476                                         sl1.CopyTo (c1, 3);
477                                         Assert.Fail ("sl.CopyTo: does not throw ArgumentException when index is too large");
478                                 } catch (ArgumentException) {
479                                 }
480                         }
481                         {
482                                 try {
483                                         Char [] c1 = new Char [2];
484                                         sl1.CopyTo (c1, 1);
485                                         Assert.Fail ("sl.CopyTo: does not throw ArgumentException when SortedList too big for the array");
486                                 } catch (ArgumentException) {
487                                 }
488                         }
489                         {
490                                 try {
491                                         Char [] c2 = new Char [15];
492                                         sl1.CopyTo (c2, 0);
493                                         Assert.Fail ("sl.CopyTo: does not throw InvalidCastException when incompatible data types");
494                                 } catch (InvalidCastException) {
495                                 }
496                         }
497
498                         // CopyTo function does not work well with SortedList
499                         // even example at MSDN gave InvalidCastException
500                         // thus, it is NOT tested here
501                         /*
502                                         sl1.Clear();
503                                         for (int i = 0; i <= 5; i++) {sl1.Add(i,""+i);}
504                             Char[] copy = new Char[15];
505                             Array.Clear(copy,0,copy.Length);
506                             copy.SetValue( "The", 0 );
507                             copy.SetValue( "quick", 1 );
508                             copy.SetValue( "brown", 2 );
509                             copy.SetValue( "fox", 3 );
510                             copy.SetValue( "jumped", 4 );
511                             copy.SetValue( "over", 5 );
512                             copy.SetValue( "the", 6 );
513                             copy.SetValue( "lazy", 7 );
514                             copy.SetValue( "dog", 8 );
515                                         sl1.CopyTo(copy,1);
516                                         AssertEquals("sl.CopyTo: incorrect copy(1).","The", copy.GetValue(0));
517                                         AssertEquals("sl.CopyTo: incorrect copy(1).","quick", copy.GetValue(1));
518                                         for (int i=2; i<8; i++) AssertEquals("sl.CopyTo: incorrect copy(2).",sl1["kala "+(i-2)], copy.GetValue(i));
519                                         AssertEquals("sl.CopyTo: incorrect copy(3).","dog", copy.GetValue(8));
520                         */
521                 }
522
523                 public SortedList DefaultSL ()
524                 {
525                         SortedList sl1 = new SortedList ();
526                         sl1.Add (1.0, "The");
527                         sl1.Add (1.1, "quick");
528                         sl1.Add (34.0, "brown");
529                         sl1.Add (-100.75, "fox");
530                         sl1.Add (1.4, "jumped");
531                         sl1.Add (1.5, "over");
532                         sl1.Add (1.6, "the");
533                         sl1.Add (1.7, "lazy");
534                         sl1.Add (1.8, "dog");
535                         return sl1;
536                 }
537
538                 public IList DefaultValues ()
539                 {
540                         IList il = new ArrayList ();
541                         il.Add ("fox");
542                         il.Add ("The");
543                         il.Add ("quick");
544                         il.Add ("jumped");
545                         il.Add ("over");
546                         il.Add ("the");
547                         il.Add ("lazy");
548                         il.Add ("dog");
549                         il.Add ("brown");
550                         return il;
551                 }
552
553                 [Test]
554                 public void TestGetByIndex ()
555                 {
556                         SortedList sl1 = DefaultSL ();
557                         Assert.AreEqual ("over", sl1.GetByIndex (4), "#A1");
558                         Assert.AreEqual ("brown", sl1.GetByIndex (8), "#A2");
559
560                         try {
561                                 sl1.GetByIndex (-1);
562                                 Assert.Fail ("#B");
563                         } catch (ArgumentOutOfRangeException) {
564                         }
565
566                         try {
567                                 sl1.GetByIndex (100);
568                                 Assert.Fail ("#C");
569                         } catch (ArgumentOutOfRangeException) {
570                         }
571                 }
572
573                 [Test]
574                 public void GetEnumerator ()
575                 {
576                         SortedList sl1 = DefaultSL ();
577                         IDictionaryEnumerator e = sl1.GetEnumerator ();
578                         Assert.IsNotNull (e, "#1");
579                         Assert.IsTrue (e.MoveNext (), "#2");
580                         Assert.IsNotNull (e.Current, "#3");
581                         Assert.IsTrue ((e is ICloneable), "#4");
582                         Assert.IsTrue ((e is IDictionaryEnumerator), "#5");
583                         Assert.IsTrue ((e is IEnumerator), "#6");
584                 }
585
586                 [Test]
587                 public void TestGetKey ()
588                 {
589                         SortedList sl1 = DefaultSL ();
590                         Assert.AreEqual (1.5, sl1.GetKey (4), "#A1");
591                         Assert.AreEqual (34.0, sl1.GetKey (8), "#A2");
592
593                         try {
594                                 sl1.GetKey (-1);
595                                 Assert.Fail ("#B");
596                         } catch (ArgumentOutOfRangeException) {
597                         }
598
599                         try {
600                                 sl1.GetKey (100);
601                                 Assert.Fail ("#C");
602                         } catch (ArgumentOutOfRangeException) {
603                         }
604                 }
605
606                 [Test]
607                 public void TestGetKeyList ()
608                 {
609                         SortedList sl1 = DefaultSL ();
610                         IList keys = sl1.GetKeyList ();
611                         Assert.IsNotNull (keys, "#A1");
612                         Assert.IsTrue (keys.IsReadOnly, "#A2");
613                         Assert.AreEqual (9, keys.Count, "#A3");
614                         Assert.AreEqual (1.4, keys [3], "#A4");
615                         sl1.Add (33.9, "ehhe");
616                         Assert.AreEqual (10, keys.Count, "#B1");
617                         Assert.AreEqual (33.9, keys [8], "#B2");
618                 }
619
620                 [Test]
621                 public void TestGetValueList ()
622                 {
623                         SortedList sl1 = DefaultSL ();
624                         IList originalvals = DefaultValues ();
625                         IList vals = sl1.GetValueList ();
626                         Assert.IsNotNull (vals, "#A1");
627                         Assert.IsTrue (vals.IsReadOnly, "#A2");
628                         Assert.AreEqual (vals.Count, sl1.Count, "#A3");
629
630                         for (int i = 0; i < sl1.Count; i++) {
631                                 Assert.AreEqual (vals [i], originalvals [i], "#A4:" + i);
632                         }
633
634                         sl1.Add (0.01, "ehhe");
635                         Assert.AreEqual (10, vals.Count, "#B1");
636                         Assert.AreEqual ("dog", vals [8], "#B2");
637                 }
638
639                 // TODO: IEnumerable.GetEnumerator [Explicit Interface Implementation]
640                 /*
641                 public void TestIEnumerable_GetEnumerator() {
642                         SortedList sl1 = DefaultSL();
643                         IEnumerator e = sl1.IEnumerable.GetEnumerator();
644                         AssertNotNull("sl.GetEnumerator: does not return enumerator", e);
645                         AssertEquals("sl.GetEnumerator: enumerator not working(1)",e.MoveNext(),true);
646                         AssertNotNull("sl.GetEnumerator: enumerator not working(2)",e.Current);
647                 }
648                 */
649
650                 [Test]
651                 public void TestIndexOfKey ()
652                 {
653                         SortedList sl1 = new SortedList (24);
654
655                         for (int i = 0; i <= 50; i++) {
656                                 string s = string.Format ("{0:D2}", i);
657                                 sl1.Add ("kala " + s, i);
658                         }
659                         Assert.AreEqual (-1, sl1.IndexOfKey ("kala "), "#A");
660
661                         try {
662                                 sl1.IndexOfKey ((string) null);
663                                 Assert.Fail ("#B");
664                         } catch (ArgumentNullException) {
665                         }
666
667                         try {
668                                 sl1.IndexOfKey (10);
669                                 Assert.Fail ("#C");
670                         } catch (InvalidOperationException) {
671                         }
672
673                         for (int i = 0; i <= 50; i++) {
674                                 string s = string.Format ("{0:D2}", i);
675                                 Assert.AreEqual (i, sl1.IndexOfKey ("kala " + s), "#D:" + i);
676                         }
677                 }
678
679                 [Test]
680                 public void TestIndexOfValue ()
681                 {
682                         SortedList sl1 = new SortedList (24);
683                         string s = null;
684                         for (int i = 0; i < 50; i++) {
685                                 s = string.Format ("{0:D2}", i);
686                                 sl1.Add ("kala " + s, 100 + i * i);
687                         }
688                         for (int i = 0; i < 50; i++) {
689                                 s = string.Format ("{0:D2}", i + 50);
690                                 sl1.Add ("kala " + s, 100 + i * i);
691                         }
692                         Assert.AreEqual (-1, sl1.IndexOfValue (102), "#1");
693                         Assert.AreEqual (-1, sl1.IndexOfValue (null), "#2");
694                         for (int i = 0; i < 50; i++)
695                                 Assert.AreEqual (i, sl1.IndexOfValue (100 + i * i), "#3:" + i);
696                 }
697
698                 [Test]
699                 public void TestIndexOfValue2 ()
700                 {
701                         SortedList list = new SortedList ();
702                         list.Add ("key0", "la la");
703                         list.Add ("key1", "value");
704                         list.Add ("key2", "value");
705
706                         int i = list.IndexOfValue ("value");
707                         Assert.AreEqual (1, i);
708                 }
709
710                 [Test]
711                 public void TestIndexOfValue3 ()
712                 {
713                         SortedList list = new SortedList ();
714                         int i = list.IndexOfValue ((string) null);
715                         Assert.AreEqual (1, -i);
716                 }
717
718                 [Test]
719                 public void TestIndexer ()
720                 {
721                         SortedList list = new SortedList ();
722
723                         list.Add (1, new Queue ());
724                         list.Add (2, new Hashtable ());
725                         list.Add (3, new Stack ());
726
727                         Assert.AreEqual (typeof (Queue), list [1].GetType (), "#1");
728                         Assert.AreEqual (typeof (Hashtable), list [2].GetType (), "#2");
729                         Assert.AreEqual (typeof (Stack), list [3].GetType (), "#3");
730                 }
731
732                 [Test]
733                 public void TestEnumerator ()
734                 {
735                         SortedList list = new SortedList ();
736
737                         list.Add (1, new Queue ());
738                         list.Add (2, new Hashtable ());
739                         list.Add (3, new Stack ());
740
741                         foreach (DictionaryEntry d in list) {
742
743                                 int key = (int) d.Key;
744                                 Type value = d.Value.GetType ();
745
746                                 switch (key) {
747                                 case 1:
748                                         Assert.AreEqual (typeof (Queue), value, "#1");
749                                         break;
750
751                                 case 2:
752                                         Assert.AreEqual (typeof (Hashtable), value, "#2");
753                                         break;
754
755                                 case 3:
756                                         Assert.AreEqual (typeof (Stack), value, "#3");
757                                         break;
758
759                                 default:
760                                         Assert.Fail ("#4:" + value.FullName);
761                                         break;
762                                 }
763                         }
764                 }
765
766                 [Test]
767                 public void TestRemove ()
768                 {
769                         SortedList sl1 = new SortedList (24);
770                         string s = null;
771                         int k;
772                         for (int i = 0; i < 50; i++) sl1.Add ("kala " + i, i);
773
774                         try {
775                                 sl1.Remove (s);
776                                 Assert.Fail ("#A");
777                         } catch (ArgumentNullException) {
778                         }
779
780                         k = sl1.Count;
781                         sl1.Remove ("kala ");
782                         Assert.AreEqual (k, sl1.Count, "#B");
783
784                         try {
785                                 sl1.Remove (15);
786                                 Assert.Fail ("#C");
787                         } catch (InvalidOperationException) {
788                         }
789
790                         for (int i = 15; i < 20; i++)
791                                 sl1.Remove ("kala " + i);
792                         for (int i = 45; i < 55; i++)
793                                 sl1.Remove ("kala " + i);
794
795                         Assert.AreEqual (40, sl1.Count, "#D1");
796                         for (int i = 45; i < 55; i++)
797                                 Assert.IsNull (sl1 ["kala " + i], "#D2:" + i);
798                 }
799
800                 [Test]
801                 public void TestRemoveAt ()
802                 {
803                         SortedList sl1 = new SortedList (24);
804                         int k;
805
806                         for (int i = 0; i < 50; i++) {
807                                 string s = string.Format ("{0:D2}", i);
808                                 sl1.Add ("kala " + s, i);
809                         }
810
811                         try {
812                                 sl1.RemoveAt (-1);
813                                 Assert.Fail ("#A");
814                         } catch (ArgumentOutOfRangeException) {
815                         }
816
817                         try {
818                                 sl1.RemoveAt (100);
819                                 Assert.Fail ("#B");
820                         } catch (ArgumentOutOfRangeException) {
821                         }
822
823                         k = sl1.Count;
824
825                         for (int i = 0; i < 20; i++)
826                                 sl1.RemoveAt (9);
827
828                         Assert.AreEqual (30, sl1.Count, 30, "#C1");
829                         for (int i = 0; i < 9; i++)
830                                 Assert.AreEqual (i, sl1 ["kala " + string.Format ("{0:D2}", i)], "#C2:" + i);
831                         for (int i = 9; i < 29; i++)
832                                 Assert.IsNull (sl1 ["kala " + string.Format ("{0:D2}", i)], "#C3:" + i);
833                         for (int i = 29; i < 50; i++)
834                                 Assert.AreEqual (i, sl1 ["kala " + string.Format ("{0:D2}", i)], "#C4:" + i);
835                 }
836
837                 [Test]
838                 public void TestSetByIndex ()
839                 {
840                         SortedList sl1 = new SortedList (24);
841                         for (int i = 49; i >= 0; i--) sl1.Add (100 + i, i);
842
843                         try {
844                                 sl1.SetByIndex (-1, 77);
845                                 Assert.Fail ("#A");
846                         } catch (ArgumentOutOfRangeException) {
847                         }
848
849                         try {
850                                 sl1.SetByIndex (100, 88);
851                                 Assert.Fail ("#B");
852                         } catch (ArgumentOutOfRangeException) {
853                         }
854
855                         for (int i = 5; i < 25; i++)
856                                 sl1.SetByIndex (i, -1);
857                         for (int i = 0; i < 5; i++)
858                                 Assert.AreEqual (i, sl1 [100 + i], "#C1");
859                         for (int i = 5; i < 25; i++)
860                                 Assert.AreEqual (-1, sl1 [100 + i], "#C2");
861                         for (int i = 25; i < 50; i++)
862                                 Assert.AreEqual (i, sl1 [100 + i], "#C3");
863                 }
864
865                 [Test]
866                 public void TestTrimToSize ()
867                 {
868                         SortedList sl1 = new SortedList (24);
869
870                         sl1.TrimToSize ();
871 #if !NET_2_0 // no such expectation as it is broken in .NET 2.0
872                         Assert.AreEqual (icap, sl1.Capacity, "#1");
873 #endif
874
875                         for (int i = 72; i >= 0; i--)
876                                 sl1.Add (100 + i, i);
877                         sl1.TrimToSize ();
878 #if !NET_2_0 // no such expectation as it is broken in .NET 2.0
879                         Assert.AreEqual (73, sl1.Capacity, "#2");
880 #endif
881                 }
882
883                 [Test]
884                 public void SerializeTest ()
885                 {
886                         SortedList sl1 = new SortedList ();
887                         sl1.Add (5, "A");
888                         sl1.Add (0, "B");
889                         sl1.Add (7, "C");
890
891                         BinaryFormatter bf = new BinaryFormatter ();
892                         bf.AssemblyFormat = FormatterAssemblyStyle.Full;
893                         MemoryStream ms = new MemoryStream ();
894                         bf.Serialize (ms, sl1);
895                         ms.Position = 0;
896
897                         SortedList sl2 = (SortedList) bf.Deserialize (ms);
898                         Assert.IsNotNull (sl2, "#1");
899                         Assert.AreEqual (3, sl2.Count, "#2");
900                         Assert.AreEqual (sl1 [0], sl2 [0], "#3");
901                         Assert.AreEqual (sl1 [1], sl2 [1], "#4");
902                         Assert.AreEqual (sl1 [2], sl2 [2], "#5");
903                 }
904
905                 [Test]
906                 public void Keys_Serialize ()
907                 {
908                         SortedList sl = new SortedList ();
909                         sl.Add (5, "A");
910                         sl.Add (0, "B");
911                         sl.Add (7, "C");
912
913                         IList keys1 = (IList) sl.Keys;
914                         BinaryFormatter bf = new BinaryFormatter ();
915                         bf.AssemblyFormat = FormatterAssemblyStyle.Full;
916                         MemoryStream ms = new MemoryStream ();
917                         bf.Serialize (ms, keys1);
918                         ms.Position = 0;
919
920                         IList keys2 = (IList) bf.Deserialize (ms);
921                         Assert.IsNotNull (keys2, "#1");
922                         Assert.AreEqual (3, keys2.Count, "#2");
923                         Assert.AreEqual (keys1 [0], keys2 [0], "#3");
924                         Assert.AreEqual (keys1 [1], keys2 [1], "#4");
925                         Assert.AreEqual (keys1 [2], keys2 [2], "#5");
926                 }
927
928                 [Test]
929                 public void Values_Serialize ()
930                 {
931                         SortedList sl = new SortedList ();
932                         sl.Add (5, "A");
933                         sl.Add (0, "B");
934                         sl.Add (7, "C");
935
936                         IList values1 = (IList) sl.Values;
937                         BinaryFormatter bf = new BinaryFormatter ();
938                         bf.AssemblyFormat = FormatterAssemblyStyle.Full;
939                         MemoryStream ms = new MemoryStream ();
940                         bf.Serialize (ms, values1);
941                         ms.Position = 0;
942
943                         IList values2 = (IList) bf.Deserialize (ms);
944                         Assert.IsNotNull (values2, "#1");
945                         Assert.AreEqual (3, values2.Count, "#2");
946                         Assert.AreEqual (values1 [0], values2 [0], "#3");
947                         Assert.AreEqual (values1 [1], values2 [1], "#4");
948                         Assert.AreEqual (values1 [2], values2 [2], "#5");
949                 }
950
951                 [Test]
952                 [Category ("NotWorking")]
953                 public void Values_Deserialize ()
954                 {
955                         BinaryFormatter bf = new BinaryFormatter ();
956
957                         MemoryStream ms = new MemoryStream ();
958                         ms.Write (_serializedValues, 0, _serializedValues.Length);
959                         ms.Position = 0;
960
961                         IList values = (IList) bf.Deserialize (ms);
962                         Assert.AreEqual (3, values.Count, "#1");
963                         Assert.AreEqual ("B", values [0], "#2");
964                         Assert.AreEqual ("A", values [1], "#3");
965                         Assert.AreEqual ("C", values [2], "#4");
966                 }
967
968                 [Test]
969                 [ExpectedException (typeof (InvalidOperationException))]
970                 public void SetIdenticalObjectException ()
971                 {
972                         // Even though the key/value pair being set are identical to
973                         // the existing one, it causes snapshot out of sync.
974                         SortedList sl = new SortedList ();
975                         sl ["foo"] = "bar";
976                         foreach (string s in sl.Keys)
977                                 sl ["foo"] = "bar";
978                 }
979
980                 [Test]
981                 public void Ctor_IComparer ()
982                 {
983                         SortedList sl = new SortedList (new SortedListComparer ());
984                         sl.Add (new object (), new object ());
985                 }
986
987                 [Test]
988                 public void Ctor_IComparer_Null ()
989                 {
990                         SortedList sl = new SortedList ((IComparer) null);
991                         sl.Add (new object (), new object ());
992                 }
993
994                 [Test]
995                 public void Ctor_IDictionary_IComparer_Before ()
996                 {
997                         Hashtable ht = new Hashtable ();
998                         ht.Add (2, "a");
999                         ht.Add (1, "b");
1000                         // adding a non-IComparable in Hashtable
1001                         ht.Add (new object (), "c");
1002                         SortedList sl = new SortedList (ht, new SortedListComparer ());
1003                         Assert.AreEqual (3, sl.Count);
1004                 }
1005
1006                 [Test]
1007                 [ExpectedException (typeof (InvalidOperationException))]
1008                 public void Ctor_IDictionary_DefaultInvariant_Before ()
1009                 {
1010                         Hashtable ht = new Hashtable ();
1011                         ht.Add (2, "a");
1012                         ht.Add (1, "b");
1013                         // adding a non-IComparable in Hashtable
1014                         ht.Add (new object (), "c");
1015                         SortedList sl = new SortedList (ht, Comparer.DefaultInvariant);
1016                         Assert.AreEqual (3, sl.Count);
1017                 }
1018
1019                 [Test]
1020                 public void Ctor_IDictionary_IComparer_Null_Before_1item ()
1021                 {
1022                         Hashtable ht = new Hashtable ();
1023                         // adding a non-IComparable in Hashtable
1024                         ht.Add (new object (), "c");
1025                         SortedList sl = new SortedList (ht, null);
1026                         Assert.AreEqual (1, sl.Count);
1027                 }
1028
1029                 [Test]
1030                 [ExpectedException (typeof (InvalidOperationException))]
1031                 public void Ctor_IDictionary_IComparer_Null_Before_2items ()
1032                 {
1033                         Hashtable ht = new Hashtable ();
1034                         ht.Add (2, "a");
1035                         // adding a non-IComparable in Hashtable
1036                         ht.Add (new object (), "c");
1037                         SortedList sl = new SortedList (ht, null);
1038                         Assert.AreEqual (2, sl.Count);
1039                 }
1040
1041                 [Test]
1042                 public void Ctor_IDictionary_IComparer_After ()
1043                 {
1044                         Hashtable ht = new Hashtable ();
1045                         ht.Add (2, "a");
1046                         ht.Add (1, "b");
1047                         SortedList sl = new SortedList (ht, new SortedListComparer ());
1048                         Assert.AreEqual (2, sl.Count);
1049                         // adding a non-IComparable in SortedList
1050                         sl.Add (new object (), "c");
1051                 }
1052
1053                 [Test]
1054                 [ExpectedException (typeof (InvalidOperationException))]
1055                 public void Ctor_IDictionary_DefaultInvariant_After ()
1056                 {
1057                         Hashtable ht = new Hashtable ();
1058                         ht.Add (2, "a");
1059                         ht.Add (1, "b");
1060                         SortedList sl = new SortedList (ht, Comparer.DefaultInvariant);
1061                         Assert.AreEqual (2, sl.Count);
1062                         // adding a non-IComparable in SortedList
1063                         sl.Add (new object (), "c");
1064                 }
1065
1066                 [Test]
1067                 public void Ctor_IDictionary_IComparer_Null_After_1item ()
1068                 {
1069                         SortedList sl = new SortedList (new Hashtable (), null);
1070                         sl.Add (new object (), "b");
1071                 }
1072
1073                 [Test]
1074                 [ExpectedException (typeof (InvalidOperationException))]
1075                 public void Ctor_IDictionary_IComparer_Null_After_2items ()
1076                 {
1077                         SortedList sl = new SortedList (new Hashtable (), null);
1078                         sl.Add (2, "a");
1079                         sl.Add (new object (), "b");
1080                 }
1081
1082                 [Test]
1083                 public void IComparer_Clone ()
1084                 {
1085                         SortedList sl = new SortedList (new SortedListComparer ());
1086                         sl.Add (new object (), new object ());
1087                         SortedList clone = (SortedList) sl.Clone ();
1088                 }
1089
1090                 [Test]
1091                 public void IComparer_Null_Clone ()
1092                 {
1093                         SortedList sl = new SortedList ((IComparer) null);
1094                         sl.Add (new object (), new object ());
1095                         SortedList clone = (SortedList) sl.Clone ();
1096                 }
1097
1098                 sealed class StartsWithComparator : IComparer {
1099                         public static readonly StartsWithComparator Instance = new StartsWithComparator();
1100
1101                         public int Compare(object p, object w)
1102                         {
1103                                 string part = (string) p;
1104                                 string whole = (string) w;
1105                                 // let the default string comparer deal with null or when part is not smaller then whole
1106                                 if (part == null || whole == null || part.Length >= whole.Length)
1107                                         return String.Compare (part, whole);
1108
1109                                 // loop through all characters that part and whole have in common
1110                                 int pos = 0;
1111                                 bool match;
1112                                 do {
1113                                         match = (part[pos] == whole[pos]);
1114                                 } while (match && ++pos < part.Length);
1115
1116                                 // return result of last comparison
1117                                 return match ? 0 : (part[pos] < whole[pos] ? -1 : 1);
1118                         }
1119                 }
1120
1121                 sealed class StartsWithComparatorPartWholeCheck : IComparer
1122                 {
1123                         public static readonly StartsWithComparator Instance = new StartsWithComparator();
1124
1125                         public int Compare(object p, object w)
1126                         {
1127                                 string part = (string) p;
1128                                 string whole = (string) w;
1129                                 Assert.IsTrue(part == "Part", "#PWC0");
1130                                 Assert.IsTrue(whole == "Whole", "#PWC1");
1131
1132                                 // let the default string comparer deal with null or when part is not smaller then whole
1133                                 if (part == null || whole == null || part.Length >= whole.Length)
1134                                         return String.Compare(part, whole);
1135
1136                                 // loop through all characters that part and whole have in common
1137                                 int pos = 0;
1138                                 bool match;
1139                                 do {
1140                                         match = (part[pos] == whole[pos]);
1141                                 } while (match && ++pos < part.Length);
1142
1143                                 // return result of last comparison
1144                                 return match ? 0 : (part[pos] < whole[pos] ? -1 : 1);
1145                         }
1146                 }
1147
1148                 [Test]
1149                 public void ComparatorUsageTest()
1150                 {
1151                         SortedList sl = new SortedList(StartsWithComparator.Instance);
1152
1153                         sl.Add("Apples", "Value-Apples");
1154                         sl.Add("Bananas", "Value-Bananas");
1155                         sl.Add("Oranges", "Value-Oranges");
1156
1157                         // Ensure 3 objects exist in the collection
1158                         Assert.IsTrue(sl.Count == 3, "Count");
1159
1160                         // Complete Match Test Set
1161                         Assert.IsTrue(sl.ContainsKey("Apples"), "#A0");
1162                         Assert.IsTrue(sl.ContainsKey("Bananas"), "#A1");
1163                         Assert.IsTrue(sl.ContainsKey("Oranges"), "#A2");
1164
1165                         // Partial Match Test Set
1166                         Assert.IsTrue(sl.ContainsKey("Apples are great fruit!"), "#B0");
1167                         Assert.IsTrue(sl.ContainsKey("Bananas are better fruit."), "#B1");
1168                         Assert.IsTrue(sl.ContainsKey("Oranges are fun to peel."), "#B2");
1169
1170                         // Reversed Match Test Set
1171                         Assert.IsFalse(sl.ContainsKey("Value"), "#C0");
1172
1173                         // No match tests
1174                         Assert.IsFalse(sl.ContainsKey("I forgot to bring my bananas."), "#D0");
1175                         Assert.IsFalse(sl.ContainsKey("My apples are on vacation."), "#D0");
1176                         Assert.IsFalse(sl.ContainsKey("The oranges are not ripe yet."), "#D0");
1177
1178                 }
1179
1180                 [Test]
1181                 public void ComparatorPartWholeCheck()
1182                 {
1183                         SortedList sl = new SortedList (StartsWithComparatorPartWholeCheck.Instance);
1184                         sl.Add("Part", "Value-Part");
1185                         Assert.IsFalse(sl.ContainsKey("Whole"), "#PWC2");
1186                 }
1187
1188                 [Test]
1189                 public void NonComparatorStringCheck()
1190                 {
1191                         SortedList sl = new SortedList ();
1192
1193                         sl.Add("Oranges", "Value-Oranges");
1194                         sl.Add("Apples", "Value-Apples");
1195                         sl.Add("Bananas", "Value-Bananas");
1196
1197                         int i = 0;
1198                         Assert.IsTrue(sl.Count == 3, "NCSC #A0");
1199
1200                         Assert.IsTrue(sl.ContainsKey("Apples"), "NCSC #B1");
1201                         Assert.IsTrue(sl.ContainsKey("Bananas"), "NCSC #B2");
1202                         Assert.IsTrue(sl.ContainsKey("Oranges"), "NCSC #B3");
1203
1204                         Assert.IsFalse(sl.ContainsKey("XApples"), "NCSC #C1");
1205                         Assert.IsFalse(sl.ContainsKey("XBananas"), "NCSC #C2");
1206                         Assert.IsFalse(sl.ContainsKey("XOranges"), "NCSC #C3");
1207
1208                         string [] keys = new string [sl.Keys.Count];
1209                         sl.Keys.CopyTo (keys, 0);
1210                         Assert.IsTrue(keys [0] == "Apples", "NCSC #D1");
1211                         Assert.IsTrue(keys [1] == "Bananas", "NCSC #D2");
1212                         Assert.IsTrue(keys [2] == "Oranges", "NCSC #D3");
1213                 }
1214
1215                 private static byte [] _serializedValues = new byte [] {
1216                         0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
1217                         0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
1218                         0x01, 0x00, 0x00, 0x00, 0x27, 0x53, 0x79, 0x73, 0x74,
1219                         0x65, 0x6d, 0x2e, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63,
1220                         0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x6f, 0x72,
1221                         0x74, 0x65, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x2b, 0x56,
1222                         0x61, 0x6c, 0x75, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x01,
1223                         0x00, 0x00, 0x00, 0x0a, 0x73, 0x6f, 0x72, 0x74, 0x65,
1224                         0x64, 0x4c, 0x69, 0x73, 0x74, 0x03, 0x1d, 0x53, 0x79,
1225                         0x73, 0x74, 0x65, 0x6d, 0x2e, 0x43, 0x6f, 0x6c, 0x6c,
1226                         0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53,
1227                         0x6f, 0x72, 0x74, 0x65, 0x64, 0x4c, 0x69, 0x73, 0x74,
1228                         0x09, 0x02, 0x00, 0x00, 0x00, 0x04, 0x02, 0x00, 0x00,
1229                         0x00, 0x1d, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e,
1230                         0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f,
1231                         0x6e, 0x73, 0x2e, 0x53, 0x6f, 0x72, 0x74, 0x65, 0x64,
1232                         0x4c, 0x69, 0x73, 0x74, 0x07, 0x00, 0x00, 0x00, 0x04,
1233                         0x6b, 0x65, 0x79, 0x73, 0x06, 0x76, 0x61, 0x6c, 0x75,
1234                         0x65, 0x73, 0x05, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x07,
1235                         0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x08, 0x63,
1236                         0x6f, 0x6d, 0x70, 0x61, 0x72, 0x65, 0x72, 0x07, 0x6b,
1237                         0x65, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x09, 0x76, 0x61,
1238                         0x6c, 0x75, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x05, 0x05,
1239                         0x00, 0x00, 0x03, 0x03, 0x03, 0x08, 0x08, 0x1b, 0x53,
1240                         0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x43, 0x6f, 0x6c,
1241                         0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e,
1242                         0x43, 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x65, 0x72, 0x25,
1243                         0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x43, 0x6f,
1244                         0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73,
1245                         0x2e, 0x53, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x4c, 0x69,
1246                         0x73, 0x74, 0x2b, 0x4b, 0x65, 0x79, 0x4c, 0x69, 0x73,
1247                         0x74, 0x27, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e,
1248                         0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f,
1249                         0x6e, 0x73, 0x2e, 0x53, 0x6f, 0x72, 0x74, 0x65, 0x64,
1250                         0x4c, 0x69, 0x73, 0x74, 0x2b, 0x56, 0x61, 0x6c, 0x75,
1251                         0x65, 0x4c, 0x69, 0x73, 0x74, 0x09, 0x03, 0x00, 0x00,
1252                         0x00, 0x09, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
1253                         0x00, 0x03, 0x00, 0x00, 0x00, 0x09, 0x05, 0x00, 0x00,
1254                         0x00, 0x0a, 0x09, 0x01, 0x00, 0x00, 0x00, 0x10, 0x03,
1255                         0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x08, 0x08,
1256                         0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x05, 0x00, 0x00,
1257                         0x00, 0x08, 0x08, 0x07, 0x00, 0x00, 0x00, 0x0d, 0x0d,
1258                         0x10, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
1259                         0x06, 0x07, 0x00, 0x00, 0x00, 0x01, 0x42, 0x06, 0x08,
1260                         0x00, 0x00, 0x00, 0x01, 0x41, 0x06, 0x09, 0x00, 0x00,
1261                         0x00, 0x01, 0x43, 0x0d, 0x0d, 0x04, 0x05, 0x00, 0x00,
1262                         0x00, 0x1b, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e,
1263                         0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f,
1264                         0x6e, 0x73, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x72,
1265                         0x65, 0x72, 0x00, 0x00, 0x00, 0x00, 0x0b };
1266         }
1267 }