2009-06-06 Carlos Alberto Cortez <calberto.cortez@gmail.com>
[mono.git] / mcs / class / Managed.Windows.Forms / Test / System.Windows.Forms / ListViewItemTest.cs
1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
8 //
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 //
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 //
20 // Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
21 //
22 // Author:
23 //      Jordi Mas i Hernandez <jordi@ximian.com>
24 //
25 //
26
27 using System;
28 using System.Windows.Forms;
29 using System.Drawing;
30 using System.IO;
31 using System.Reflection;
32 using System.Runtime.Serialization;
33 using System.Runtime.Serialization.Formatters;
34 using System.Runtime.Serialization.Formatters.Binary;
35 using NUnit.Framework;
36         
37 namespace MonoTests.System.Windows.Forms
38 {
39         [TestFixture]
40         public class ListViewItemTest : TestHelper
41         {
42                 [Test]
43                 public void ListViewItemConstructors ()
44                 {
45                         Font fnt = new Font ("Arial", 12);
46                         ListViewItem item1 = new ListViewItem ("Hello folks");
47                         Assert.AreEqual ("Hello folks", item1.Text, "Constructor#1");
48
49                         ListViewItem item2 = new ListViewItem (new string [] {"Element1", "Element2"},
50                                 -1, Color.Blue, Color.Red, fnt);
51
52                         Assert.AreEqual (item2.ForeColor, Color.Blue, "Constructor#2");
53                         Assert.AreEqual (item2.BackColor, Color.Red, "Constructor#3");
54
55                         Assert.AreEqual (2, item2.SubItems.Count,"Constructor#4");
56                         Assert.AreEqual (Color.Blue, item2.SubItems[0].ForeColor,"Constructor#5");
57                         Assert.AreEqual (Color.Red, item2.SubItems[0].BackColor, "Constructor#6");
58                         Assert.AreEqual (fnt, item2.SubItems[0].Font, "Constructor#7");
59                         Assert.AreEqual ("Element1", item2.SubItems[0].Text, "Constructor#8");
60                         Assert.AreEqual ("Element2", item2.SubItems[1].Text, "Constructor#12");
61
62                         ListViewItem item3 = new ListViewItem ((string)null);
63                         Assert.AreEqual (String.Empty, item3.Text, "Constructor#13");
64
65                         ListViewItem item4 = new ListViewItem ((string)null, -99);
66                         Assert.AreEqual (String.Empty, item4.Text, "Constructor#14");
67                         Assert.AreEqual (-99, item4.ImageIndex, "Constructor#15");
68
69                         ListViewItem item5 = new ListViewItem (new string [2]);
70                         Assert.AreEqual (2, item5.SubItems.Count, "Constructor#16");
71                         Assert.IsNotNull (item5.SubItems [0], "Constructor#17");
72                         Assert.IsNotNull (item5.SubItems [1], "Constructor#18");
73
74                         ListViewItem item6 = new ListViewItem (new string [2], -1, Color.Blue, Color.Red,
75                                 fnt);
76                         Assert.AreEqual (2, item6.SubItems.Count, "Constructor#19");
77                         Assert.IsNotNull (item6.SubItems [0], "Constructor#20");
78                         Assert.IsNotNull (item6.SubItems [1], "Constructor#21");
79                         Assert.AreEqual (Color.Blue, item6.ForeColor, "Constructor#22");
80                         Assert.AreEqual (Color.Blue, item6.SubItems [0].ForeColor, "Constructor#23");
81                         Assert.AreEqual (Color.Red, item6.BackColor, "Constructor#24");
82                         Assert.AreEqual (Color.Red, item6.SubItems [0].BackColor, "Constructor#25");
83                         Assert.AreEqual (fnt, item6.Font, "Constructor#26");
84                         Assert.AreEqual (fnt, item6.SubItems [0].Font, "Constructor#27");
85                 }
86
87                 [Test]
88                 public void Constructor2_Text_Null ()
89                 {
90                         ListViewItem item = new ListViewItem ((string) null);
91                         Assert.AreEqual (-1, item.ImageIndex, "#1");
92                         Assert.AreEqual (1, item.SubItems.Count, "#2");
93                         Assert.IsNotNull (item.SubItems [0].Text, "#3");
94                         Assert.AreEqual (string.Empty, item.SubItems [0].Text, "#4");
95                 }
96
97                 [Test]
98                 public void Constructor3_Items_Empty ()
99                 {
100                         ListViewItem item = new ListViewItem (new string [3]);
101                         Assert.AreEqual (-1, item.ImageIndex, "#1");
102                         Assert.AreEqual (3, item.SubItems.Count, "#2");
103                         Assert.AreEqual (string.Empty, item.SubItems [0].Text, "#3");
104                         Assert.AreEqual (string.Empty, item.SubItems [1].Text, "#4");
105                         Assert.AreEqual (string.Empty, item.SubItems [2].Text, "#5");
106                 }
107
108                 [Test]
109                 public void Constructor3_Items_Null ()
110                 {
111                         ListViewItem item = new ListViewItem ((string []) null);
112                         Assert.AreEqual (-1, item.ImageIndex, "#1");
113                         Assert.AreEqual (1, item.SubItems.Count, "#2");
114                         Assert.IsNotNull (item.SubItems [0].Text, "#3");
115                         Assert.AreEqual (string.Empty, item.SubItems [0].Text, "#4");
116                 }
117
118                 [Test]
119                 [ExpectedException (typeof (NullReferenceException))]
120                 public void Constructor4_SubItems_Empty ()
121                 {
122                         new ListViewItem (new ListViewItem.ListViewSubItem [2], 3);
123                 }
124
125                 [Test]
126                 [ExpectedException (typeof (NullReferenceException))]
127                 public void Constructor4_SubItems_Null ()
128                 {
129                         new ListViewItem ((ListViewItem.ListViewSubItem []) null, 3);
130                 }
131
132                 [Test]
133                 public void Constructor5_Text_Null ()
134                 {
135                         ListViewItem item = new ListViewItem ((string) null, 2);
136                         Assert.AreEqual (2, item.ImageIndex, "#1");
137                         Assert.AreEqual (1, item.SubItems.Count, "#2");
138                         Assert.IsNotNull (item.SubItems [0].Text, "#3");
139                         Assert.AreEqual (string.Empty, item.SubItems [0].Text, "#4");
140                 }
141
142                 [Test]
143                 public void Constructor6_Items_Empty ()
144                 {
145                         ListViewItem item = new ListViewItem (new string [3], 5);
146                         Assert.AreEqual (5, item.ImageIndex, "#1");
147                         Assert.AreEqual (3, item.SubItems.Count, "#2");
148                         Assert.AreEqual (string.Empty, item.SubItems [0].Text, "#3");
149                         Assert.AreEqual (string.Empty, item.SubItems [1].Text, "#4");
150                         Assert.AreEqual (string.Empty, item.SubItems [2].Text, "#5");
151                 }
152
153                 [Test]
154                 public void Constructor6_Items_Null ()
155                 {
156                         ListViewItem item = new ListViewItem ((string []) null, 3);
157                         Assert.AreEqual (3, item.ImageIndex, "#1");
158                         Assert.AreEqual (1, item.SubItems.Count, "#2");
159                         Assert.IsNotNull (item.SubItems [0].Text, "#3");
160                         Assert.AreEqual (string.Empty, item.SubItems [0].Text, "#4");
161                 }
162
163                 [Test]
164                 public void Constructor7_Items_Empty ()
165                 {
166                         Font font = new Font (FontFamily.GenericSansSerif, 6);
167
168                         ListViewItem item = new ListViewItem (new string [2], 3, Color.Red,
169                                 Color.Blue, font);
170                         Assert.AreEqual (Color.Blue, item.BackColor, "#1");
171                         Assert.AreEqual (Color.Red, item.ForeColor, "#2");
172                         Assert.AreSame (font, item.Font, "#3");
173                         Assert.AreEqual (3, item.ImageIndex, "#4");
174                         Assert.AreEqual (2, item.SubItems.Count, "#5");
175                         Assert.IsNotNull (item.SubItems [0].Text, "#6");
176                         Assert.AreEqual (string.Empty, item.SubItems [0].Text, "#7");
177                         Assert.IsNotNull (item.SubItems [1].Text, "#8");
178                         Assert.AreEqual (string.Empty, item.SubItems [1].Text, "#9");
179                 }
180
181                 [Test]
182                 public void Constructor7_Items_Null ()
183                 {
184                         Font font = new Font (FontFamily.GenericSansSerif, 6);
185
186                         ListViewItem item = new ListViewItem ((string []) null, 3, Color.Red,
187                                 Color.Blue, font);
188                         Assert.AreEqual (Color.Blue, item.BackColor, "#1");
189                         Assert.AreEqual (Color.Red, item.ForeColor, "#2");
190                         Assert.AreSame (font, item.Font, "#3");
191                         Assert.AreEqual (3, item.ImageIndex, "#4");
192                         Assert.AreEqual (1, item.SubItems.Count, "#5");
193                         Assert.IsNotNull (item.SubItems [0].Text, "#6");
194                         Assert.AreEqual (string.Empty, item.SubItems [0].Text, "#7");
195                 }
196
197 #if NET_2_0
198                 [Test]
199                 public void Constructor9_Text_Null ()
200                 {
201                         ListViewItem item = new ListViewItem ((string) null, "key");
202                         Assert.AreEqual (-1, item.ImageIndex, "#1");
203                         Assert.IsNotNull (item.ImageKey, "#2");
204                         Assert.AreEqual ("key", item.ImageKey, "#3");
205                         Assert.AreEqual (1, item.SubItems.Count, "#4");
206                         Assert.IsNotNull (item.SubItems [0].Text, "#5");
207                         Assert.AreEqual (string.Empty, item.SubItems [0].Text, "#6");
208                 }
209
210                 [Test]
211                 public void Constructor9_ImageKey_Null ()
212                 {
213                         ListViewItem item = new ListViewItem ("name", (string) null);
214                         Assert.AreEqual (-1, item.ImageIndex, "#1");
215                         Assert.IsNotNull (item.ImageKey, "#2");
216                         Assert.AreEqual (string.Empty, item.ImageKey, "#3");
217                         Assert.AreEqual (1, item.SubItems.Count, "#4");
218                         Assert.IsNotNull (item.SubItems [0].Text, "#5");
219                         Assert.AreEqual ("name", item.SubItems [0].Text, "#6");
220                 }
221
222                 [Test]
223                 [ExpectedException (typeof (NullReferenceException))]
224                 public void Constructor10_SubItems_Null ()
225                 {
226                         new ListViewItem ((ListViewItem.ListViewSubItem []) null, "key");
227                 }
228
229                 [Test]
230                 [ExpectedException (typeof (NullReferenceException))]
231                 public void Constructor10_SubItems_Empty ()
232                 {
233                         new ListViewItem (new ListViewItem.ListViewSubItem [2], "key");
234                 }
235
236                 [Test]
237                 public void Constructor10_ImageKey_Null ()
238                 {
239                         ListViewItem.ListViewSubItem subItemA = new ListViewItem.ListViewSubItem ();
240                         subItemA.Text = "A";
241                         ListViewItem.ListViewSubItem subItemB = new ListViewItem.ListViewSubItem ();
242                         subItemB.Text = "B";
243
244                         ListViewItem item = new ListViewItem (new ListViewItem.ListViewSubItem [] {
245                                 subItemA, subItemB }, (string) null);
246                         Assert.AreEqual (-1, item.ImageIndex, "#1");
247                         Assert.IsNotNull (item.ImageKey, "#2");
248                         Assert.AreEqual (string.Empty, item.ImageKey, "#3");
249                         Assert.AreEqual (2, item.SubItems.Count, "#4");
250                         Assert.IsNotNull (item.SubItems [0].Text, "#5");
251                         Assert.AreEqual ("A", item.SubItems [0].Text, "#6");
252                         Assert.IsNotNull (item.SubItems [1].Text, "#7");
253                         Assert.AreEqual ("B", item.SubItems [1].Text, "#8");
254                 }
255
256                 [Test]
257                 public void Constructor_Groups ()
258                 {
259                         ListViewItem itemA = new ListViewItem ((ListViewGroup) null);
260                         Assert.AreEqual (null, itemA.Group, "#A1");
261
262                         ListViewGroup group = new ListViewGroup ("Group A");
263                         group.Items.Add (itemA);
264
265                         ListViewItem itemB = new ListViewItem ("B", group);
266                         Assert.AreEqual (group, itemB.Group, "#B1");
267                         Assert.AreEqual (2, group.Items.Count, "#B2");
268                         Assert.AreEqual (itemB, group.Items [1], "#B3");
269                 }
270
271                 [Test]
272                 public void Constructor_Serializable ()
273                 {
274                         ListViewItem item = new ListViewItem ("A");
275                         ListView lvw = new ListView ();
276                         lvw.Items.Add (item);
277                         lvw.CreateControl (); // Need to calculate layout
278
279                         item.SubItems.Add ("B");
280                         item.SubItems.Add ("C");
281                         item.SubItems.Add ("D");
282                         item.BackColor = Color.AliceBlue;
283                         item.Checked = true;
284                         item.Font = new Font (item.Font, FontStyle.Bold);
285                         item.ForeColor = Color.AntiqueWhite;
286                         item.ImageIndex = 1;
287                         item.Selected = true;
288                         item.Tag = "Tag";
289                         item.UseItemStyleForSubItems = false;
290
291                         ListViewGroup group = lvw.Groups.Add ("GroupKey", "MyGroup");
292                         group.Items.Add (item);
293
294                         item.ImageKey = "MyKey";
295                         item.IndentCount = 2;
296                         item.Name = "MyName";
297                         item.ToolTipText = "MyTooltipText";
298
299                         MemoryStream ms = new MemoryStream ();
300                         BinaryFormatter formatter = new BinaryFormatter ();
301                         formatter.Serialize (ms, item);
302
303                         ListViewItem item2 = null;
304                         ms.Position = 0;
305
306                         item2 = (ListViewItem) formatter.Deserialize (ms);
307                         Assert.AreEqual ("A", item2.Text, "#A1");
308                         Assert.AreEqual ("A", item2.SubItems [0].Text, "#A2");
309                         Assert.AreEqual ("B", item2.SubItems [1].Text, "#A3");
310                         Assert.AreEqual ("C", item2.SubItems [2].Text, "#A4");
311                         Assert.AreEqual (Color.AliceBlue, item2.BackColor, "#A4");
312                         Assert.AreEqual (null, item2.ListView, "#A5");
313                         Assert.AreEqual (Rectangle.Empty, item2.Bounds, "#A6");
314                         Assert.AreEqual (item.Checked, item2.Checked, "#A7");
315                         Assert.AreEqual (item.Font, item2.Font, "#A8");
316                         Assert.AreEqual (item.ForeColor, item2.ForeColor, "#A9");
317                         Assert.AreEqual (item.ImageIndex, item2.ImageIndex, "#A10");
318                         Assert.AreEqual (-1, item2.Index, "#A11");
319                         Assert.AreEqual (false, item2.Selected, "#A12");
320                         Assert.AreEqual (null, item2.Tag, "#A13");
321                         Assert.AreEqual (item.UseItemStyleForSubItems, item2.UseItemStyleForSubItems, "#A14");
322                         Assert.AreEqual (item.ImageKey, item2.ImageKey, "#A15");
323                         Assert.AreEqual (0, item2.IndentCount, "#A16");
324                         Assert.AreEqual (String.Empty, item2.Name, "#A17");
325                         Assert.AreEqual (new Point (-1, -1), item2.Position, "#A18");
326                         Assert.AreEqual (String.Empty, item2.ToolTipText, "#A19");
327                         Assert.AreEqual (item.Group.Header, item2.Group.Header, "#A20");
328                 }
329 #endif
330
331                 [Test]
332                 public void ListViewItemDefaultValues ()
333                 {
334                         ListViewItem item = new ListViewItem ();
335
336                         Assert.IsFalse (item.Focused, "DefaultValues#3");
337                         Assert.IsFalse (item.Checked, "DefaultValues#4");
338                         Assert.AreEqual (string.Empty, item.Text, "DefaultValues#5");
339                         Assert.IsTrue (item.UseItemStyleForSubItems, "DefaultValues#6");
340                         Assert.AreEqual (-1, item.ImageIndex, "DefaultValues#7");
341 #if NET_2_0
342                         Assert.AreEqual (String.Empty, item.Name, "DefaultValues#8");
343                         Assert.AreEqual(String.Empty, item.ImageKey, "DefaultValues#9");
344                         Assert.AreEqual (String.Empty, item.ToolTipText, "DefaultValues#10");
345                         Assert.AreEqual (0, item.IndentCount, "DefaultValues#11");
346 #endif
347                 }
348
349                 [Test]
350                 public void ListViewItemBackColor ()
351                 {
352                         ListViewItem item = new ListViewItem ();
353
354                         ListView lv = new ListView ();
355                         lv.Items.Add (item);
356                         lv.BackColor = Color.Orange;
357                         Assert.AreEqual (lv.BackColor, item.BackColor, "BackColor#1");
358                         Assert.AreEqual (lv.BackColor, item.SubItems [0].BackColor, "BackColor#2");
359
360                         item.BackColor = Color.Navy;
361                         Assert.AreEqual (Color.Navy, item.BackColor, "BackColor#3");
362                         Assert.AreEqual (Color.Navy, item.SubItems [0].BackColor, "BackColor#4");
363
364                         item.SubItems [0].BackColor = Color.Green;
365                         Assert.AreEqual (Color.Green, item.BackColor, "BackColor#5");
366                         Assert.AreEqual (Color.Green, item.SubItems [0].BackColor, "BackColor#6");
367                 }
368
369                 [Test]
370                 public void ListViewItemForeColor ()
371                 {
372                         ListViewItem item = new ListViewItem ();
373
374                         ListView lv = new ListView ();
375                         lv.Items.Add (item);
376                         lv.ForeColor = Color.Orange;
377                         Assert.AreEqual (lv.ForeColor, item.ForeColor, "ForeColor#1");
378                         Assert.AreEqual (lv.ForeColor, item.SubItems [0].ForeColor, "ForeColor#2");
379
380                         item.ForeColor = Color.Navy;
381                         Assert.AreEqual (Color.Navy, item.ForeColor, "ForeColor#3");
382                         Assert.AreEqual (Color.Navy, item.SubItems [0].ForeColor, "ForeColor#4");
383
384                         item.SubItems [0].ForeColor = Color.Green;
385                         Assert.AreEqual (Color.Green, item.ForeColor, "ForeColor#5");
386                         Assert.AreEqual (Color.Green, item.SubItems [0].ForeColor, "ForeColor#6");
387                 }
388
389                 [Test]
390                 public void ListViewItemFocused ()
391                 {
392                         ListView lv = new ListView ();
393                         ListViewItem item1 = lv.Items.Add ("A");
394                         ListViewItem item2 = lv.Items.Add ("B");
395                         ListViewItem item3 = lv.Items.Add ("C");
396
397                         // Need to show form
398                         Form form = new Form ();
399                         lv.Parent = form;
400                         form.Show ();
401
402                         item1.Focused = true;
403                         Assert.IsTrue (item1.Focused, "#A1");
404                         Assert.IsFalse (item2.Focused, "#A2");
405                         Assert.IsFalse (item3.Focused, "#A3");
406                         Assert.AreEqual (item1, lv.FocusedItem, "#A4");
407
408                         item2.Focused = true;
409                         Assert.IsFalse (item1.Focused, "#B1");
410                         Assert.IsTrue (item2.Focused, "#B2");
411                         Assert.IsFalse (item3.Focused, "#B3");
412                         Assert.AreEqual (item2, lv.FocusedItem, "#B4");
413
414                         item3.Focused = true;
415                         Assert.IsFalse (item1.Focused, "#C1");
416                         Assert.IsFalse (item2.Focused, "#C2");
417                         Assert.IsTrue (item3.Focused, "#C3");
418                         Assert.AreEqual (item3, lv.FocusedItem, "#C4");
419
420                         item3.Focused = false;
421                         Assert.IsFalse (item1.Focused, "#D1");
422                         Assert.IsFalse (item2.Focused, "#D2");
423                         Assert.IsFalse (item3.Focused, "#D3");
424                         Assert.IsNull (lv.FocusedItem, "#D4");
425
426                         // Test Focused for Items without owner
427                         ListViewItem item4 = new ListViewItem ();
428                         Assert.IsFalse (item4.Focused);
429                         item4.Focused = true;
430
431                         Assert.IsFalse (item4.Focused, "#E1");
432
433                         form.Dispose ();
434                 }
435
436 #if NET_2_0
437                 [Test]
438                 [ExpectedException (typeof (ArgumentOutOfRangeException))]
439                 public void ListViewItemIndent ()
440                 {
441                         ListViewItem item = new ListViewItem ();
442                         item.IndentCount = -1;
443                 }
444
445                 [Test]
446                 public void ListViewItemPosition ()
447                 {
448                         ListViewItem itemA = new ListViewItem ();
449                         ListViewItem itemB = new ListViewItem ();
450                         Point initial_pos = new Point (-1, -1);
451
452                         Assert.AreEqual (itemA.Position, initial_pos, "#A1");
453                         Assert.AreEqual (itemB.Position, initial_pos, "#A2");
454
455                         ListView lvw = new ListView ();
456                         lvw.Items.AddRange (new ListViewItem [] { itemA, itemB });
457
458                         Assert.AreEqual (itemA.Position, initial_pos, "#B1");
459                         Assert.AreEqual (itemB.Position, initial_pos, "#B2");
460
461                         // Create handle for lvw
462                         lvw.CreateControl ();
463
464                         Point itemA_pos = itemA.Position;
465                         Point itemB_pos = itemB.Position;
466
467                         Assert.IsTrue (itemA_pos != initial_pos, "#C1");
468                         Assert.IsTrue (itemB_pos != initial_pos, "#C2");
469
470                         // Now remove
471                         lvw.Items.Clear ();
472
473                         Assert.AreEqual (itemA_pos, itemA.Position, "#D1");
474                         Assert.AreEqual (itemB_pos, itemB.Position, "#D2");
475
476                         // Add in reverse order
477                         lvw.Items.AddRange (new ListViewItem [] { itemB, itemA });
478
479                         Assert.IsTrue (itemA_pos != itemA.Position, "#E1");
480                         Assert.IsTrue (itemB_pos != itemB.Position, "#E2");
481
482                         // Remove from ListView
483                         lvw.Items.Clear ();
484                         Assert.IsTrue (initial_pos != itemA.Position, "#F1");
485                         Assert.IsTrue (initial_pos != itemB.Position, "#F2");
486
487                         //
488                         // Now add them in other view (no effect)
489                         //
490                         lvw.Items.AddRange (new ListViewItem [] { itemA, itemB });
491                         lvw.Columns.Add ("Column A");
492                         lvw.View = View.Details;
493
494                         itemB_pos = itemB.Position;
495                         Assert.IsTrue (Point.Empty != itemB_pos, "#G1");
496                         Assert.IsTrue (initial_pos != itemB_pos, "#G2");
497
498                         itemB.Position = Point.Empty;
499                         Assert.AreEqual (itemB_pos, itemB.Position, "#H1");
500                 }
501 #endif
502
503                 [Test] // bug #330415 and #331643
504                 public void RemoveFocusedItem ()
505                 {
506                         ListView lv = new ListView ();
507                         ListViewItem itemA = lv.Items.Add ("ItemA");
508                         ListViewItem itemB = lv.Items.Add ("ItemB");
509                         ListViewItem itemC = lv.Items.Add ("ItemC");
510                         ListViewItem itemD = lv.Items.Add ("ItemD");
511
512                         Form form = new Form ();
513                         form.ShowInTaskbar = false;
514                         form.Controls.Add (lv);
515                         form.Show ();
516
517                         // Calling Form.Show () doesn't fire
518                         // GotFocus event on child controls (asynch messages),
519                         // thus we can't get the first item focused,
520                         // but we DO when calling Application.Run ()
521
522                         //Assert.IsTrue (itemA.Focused, "#A1");
523                         Assert.IsFalse (itemB.Focused, "#A2");
524                         Assert.IsFalse (itemC.Focused, "#A3");
525                         Assert.IsFalse (itemD.Focused, "#A4");
526
527                         itemB.Focused = true;
528
529                         Assert.IsFalse (itemA.Focused, "#B1");
530                         Assert.IsTrue (itemB.Focused, "#B2");
531                         Assert.IsFalse (itemC.Focused, "#B3");
532                         Assert.IsFalse (itemD.Focused, "#B4");
533
534                         lv.Items.Remove (itemB);
535
536                         Assert.IsFalse (itemA.Focused, "#C1");
537                         Assert.IsFalse (itemB.Focused, "#C2");
538                         Assert.IsTrue (itemC.Focused, "#C3");
539                         Assert.IsFalse (itemD.Focused, "#C4");
540
541                         itemD.Focused = true;
542
543                         Assert.IsFalse (itemA.Focused, "#D1");
544                         Assert.IsFalse (itemB.Focused, "#D2");
545                         Assert.IsFalse (itemC.Focused, "#D3");
546                         Assert.IsTrue (itemD.Focused, "#D4");
547
548                         lv.Items.Remove (itemD);
549
550                         Assert.IsFalse (itemA.Focused, "#E1");
551                         Assert.IsFalse (itemB.Focused, "#E2");
552                         Assert.IsTrue (itemC.Focused, "#E3");
553                         Assert.IsFalse (itemD.Focused, "#E4");
554
555                         lv.Items.Remove (itemC);
556
557                         Assert.IsTrue (itemA.Focused, "#F1");
558                         Assert.IsFalse (itemB.Focused, "#F2");
559                         Assert.IsFalse (itemC.Focused, "#F3");
560                         Assert.IsFalse (itemD.Focused, "#F4");
561
562                         lv.Items.Remove (itemA);
563
564                         Assert.IsFalse (itemA.Focused, "#G1");
565                         Assert.IsFalse (itemB.Focused, "#G2");
566                         Assert.IsFalse (itemC.Focused, "#G3");
567                         Assert.IsFalse (itemD.Focused, "#G4");
568
569                         ListViewItem itemE = lv.Items.Add ("ItemE");
570
571                         Assert.IsFalse (itemA.Focused, "#H1");
572                         Assert.IsFalse (itemB.Focused, "#H2");
573                         Assert.IsFalse (itemC.Focused, "#H3");
574                         Assert.IsFalse (itemD.Focused, "#H4");
575                         Assert.IsFalse (itemE.Focused, "#H5");
576
577                         form.Dispose ();
578                 }
579         
580 #if NET_2_0
581                 [Test]
582                 public void ListViewItemGroup ()
583                 {
584                         ListViewGroup lvg1 = new ListViewGroup ();
585                         ListViewGroup lvg2 = new ListViewGroup ();
586                         ListViewItem lvi = new ListViewItem ();
587                 
588                         lvg1.Items.Add (lvi);
589                 
590                         Assert.AreEqual (1, lvg1.Items.Count, "#A1");
591                         Assert.AreEqual (lvg1, lvi.Group, "#A2");
592                         lvi.Group = lvg2;
593                 
594                         Assert.AreEqual (0, lvg1.Items.Count, "#B1");
595                         Assert.AreEqual (1, lvg2.Items.Count, "#B2");
596                         Assert.AreEqual (lvg2, lvi.Group, "#B3");
597                 }
598 #endif
599
600                 [Test]
601                 public void ListViewItemUseItemStyleForSubItems ()
602                 {
603                         ListViewItem item = new ListViewItem ();
604                         Assert.AreEqual (1, item.SubItems.Count);
605
606                         // UseitemStyleForSubItems works at draw level
607                         item.UseItemStyleForSubItems = true;
608
609                         ListViewItem.ListViewSubItem subitem0 = item.SubItems [0];
610                         Color subitem0_back_color = subitem0.BackColor = Color.Black;
611                         Color subitem0_fore_color = subitem0.ForeColor = Color.White;
612
613                         Assert.AreEqual (subitem0_back_color, item.SubItems [0].BackColor, "UseItemStyleForSubItems#1");
614                         Assert.AreEqual (subitem0_fore_color, item.SubItems [0].ForeColor, "UseItemStyleForSubItems#2");
615                         Assert.AreEqual (item.BackColor, item.SubItems [0].BackColor, "UseItemStyleForSubItems#3");
616                         Assert.AreEqual (item.ForeColor, item.SubItems [0].ForeColor, "UseItemStyleForSubItems#4");
617
618                         ListViewItem.ListViewSubItem subitem1 = item.SubItems.Add ("SubItem");
619                         Color subitem1_back_color = subitem1.BackColor = Color.Blue;
620                         Color subitem1_fore_color = subitem1.ForeColor = Color.Gray;
621
622                         Assert.AreEqual (subitem1_back_color, subitem1.BackColor, "UseItemStyleForSubItem#5");
623                         Assert.AreEqual (subitem1_fore_color, subitem1.ForeColor, "UseItemStyleForSubItem#6");
624                 }
625
626                 [Test]
627                 public void ListViewItemTestClone ()
628                 {
629                         Form f = new Form ();
630                         ListView lv = new ListView ();
631                         lv.Parent = f;
632
633                         ListViewItem item1 = lv.Items.Add ("Hello");
634                         item1.ForeColor = Color.Blue;
635                         item1.BackColor = Color.Red;
636                         item1.Font = new Font ("Arial", 14);
637                         item1.SubItems.Add ("Element2");
638 #if NET_2_0
639                         item1.ToolTipText = item1.Text;
640 #endif
641
642                         f.Show ();
643
644                         ListViewItem item2 =  (ListViewItem) item1.Clone ();
645                         Assert.AreEqual (Color.Blue, item2.ForeColor, "#1");
646                         Assert.AreEqual (Color.Red, item2.BackColor, "#2");
647                         Assert.AreEqual ("Hello", item2.Text, "#3");
648                         Assert.AreEqual (item1.Font, item2.Font, "#4");
649                         Assert.AreEqual (2, item2.SubItems.Count, "#5");
650                         Assert.AreEqual ("Hello", item2.SubItems [0].Text, "#6");
651                         Assert.AreEqual ("Element2", item2.SubItems[1].Text, "#7");
652 #if NET_2_0
653                         Assert.AreEqual (item1.ToolTipText, item2.ToolTipText, "#8");
654 #endif
655                         // Focused is not copied
656                         // These tests shoule be re-enabled when #333693
657                         /*Assert.IsTrue (item1.Focused, "#9");
658                         Assert.IsFalse (item2.Focused, "#10");*/
659
660                         f.Dispose ();
661                 }
662
663 #if NET_2_0
664                 [Test]
665                 public void ListViewItemTestImageIndex()
666                 {
667                         ListViewItem item1 = new ListViewItem();
668
669                         item1.ImageKey = "Key1";
670                         item1.ImageIndex = 0;
671                         Assert.AreEqual(String.Empty, item1.ImageKey, "ImageIndex#1");
672
673                         item1.ImageIndex = 0;
674                         item1.ImageKey = "Key1";
675                         Assert.AreEqual (-1, item1.ImageIndex, "ImageIndex#2");
676
677                         item1.ImageKey = "Key1";
678                         item1.ImageIndex = -1;
679                         Assert.AreEqual (String.Empty, item1.ImageKey, "ImageIndex#3");
680
681                         item1.ImageIndex = 0;
682                         item1.ImageKey = String.Empty;
683                         Assert.AreEqual (-1, item1.ImageIndex, "ImageIndex#4");
684                 }
685
686                 [Test]
687                 public void ListViewItemToolTipText ()
688                 {
689                         ListViewItem item1 = new ListViewItem();
690                         item1.ToolTipText = null;
691                         Assert.AreEqual (String.Empty, item1.ToolTipText, "ToolTipText#1");
692                 }
693 #endif
694         }
695
696         [TestFixture]
697         public class ListViewSubItemTest : TestHelper
698         {
699                 [Test] // ctor ()
700                 public void Constructor1 ()
701                 {
702                         ListViewItem.ListViewSubItem subItem = new ListViewItem.ListViewSubItem ();
703                         Assert.AreEqual (string.Empty, subItem.Text, "#1");
704                         Assert.AreEqual (SystemColors.Window, subItem.BackColor, "#2");
705                         Assert.AreEqual (SystemColors.WindowText, subItem.ForeColor, "#3");
706 #if NET_2_0
707                         Assert.AreEqual (SystemFonts.DefaultFont, subItem.Font, "#4");
708 #endif
709                 }
710
711                 [Test] // ctor (ListViewItem, String)
712                 public void Constructor2 ()
713                 {
714                         ListViewItem.ListViewSubItem subItem;
715                         ListViewItem item = new ListViewItem ();
716                         
717                         subItem = new ListViewItem.ListViewSubItem (null, null);
718                         Assert.IsNotNull (subItem.Font, "#A1");
719 #if NET_2_0
720                         Assert.AreEqual (string.Empty, subItem.Name, "#A2");
721                         Assert.IsNull (subItem.Tag, "#A3");
722 #endif
723                         Assert.AreEqual (String.Empty, subItem.Text, "#A4");
724
725                         subItem = new ListViewItem.ListViewSubItem (item, "SubItem2");
726                         Assert.IsNotNull (subItem.Font, "#B1");
727 #if NET_2_0
728                         Assert.AreEqual (string.Empty, subItem.Name, "#B2");
729                         Assert.IsNull (subItem.Tag, "#B3");
730 #endif
731                         Assert.AreEqual ("SubItem2", subItem.Text, "#B4");
732                 }
733
734                 [Test] // ctor (ListViewItem, String, Color, Color, Font)
735                 public void Constructor3 ()
736                 {
737                         ListViewItem.ListViewSubItem subItem;
738                         Font font = new Font ("Arial", 12);
739                         ListViewItem item = new ListViewItem ();
740
741                         subItem = new ListViewItem.ListViewSubItem (null, null,
742                                 Color.Blue, Color.Red, null);
743                         Assert.AreEqual (Color.Red, subItem.BackColor, "#A1");
744                         Assert.IsNotNull (subItem.Font, "#A2");
745                         Assert.AreEqual (Color.Blue, subItem.ForeColor, "#A3");
746 #if NET_2_0
747                         Assert.AreEqual (string.Empty, subItem.Name, "#A4");
748                         Assert.IsNull (subItem.Tag, "#A5");
749 #endif
750                         Assert.AreEqual (string.Empty, subItem.Text, "#A6");
751
752                         subItem = new ListViewItem.ListViewSubItem (item, "SubItem3",
753                                 Color.Blue, Color.Green, font);
754                         Assert.AreEqual (Color.Green, subItem.BackColor, "#B1");
755                         Assert.AreSame (font, subItem.Font, "#B2");
756                         Assert.AreEqual (Color.Blue, subItem.ForeColor, "#B3");
757 #if NET_2_0
758                         Assert.AreEqual (string.Empty, subItem.Name, "#B4");
759                         Assert.IsNull (subItem.Tag, "#B5");
760 #endif
761                         Assert.AreEqual ("SubItem3", subItem.Text, "#B6");
762                 }
763
764 #if NET_2_0
765                 [Test]
766                 public void Name ()
767                 {
768                         ListViewItem.ListViewSubItem subItem = new ListViewItem.ListViewSubItem ();
769                         subItem.Name = "foo";
770                         Assert.AreEqual ("foo", subItem.Name, "#1");
771                         subItem.Name = null;
772                         Assert.AreEqual (string.Empty, subItem.Name, "#2");
773                         subItem.Name = "bar";
774                         Assert.AreEqual ("bar", subItem.Name, "#3");
775                         subItem.Name = string.Empty;
776                         Assert.AreEqual (string.Empty, subItem.Name, "#4");
777                         subItem.Name = " \t ";
778                         Assert.AreEqual (" \t ", subItem.Name, "#5");
779                 }
780
781                 [Test]
782                 public void Tag ()
783                 {
784                         ListViewItem.ListViewSubItem subItem = new ListViewItem.ListViewSubItem ();
785                         subItem.Tag = "foo";
786                         Assert.AreEqual ("foo", subItem.Tag, "#1");
787                         subItem.Tag = null;
788                         Assert.IsNull (subItem.Tag, "#2");
789                         subItem.Tag = 5;
790                         Assert.AreEqual (5, subItem.Tag, "#3");
791                 }
792 #endif
793
794                 [Test]
795                 public void Text ()
796                 {
797                         ListViewItem.ListViewSubItem subItem = new ListViewItem.ListViewSubItem ();
798                         subItem.Text = "foo";
799                         Assert.AreEqual ("foo", subItem.Text, "#1");
800                         subItem.Text = null;
801                         Assert.AreEqual (string.Empty, subItem.Text, "#2");
802                         subItem.Text = "bar";
803                         Assert.AreEqual ("bar", subItem.Text, "#3");
804                         subItem.Text = string.Empty;
805                         Assert.AreEqual (string.Empty, subItem.Text, "#4");
806                         subItem.Text = " \t ";
807                         Assert.AreEqual (" \t ", subItem.Text, "#5");
808                 }
809
810                 [Test]
811                 public void Serialize ()
812                 {
813                         ListViewItem.ListViewSubItem subItem;
814                         Font font = new Font ("Arial", 12);
815                         ListViewItem item = new ListViewItem ();
816
817                         subItem = new ListViewItem.ListViewSubItem (item,
818                                 "SubItemText", Color.Yellow, Color.Green,
819                                 font);
820 #if NET_2_0
821                         subItem.Name = "foo";
822                         subItem.Tag = "bar";
823 #endif
824
825                         MemoryStream ms = new MemoryStream ();
826                         BinaryFormatter formatter = new BinaryFormatter ();
827                         formatter.Serialize (ms, subItem);
828                         ms.Position = 0;
829
830                         subItem = (ListViewItem.ListViewSubItem)
831                                 formatter.Deserialize (ms);
832
833                         Assert.AreEqual (Color.Green, subItem.BackColor, "#A1");
834                         Assert.AreEqual (font, subItem.Font, "#A2");
835                         Assert.AreEqual (Color.Yellow, subItem.ForeColor, "#A3");
836 #if NET_2_0
837                         Assert.AreEqual (string.Empty, subItem.Name, "#A4");
838                         Assert.IsNull (subItem.Tag, "#A5");
839 #endif
840                         Assert.AreEqual ("SubItemText", subItem.Text, "#A6");
841
842                         ms.Position = 0;
843                         byte [] ser = new byte [ms.Length];
844                         ms.Read (ser, 0, ser.Length);
845                 }
846
847                 [Test]
848                 [Category ("NotDotNet")]
849                 [Category ("NotWorking")] // fails on buildbot
850                 public void SerializeExact_Mono ()
851                 {
852                         ListViewItem.ListViewSubItem subItem;
853                         Font font = new Font ("Arial", 12);
854                         ListViewItem item = new ListViewItem ();
855
856                         subItem = new ListViewItem.ListViewSubItem (item,
857                                 "SubItemText", Color.Yellow, Color.Green,
858                                 font);
859 #if NET_2_0
860                         subItem.Name = "foo";
861                         subItem.Tag = "bar";
862 #endif
863
864                         MemoryStream ms = new MemoryStream ();
865                         BinaryFormatter formatter = new BinaryFormatter ();
866                         formatter.AssemblyFormat = FormatterAssemblyStyle.Full;
867                         formatter.Serialize (ms, subItem);
868                         ms.Position = 0;
869
870                         byte [] ser = new byte [ms.Length];
871                         ms.Read (ser, 0, ser.Length);
872
873 #if NET_2_0
874                         Assert.AreEqual (_serializedV20_Mono, ser);
875 #else
876                         Assert.AreEqual (_serializedV11_Mono, ser);
877 #endif
878                 }
879
880                 [Test]
881                 [Category ("NotWorking")]
882                 public void SerializeExact_MS ()
883                 {
884                         ListViewItem.ListViewSubItem subItem;
885                         Font font = new Font ("Arial", 12);
886                         ListViewItem item = new ListViewItem ();
887
888                         subItem = new ListViewItem.ListViewSubItem (item,
889                                 "SubItemText", Color.Yellow, Color.Green,
890                                 font);
891 #if NET_2_0
892                         subItem.Name = "foo";
893                         subItem.Tag = "bar";
894 #endif
895
896                         MemoryStream ms = new MemoryStream ();
897                         BinaryFormatter formatter = new BinaryFormatter ();
898                         formatter.Serialize (ms, subItem);
899                         ms.Position = 0;
900
901                         byte [] ser = new byte [ms.Length];
902                         ms.Read (ser, 0, ser.Length);
903
904 #if NET_2_0
905                         Assert.AreEqual (_serializedV20_MS, ser);
906 #else
907                         Assert.AreEqual (_serializedV11_MS, ser);
908 #endif
909                 }
910
911                 [Test]
912                 public void Deserialize ()
913                 {
914                         ListViewItem.ListViewSubItem subItem;
915                         MemoryStream ms;
916                         BinaryFormatter formatter = new BinaryFormatter ();
917
918                         ms = new MemoryStream ();
919                         ms.Write (_serializedV11_Mono, 0, _serializedV11_Mono.Length);
920                         ms.Position = 0;
921
922                         subItem = (ListViewItem.ListViewSubItem)
923                                 formatter.Deserialize (ms);
924
925                         // FIXME: bug #410693
926                         //Assert.AreEqual (Color.Green, subItem.BackColor, "#A1");
927                         Assert.AreEqual ("Green", subItem.BackColor.Name, "#A1");
928                         Assert.IsNotNull (subItem.Font, "#A2");
929                         // FIXME: bug #410693
930                         //Assert.AreEqual (Color.Yellow, subItem.ForeColor, "#A3");
931                         Assert.AreEqual ("Yellow", subItem.ForeColor.Name, "#A3");
932 #if NET_2_0
933                         Assert.AreEqual (string.Empty, subItem.Name, "#A4");
934                         Assert.IsNull (subItem.Tag, "#A5");
935 #endif
936                         Assert.AreEqual ("SubItemText", subItem.Text, "#A6");
937
938                         ms = new MemoryStream ();
939                         ms.Write (_serializedV11_MS, 0, _serializedV11_MS.Length);
940                         ms.Position = 0;
941
942                         subItem = (ListViewItem.ListViewSubItem)
943                                 formatter.Deserialize (ms);
944
945                         // FIXME: bug #410693
946                         //Assert.AreEqual (Color.Green, subItem.BackColor, "#B1");
947                         Assert.AreEqual ("Green", subItem.BackColor.Name, "#B1");
948                         Assert.IsNotNull (subItem.Font, "#B2");
949                         // FIXME: bug #410693
950                         //Assert.AreEqual (Color.Yellow, subItem.ForeColor, "#B3");
951                         Assert.AreEqual ("Yellow", subItem.ForeColor.Name, "#B3");
952 #if NET_2_0
953                         Assert.AreEqual (string.Empty, subItem.Name, "#B4");
954                         Assert.IsNull (subItem.Tag, "#B5");
955 #endif
956                         Assert.AreEqual ("SubItemText", subItem.Text, "#B6");
957
958 #if NET_2_0
959                         ms = new MemoryStream ();
960                         ms.Write (_serializedV20_Mono, 0, _serializedV20_Mono.Length);
961                         ms.Position = 0;
962
963                         subItem = (ListViewItem.ListViewSubItem)
964                                 formatter.Deserialize (ms);
965
966                         // FIXME: bug #410693
967                         //Assert.AreEqual (Color.Green, subItem.BackColor, "#C1");
968                         Assert.AreEqual ("Green", subItem.BackColor.Name, "#C1");
969                         Assert.IsNotNull (subItem.Font, "#C2");
970                         // FIXME: bug #410693
971                         //Assert.AreEqual (Color.Yellow, subItem.ForeColor, "#C3");
972                         Assert.AreEqual ("Yellow", subItem.ForeColor.Name, "#C3");
973                         Assert.AreEqual (string.Empty, subItem.Name, "#C4");
974                         Assert.IsNull (subItem.Tag, "#C5");
975                         Assert.AreEqual ("SubItemText", subItem.Text, "#C6");
976
977                         ms = new MemoryStream ();
978                         ms.Write (_serializedV20_MS, 0, _serializedV20_MS.Length);
979                         ms.Position = 0;
980
981                         subItem = (ListViewItem.ListViewSubItem)
982                                 formatter.Deserialize (ms);
983
984                         // FIXME: bug #410693
985                         //Assert.AreEqual (Color.Green, subItem.BackColor, "#D1");
986                         Assert.AreEqual ("Green", subItem.BackColor.Name, "#D1");
987                         Assert.IsNotNull (subItem.Font, "#D2");
988                         // FIXME: bug #410693
989                         //Assert.AreEqual (Color.Yellow, subItem.ForeColor, "#D3");
990                         Assert.AreEqual ("Yellow", subItem.ForeColor.Name, "#D3");
991                         Assert.AreEqual (string.Empty, subItem.Name, "#D4");
992                         Assert.IsNull (subItem.Tag, "#D5");
993                         Assert.AreEqual ("SubItemText", subItem.Text, "#D6");
994 #endif
995                 }
996
997                 static byte [] _serializedV11_MS = {
998                         0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00,
999                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x02, 0x00, 0x00, 0x00,
1000                         0x5a, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x57, 0x69, 0x6e,
1001                         0x64, 0x6f, 0x77, 0x73, 0x2e, 0x46, 0x6f, 0x72, 0x6d, 0x73, 0x2c,
1002                         0x20, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x31, 0x2e,
1003                         0x30, 0x2e, 0x35, 0x30, 0x30, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x43,
1004                         0x75, 0x6c, 0x74, 0x75, 0x72, 0x65, 0x3d, 0x6e, 0x65, 0x75, 0x74,
1005                         0x72, 0x61, 0x6c, 0x2c, 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63,
1006                         0x4b, 0x65, 0x79, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x3d, 0x62, 0x37,
1007                         0x37, 0x61, 0x35, 0x63, 0x35, 0x36, 0x31, 0x39, 0x33, 0x34, 0x65,
1008                         0x30, 0x38, 0x39, 0x05, 0x01, 0x00, 0x00, 0x00, 0x31, 0x53, 0x79,
1009                         0x73, 0x74, 0x65, 0x6d, 0x2e, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77,
1010                         0x73, 0x2e, 0x46, 0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x4c, 0x69, 0x73,
1011                         0x74, 0x56, 0x69, 0x65, 0x77, 0x49, 0x74, 0x65, 0x6d, 0x2b, 0x4c,
1012                         0x69, 0x73, 0x74, 0x56, 0x69, 0x65, 0x77, 0x53, 0x75, 0x62, 0x49,
1013                         0x74, 0x65, 0x6d, 0x02, 0x00, 0x00, 0x00, 0x04, 0x74, 0x65, 0x78,
1014                         0x74, 0x05, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x01, 0x04, 0x3e, 0x53,
1015                         0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x57, 0x69, 0x6e, 0x64, 0x6f,
1016                         0x77, 0x73, 0x2e, 0x46, 0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x4c, 0x69,
1017                         0x73, 0x74, 0x56, 0x69, 0x65, 0x77, 0x49, 0x74, 0x65, 0x6d, 0x2b,
1018                         0x4c, 0x69, 0x73, 0x74, 0x56, 0x69, 0x65, 0x77, 0x53, 0x75, 0x62,
1019                         0x49, 0x74, 0x65, 0x6d, 0x2b, 0x53, 0x75, 0x62, 0x49, 0x74, 0x65,
1020                         0x6d, 0x53, 0x74, 0x79, 0x6c, 0x65, 0x02, 0x00, 0x00, 0x00, 0x02,
1021                         0x00, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x00, 0x0b, 0x53, 0x75,
1022                         0x62, 0x49, 0x74, 0x65, 0x6d, 0x54, 0x65, 0x78, 0x74, 0x09, 0x04,
1023                         0x00, 0x00, 0x00, 0x0c, 0x05, 0x00, 0x00, 0x00, 0x54, 0x53, 0x79,
1024                         0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72, 0x61, 0x77, 0x69, 0x6e,
1025                         0x67, 0x2c, 0x20, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3d,
1026                         0x31, 0x2e, 0x30, 0x2e, 0x35, 0x30, 0x30, 0x30, 0x2e, 0x30, 0x2c,
1027                         0x20, 0x43, 0x75, 0x6c, 0x74, 0x75, 0x72, 0x65, 0x3d, 0x6e, 0x65,
1028                         0x75, 0x74, 0x72, 0x61, 0x6c, 0x2c, 0x20, 0x50, 0x75, 0x62, 0x6c,
1029                         0x69, 0x63, 0x4b, 0x65, 0x79, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x3d,
1030                         0x62, 0x30, 0x33, 0x66, 0x35, 0x66, 0x37, 0x66, 0x31, 0x31, 0x64,
1031                         0x35, 0x30, 0x61, 0x33, 0x61, 0x05, 0x04, 0x00, 0x00, 0x00, 0x3e,
1032                         0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x57, 0x69, 0x6e, 0x64,
1033                         0x6f, 0x77, 0x73, 0x2e, 0x46, 0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x4c,
1034                         0x69, 0x73, 0x74, 0x56, 0x69, 0x65, 0x77, 0x49, 0x74, 0x65, 0x6d,
1035                         0x2b, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x69, 0x65, 0x77, 0x53, 0x75,
1036                         0x62, 0x49, 0x74, 0x65, 0x6d, 0x2b, 0x53, 0x75, 0x62, 0x49, 0x74,
1037                         0x65, 0x6d, 0x53, 0x74, 0x79, 0x6c, 0x65, 0x03, 0x00, 0x00, 0x00,
1038                         0x09, 0x62, 0x61, 0x63, 0x6b, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x09,
1039                         0x66, 0x6f, 0x72, 0x65, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x04, 0x66,
1040                         0x6f, 0x6e, 0x74, 0x04, 0x04, 0x04, 0x14, 0x53, 0x79, 0x73, 0x74,
1041                         0x65, 0x6d, 0x2e, 0x44, 0x72, 0x61, 0x77, 0x69, 0x6e, 0x67, 0x2e,
1042                         0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x05, 0x00, 0x00, 0x00, 0x14, 0x53,
1043                         0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72, 0x61, 0x77, 0x69,
1044                         0x6e, 0x67, 0x2e, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x05, 0x00, 0x00,
1045                         0x00, 0x13, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72,
1046                         0x61, 0x77, 0x69, 0x6e, 0x67, 0x2e, 0x46, 0x6f, 0x6e, 0x74, 0x05,
1047                         0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0xfa, 0xff, 0xff,
1048                         0xff, 0x14, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72,
1049                         0x61, 0x77, 0x69, 0x6e, 0x67, 0x2e, 0x43, 0x6f, 0x6c, 0x6f, 0x72,
1050                         0x04, 0x00, 0x00, 0x00, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x0a,
1051                         0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x05,
1052                         0x73, 0x74, 0x61, 0x74, 0x65, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x00,
1053                         0x00, 0x00, 0x01, 0x09, 0x07, 0x07, 0x05, 0x00, 0x00, 0x00, 0x00,
1054                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x01, 0x00,
1055                         0x0a, 0x01, 0xf9, 0xff, 0xff, 0xff, 0xfa, 0xff, 0xff, 0xff, 0x00,
1056                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x00, 0x01, 0x00,
1057                         0x0a, 0x09, 0x08, 0x00, 0x00, 0x00, 0x05, 0x08, 0x00, 0x00, 0x00,
1058                         0x13, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72, 0x61,
1059                         0x77, 0x69, 0x6e, 0x67, 0x2e, 0x46, 0x6f, 0x6e, 0x74, 0x04, 0x00,
1060                         0x00, 0x00, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x04, 0x53, 0x69, 0x7a,
1061                         0x65, 0x05, 0x53, 0x74, 0x79, 0x6c, 0x65, 0x04, 0x55, 0x6e, 0x69,
1062                         0x74, 0x01, 0x00, 0x04, 0x04, 0x0b, 0x18, 0x53, 0x79, 0x73, 0x74,
1063                         0x65, 0x6d, 0x2e, 0x44, 0x72, 0x61, 0x77, 0x69, 0x6e, 0x67, 0x2e,
1064                         0x46, 0x6f, 0x6e, 0x74, 0x53, 0x74, 0x79, 0x6c, 0x65, 0x05, 0x00,
1065                         0x00, 0x00, 0x1b, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44,
1066                         0x72, 0x61, 0x77, 0x69, 0x6e, 0x67, 0x2e, 0x47, 0x72, 0x61, 0x70,
1067                         0x68, 0x69, 0x63, 0x73, 0x55, 0x6e, 0x69, 0x74, 0x05, 0x00, 0x00,
1068                         0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x09, 0x00, 0x00, 0x00, 0x05,
1069                         0x41, 0x72, 0x69, 0x61, 0x6c, 0x00, 0x00, 0x40, 0x41, 0x05, 0xf6,
1070                         0xff, 0xff, 0xff, 0x18, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e,
1071                         0x44, 0x72, 0x61, 0x77, 0x69, 0x6e, 0x67, 0x2e, 0x46, 0x6f, 0x6e,
1072                         0x74, 0x53, 0x74, 0x79, 0x6c, 0x65, 0x01, 0x00, 0x00, 0x00, 0x07,
1073                         0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x5f, 0x00, 0x08, 0x05, 0x00,
1074                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xf5, 0xff, 0xff, 0xff,
1075                         0x1b, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72, 0x61,
1076                         0x77, 0x69, 0x6e, 0x67, 0x2e, 0x47, 0x72, 0x61, 0x70, 0x68, 0x69,
1077                         0x63, 0x73, 0x55, 0x6e, 0x69, 0x74, 0x01, 0x00, 0x00, 0x00, 0x07,
1078                         0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x5f, 0x00, 0x08, 0x05, 0x00,
1079                         0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0b };
1080
1081                 static byte [] _serializedV20_MS = {
1082                         0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00,
1083                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x02, 0x00, 0x00, 0x00,
1084                         0x57, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x57, 0x69, 0x6e,
1085                         0x64, 0x6f, 0x77, 0x73, 0x2e, 0x46, 0x6f, 0x72, 0x6d, 0x73, 0x2c,
1086                         0x20, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x32, 0x2e,
1087                         0x30, 0x2e, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x43, 0x75, 0x6c, 0x74,
1088                         0x75, 0x72, 0x65, 0x3d, 0x6e, 0x65, 0x75, 0x74, 0x72, 0x61, 0x6c,
1089                         0x2c, 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79,
1090                         0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x3d, 0x62, 0x37, 0x37, 0x61, 0x35,
1091                         0x63, 0x35, 0x36, 0x31, 0x39, 0x33, 0x34, 0x65, 0x30, 0x38, 0x39,
1092                         0x05, 0x01, 0x00, 0x00, 0x00, 0x31, 0x53, 0x79, 0x73, 0x74, 0x65,
1093                         0x6d, 0x2e, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x2e, 0x46,
1094                         0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x69,
1095                         0x65, 0x77, 0x49, 0x74, 0x65, 0x6d, 0x2b, 0x4c, 0x69, 0x73, 0x74,
1096                         0x56, 0x69, 0x65, 0x77, 0x53, 0x75, 0x62, 0x49, 0x74, 0x65, 0x6d,
1097                         0x04, 0x00, 0x00, 0x00, 0x04, 0x74, 0x65, 0x78, 0x74, 0x04, 0x6e,
1098                         0x61, 0x6d, 0x65, 0x05, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x08, 0x75,
1099                         0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x01, 0x01, 0x04, 0x02,
1100                         0x3e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x57, 0x69, 0x6e,
1101                         0x64, 0x6f, 0x77, 0x73, 0x2e, 0x46, 0x6f, 0x72, 0x6d, 0x73, 0x2e,
1102                         0x4c, 0x69, 0x73, 0x74, 0x56, 0x69, 0x65, 0x77, 0x49, 0x74, 0x65,
1103                         0x6d, 0x2b, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x69, 0x65, 0x77, 0x53,
1104                         0x75, 0x62, 0x49, 0x74, 0x65, 0x6d, 0x2b, 0x53, 0x75, 0x62, 0x49,
1105                         0x74, 0x65, 0x6d, 0x53, 0x74, 0x79, 0x6c, 0x65, 0x02, 0x00, 0x00,
1106                         0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x00, 0x0b,
1107                         0x53, 0x75, 0x62, 0x49, 0x74, 0x65, 0x6d, 0x54, 0x65, 0x78, 0x74,
1108                         0x06, 0x04, 0x00, 0x00, 0x00, 0x03, 0x66, 0x6f, 0x6f, 0x09, 0x05,
1109                         0x00, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x00, 0x03, 0x62, 0x61,
1110                         0x72, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x51, 0x53, 0x79, 0x73, 0x74,
1111                         0x65, 0x6d, 0x2e, 0x44, 0x72, 0x61, 0x77, 0x69, 0x6e, 0x67, 0x2c,
1112                         0x20, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x32, 0x2e,
1113                         0x30, 0x2e, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x43, 0x75, 0x6c, 0x74,
1114                         0x75, 0x72, 0x65, 0x3d, 0x6e, 0x65, 0x75, 0x74, 0x72, 0x61, 0x6c,
1115                         0x2c, 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79,
1116                         0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x3d, 0x62, 0x30, 0x33, 0x66, 0x35,
1117                         0x66, 0x37, 0x66, 0x31, 0x31, 0x64, 0x35, 0x30, 0x61, 0x33, 0x61,
1118                         0x05, 0x05, 0x00, 0x00, 0x00, 0x3e, 0x53, 0x79, 0x73, 0x74, 0x65,
1119                         0x6d, 0x2e, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x2e, 0x46,
1120                         0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x69,
1121                         0x65, 0x77, 0x49, 0x74, 0x65, 0x6d, 0x2b, 0x4c, 0x69, 0x73, 0x74,
1122                         0x56, 0x69, 0x65, 0x77, 0x53, 0x75, 0x62, 0x49, 0x74, 0x65, 0x6d,
1123                         0x2b, 0x53, 0x75, 0x62, 0x49, 0x74, 0x65, 0x6d, 0x53, 0x74, 0x79,
1124                         0x6c, 0x65, 0x03, 0x00, 0x00, 0x00, 0x09, 0x62, 0x61, 0x63, 0x6b,
1125                         0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x09, 0x66, 0x6f, 0x72, 0x65, 0x43,
1126                         0x6f, 0x6c, 0x6f, 0x72, 0x04, 0x66, 0x6f, 0x6e, 0x74, 0x04, 0x04,
1127                         0x04, 0x14, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72,
1128                         0x61, 0x77, 0x69, 0x6e, 0x67, 0x2e, 0x43, 0x6f, 0x6c, 0x6f, 0x72,
1129                         0x07, 0x00, 0x00, 0x00, 0x14, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d,
1130                         0x2e, 0x44, 0x72, 0x61, 0x77, 0x69, 0x6e, 0x67, 0x2e, 0x43, 0x6f,
1131                         0x6c, 0x6f, 0x72, 0x07, 0x00, 0x00, 0x00, 0x13, 0x53, 0x79, 0x73,
1132                         0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72, 0x61, 0x77, 0x69, 0x6e, 0x67,
1133                         0x2e, 0x46, 0x6f, 0x6e, 0x74, 0x07, 0x00, 0x00, 0x00, 0x02, 0x00,
1134                         0x00, 0x00, 0x05, 0xf8, 0xff, 0xff, 0xff, 0x14, 0x53, 0x79, 0x73,
1135                         0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72, 0x61, 0x77, 0x69, 0x6e, 0x67,
1136                         0x2e, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x04, 0x00, 0x00, 0x00, 0x04,
1137                         0x6e, 0x61, 0x6d, 0x65, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x0a,
1138                         0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x05,
1139                         0x73, 0x74, 0x61, 0x74, 0x65, 0x01, 0x00, 0x00, 0x00, 0x09, 0x07,
1140                         0x07, 0x07, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00,
1141                         0x00, 0x00, 0x00, 0x4f, 0x00, 0x01, 0x00, 0x01, 0xf7, 0xff, 0xff,
1142                         0xff, 0xf8, 0xff, 0xff, 0xff, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00,
1143                         0x00, 0x00, 0x00, 0xa6, 0x00, 0x01, 0x00, 0x09, 0x0a, 0x00, 0x00,
1144                         0x00, 0x05, 0x0a, 0x00, 0x00, 0x00, 0x13, 0x53, 0x79, 0x73, 0x74,
1145                         0x65, 0x6d, 0x2e, 0x44, 0x72, 0x61, 0x77, 0x69, 0x6e, 0x67, 0x2e,
1146                         0x46, 0x6f, 0x6e, 0x74, 0x04, 0x00, 0x00, 0x00, 0x04, 0x4e, 0x61,
1147                         0x6d, 0x65, 0x04, 0x53, 0x69, 0x7a, 0x65, 0x05, 0x53, 0x74, 0x79,
1148                         0x6c, 0x65, 0x04, 0x55, 0x6e, 0x69, 0x74, 0x01, 0x00, 0x04, 0x04,
1149                         0x0b, 0x18, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72,
1150                         0x61, 0x77, 0x69, 0x6e, 0x67, 0x2e, 0x46, 0x6f, 0x6e, 0x74, 0x53,
1151                         0x74, 0x79, 0x6c, 0x65, 0x07, 0x00, 0x00, 0x00, 0x1b, 0x53, 0x79,
1152                         0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72, 0x61, 0x77, 0x69, 0x6e,
1153                         0x67, 0x2e, 0x47, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x55,
1154                         0x6e, 0x69, 0x74, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
1155                         0x06, 0x0b, 0x00, 0x00, 0x00, 0x05, 0x41, 0x72, 0x69, 0x61, 0x6c,
1156                         0x00, 0x00, 0x40, 0x41, 0x05, 0xf4, 0xff, 0xff, 0xff, 0x18, 0x53,
1157                         0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72, 0x61, 0x77, 0x69,
1158                         0x6e, 0x67, 0x2e, 0x46, 0x6f, 0x6e, 0x74, 0x53, 0x74, 0x79, 0x6c,
1159                         0x65, 0x01, 0x00, 0x00, 0x00, 0x07, 0x76, 0x61, 0x6c, 0x75, 0x65,
1160                         0x5f, 0x5f, 0x00, 0x08, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1161                         0x00, 0x05, 0xf3, 0xff, 0xff, 0xff, 0x1b, 0x53, 0x79, 0x73, 0x74,
1162                         0x65, 0x6d, 0x2e, 0x44, 0x72, 0x61, 0x77, 0x69, 0x6e, 0x67, 0x2e,
1163                         0x47, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x55, 0x6e, 0x69,
1164                         0x74, 0x01, 0x00, 0x00, 0x00, 0x07, 0x76, 0x61, 0x6c, 0x75, 0x65,
1165                         0x5f, 0x5f, 0x00, 0x08, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
1166                         0x00, 0x0b };
1167
1168                 static byte [] _serializedV11_Mono = {
1169                         0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00,
1170                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x02, 0x00, 0x00, 0x00,
1171                         0x5a, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x57, 0x69, 0x6e,
1172                         0x64, 0x6f, 0x77, 0x73, 0x2e, 0x46, 0x6f, 0x72, 0x6d, 0x73, 0x2c,
1173                         0x20, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x31, 0x2e,
1174                         0x30, 0x2e, 0x35, 0x30, 0x30, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x43,
1175                         0x75, 0x6c, 0x74, 0x75, 0x72, 0x65, 0x3d, 0x6e, 0x65, 0x75, 0x74,
1176                         0x72, 0x61, 0x6c, 0x2c, 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63,
1177                         0x4b, 0x65, 0x79, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x3d, 0x62, 0x37,
1178                         0x37, 0x61, 0x35, 0x63, 0x35, 0x36, 0x31, 0x39, 0x33, 0x34, 0x65,
1179                         0x30, 0x38, 0x39, 0x05, 0x01, 0x00, 0x00, 0x00, 0x31, 0x53, 0x79,
1180                         0x73, 0x74, 0x65, 0x6d, 0x2e, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77,
1181                         0x73, 0x2e, 0x46, 0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x4c, 0x69, 0x73,
1182                         0x74, 0x56, 0x69, 0x65, 0x77, 0x49, 0x74, 0x65, 0x6d, 0x2b, 0x4c,
1183                         0x69, 0x73, 0x74, 0x56, 0x69, 0x65, 0x77, 0x53, 0x75, 0x62, 0x49,
1184                         0x74, 0x65, 0x6d, 0x02, 0x00, 0x00, 0x00, 0x04, 0x74, 0x65, 0x78,
1185                         0x74, 0x05, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x01, 0x04, 0x3e, 0x53,
1186                         0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x57, 0x69, 0x6e, 0x64, 0x6f,
1187                         0x77, 0x73, 0x2e, 0x46, 0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x4c, 0x69,
1188                         0x73, 0x74, 0x56, 0x69, 0x65, 0x77, 0x49, 0x74, 0x65, 0x6d, 0x2b,
1189                         0x4c, 0x69, 0x73, 0x74, 0x56, 0x69, 0x65, 0x77, 0x53, 0x75, 0x62,
1190                         0x49, 0x74, 0x65, 0x6d, 0x2b, 0x53, 0x75, 0x62, 0x49, 0x74, 0x65,
1191                         0x6d, 0x53, 0x74, 0x79, 0x6c, 0x65, 0x02, 0x00, 0x00, 0x00, 0x02,
1192                         0x00, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x00, 0x0b, 0x53, 0x75,
1193                         0x62, 0x49, 0x74, 0x65, 0x6d, 0x54, 0x65, 0x78, 0x74, 0x09, 0x04,
1194                         0x00, 0x00, 0x00, 0x0c, 0x05, 0x00, 0x00, 0x00, 0x54, 0x53, 0x79,
1195                         0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72, 0x61, 0x77, 0x69, 0x6e,
1196                         0x67, 0x2c, 0x20, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3d,
1197                         0x31, 0x2e, 0x30, 0x2e, 0x35, 0x30, 0x30, 0x30, 0x2e, 0x30, 0x2c,
1198                         0x20, 0x43, 0x75, 0x6c, 0x74, 0x75, 0x72, 0x65, 0x3d, 0x6e, 0x65,
1199                         0x75, 0x74, 0x72, 0x61, 0x6c, 0x2c, 0x20, 0x50, 0x75, 0x62, 0x6c,
1200                         0x69, 0x63, 0x4b, 0x65, 0x79, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x3d,
1201                         0x62, 0x30, 0x33, 0x66, 0x35, 0x66, 0x37, 0x66, 0x31, 0x31, 0x64,
1202                         0x35, 0x30, 0x61, 0x33, 0x61, 0x05, 0x04, 0x00, 0x00, 0x00, 0x3e,
1203                         0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x57, 0x69, 0x6e, 0x64,
1204                         0x6f, 0x77, 0x73, 0x2e, 0x46, 0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x4c,
1205                         0x69, 0x73, 0x74, 0x56, 0x69, 0x65, 0x77, 0x49, 0x74, 0x65, 0x6d,
1206                         0x2b, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x69, 0x65, 0x77, 0x53, 0x75,
1207                         0x62, 0x49, 0x74, 0x65, 0x6d, 0x2b, 0x53, 0x75, 0x62, 0x49, 0x74,
1208                         0x65, 0x6d, 0x53, 0x74, 0x79, 0x6c, 0x65, 0x03, 0x00, 0x00, 0x00,
1209                         0x09, 0x62, 0x61, 0x63, 0x6b, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x09,
1210                         0x66, 0x6f, 0x72, 0x65, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x04, 0x66,
1211                         0x6f, 0x6e, 0x74, 0x04, 0x04, 0x04, 0x14, 0x53, 0x79, 0x73, 0x74,
1212                         0x65, 0x6d, 0x2e, 0x44, 0x72, 0x61, 0x77, 0x69, 0x6e, 0x67, 0x2e,
1213                         0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x05, 0x00, 0x00, 0x00, 0x14, 0x53,
1214                         0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72, 0x61, 0x77, 0x69,
1215                         0x6e, 0x67, 0x2e, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x05, 0x00, 0x00,
1216                         0x00, 0x13, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72,
1217                         0x61, 0x77, 0x69, 0x6e, 0x67, 0x2e, 0x46, 0x6f, 0x6e, 0x74, 0x05,
1218                         0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x06, 0x00, 0x00,
1219                         0x00, 0x14, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72,
1220                         0x61, 0x77, 0x69, 0x6e, 0x67, 0x2e, 0x43, 0x6f, 0x6c, 0x6f, 0x72,
1221                         0x04, 0x00, 0x00, 0x00, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x05,
1222                         0x73, 0x74, 0x61, 0x74, 0x65, 0x0a, 0x6b, 0x6e, 0x6f, 0x77, 0x6e,
1223                         0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x00,
1224                         0x00, 0x00, 0x01, 0x09, 0x07, 0x07, 0x05, 0x00, 0x00, 0x00, 0x00,
1225                         0x80, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x4f, 0x00,
1226                         0x06, 0x07, 0x00, 0x00, 0x00, 0x05, 0x47, 0x72, 0x65, 0x65, 0x6e,
1227                         0x01, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0xff,
1228                         0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0xa6, 0x00, 0x06,
1229                         0x09, 0x00, 0x00, 0x00, 0x06, 0x59, 0x65, 0x6c, 0x6c, 0x6f, 0x77,
1230                         0x09, 0x0a, 0x00, 0x00, 0x00, 0x05, 0x0a, 0x00, 0x00, 0x00, 0x13,
1231                         0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72, 0x61, 0x77,
1232                         0x69, 0x6e, 0x67, 0x2e, 0x46, 0x6f, 0x6e, 0x74, 0x04, 0x00, 0x00,
1233                         0x00, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x04, 0x53, 0x69, 0x7a, 0x65,
1234                         0x05, 0x53, 0x74, 0x79, 0x6c, 0x65, 0x04, 0x55, 0x6e, 0x69, 0x74,
1235                         0x01, 0x00, 0x04, 0x04, 0x0b, 0x18, 0x53, 0x79, 0x73, 0x74, 0x65,
1236                         0x6d, 0x2e, 0x44, 0x72, 0x61, 0x77, 0x69, 0x6e, 0x67, 0x2e, 0x46,
1237                         0x6f, 0x6e, 0x74, 0x53, 0x74, 0x79, 0x6c, 0x65, 0x05, 0x00, 0x00,
1238                         0x00, 0x1b, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72,
1239                         0x61, 0x77, 0x69, 0x6e, 0x67, 0x2e, 0x47, 0x72, 0x61, 0x70, 0x68,
1240                         0x69, 0x63, 0x73, 0x55, 0x6e, 0x69, 0x74, 0x05, 0x00, 0x00, 0x00,
1241                         0x05, 0x00, 0x00, 0x00, 0x06, 0x0b, 0x00, 0x00, 0x00, 0x05, 0x41,
1242                         0x72, 0x69, 0x61, 0x6c, 0x00, 0x00, 0x40, 0x41, 0x05, 0x0c, 0x00,
1243                         0x00, 0x00, 0x18, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44,
1244                         0x72, 0x61, 0x77, 0x69, 0x6e, 0x67, 0x2e, 0x46, 0x6f, 0x6e, 0x74,
1245                         0x53, 0x74, 0x79, 0x6c, 0x65, 0x01, 0x00, 0x00, 0x00, 0x07, 0x76,
1246                         0x61, 0x6c, 0x75, 0x65, 0x5f, 0x5f, 0x00, 0x08, 0x05, 0x00, 0x00,
1247                         0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0d, 0x00, 0x00, 0x00, 0x1b,
1248                         0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72, 0x61, 0x77,
1249                         0x69, 0x6e, 0x67, 0x2e, 0x47, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63,
1250                         0x73, 0x55, 0x6e, 0x69, 0x74, 0x01, 0x00, 0x00, 0x00, 0x07, 0x76,
1251                         0x61, 0x6c, 0x75, 0x65, 0x5f, 0x5f, 0x00, 0x08, 0x05, 0x00, 0x00,
1252                         0x00, 0x03, 0x00, 0x00, 0x00, 0x0b };
1253
1254                 static byte [] _serializedV20_Mono = {
1255                         0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 
1256                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x02, 0x00, 0x00, 0x00, 
1257                         0x57, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x57, 0x69, 0x6e, 
1258                         0x64, 0x6f, 0x77, 0x73, 0x2e, 0x46, 0x6f, 0x72, 0x6d, 0x73, 0x2c, 
1259                         0x20, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x32, 0x2e, 
1260                         0x30, 0x2e, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x43, 0x75, 0x6c, 0x74, 
1261                         0x75, 0x72, 0x65, 0x3d, 0x6e, 0x65, 0x75, 0x74, 0x72, 0x61, 0x6c, 
1262                         0x2c, 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 
1263                         0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x3d, 0x62, 0x37, 0x37, 0x61, 0x35, 
1264                         0x63, 0x35, 0x36, 0x31, 0x39, 0x33, 0x34, 0x65, 0x30, 0x38, 0x39, 
1265                         0x05, 0x01, 0x00, 0x00, 0x00, 0x31, 0x53, 0x79, 0x73, 0x74, 0x65, 
1266                         0x6d, 0x2e, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x2e, 0x46, 
1267                         0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x69, 
1268                         0x65, 0x77, 0x49, 0x74, 0x65, 0x6d, 0x2b, 0x4c, 0x69, 0x73, 0x74, 
1269                         0x56, 0x69, 0x65, 0x77, 0x53, 0x75, 0x62, 0x49, 0x74, 0x65, 0x6d, 
1270                         0x04, 0x00, 0x00, 0x00, 0x04, 0x74, 0x65, 0x78, 0x74, 0x04, 0x6e, 
1271                         0x61, 0x6d, 0x65, 0x08, 0x75, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 
1272                         0x61, 0x05, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x01, 0x01, 0x02, 0x04, 
1273                         0x3e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x57, 0x69, 0x6e, 
1274                         0x64, 0x6f, 0x77, 0x73, 0x2e, 0x46, 0x6f, 0x72, 0x6d, 0x73, 0x2e, 
1275                         0x4c, 0x69, 0x73, 0x74, 0x56, 0x69, 0x65, 0x77, 0x49, 0x74, 0x65, 
1276                         0x6d, 0x2b, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x69, 0x65, 0x77, 0x53, 
1277                         0x75, 0x62, 0x49, 0x74, 0x65, 0x6d, 0x2b, 0x53, 0x75, 0x62, 0x49, 
1278                         0x74, 0x65, 0x6d, 0x53, 0x74, 0x79, 0x6c, 0x65, 0x02, 0x00, 0x00, 
1279                         0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x00, 0x0b, 
1280                         0x53, 0x75, 0x62, 0x49, 0x74, 0x65, 0x6d, 0x54, 0x65, 0x78, 0x74, 
1281                         0x06, 0x04, 0x00, 0x00, 0x00, 0x03, 0x66, 0x6f, 0x6f, 0x06, 0x05, 
1282                         0x00, 0x00, 0x00, 0x03, 0x62, 0x61, 0x72, 0x09, 0x06, 0x00, 0x00, 
1283                         0x00, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x51, 0x53, 0x79, 0x73, 0x74, 
1284                         0x65, 0x6d, 0x2e, 0x44, 0x72, 0x61, 0x77, 0x69, 0x6e, 0x67, 0x2c, 
1285                         0x20, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x32, 0x2e, 
1286                         0x30, 0x2e, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x43, 0x75, 0x6c, 0x74, 
1287                         0x75, 0x72, 0x65, 0x3d, 0x6e, 0x65, 0x75, 0x74, 0x72, 0x61, 0x6c, 
1288                         0x2c, 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 
1289                         0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x3d, 0x62, 0x30, 0x33, 0x66, 0x35, 
1290                         0x66, 0x37, 0x66, 0x31, 0x31, 0x64, 0x35, 0x30, 0x61, 0x33, 0x61, 
1291                         0x05, 0x06, 0x00, 0x00, 0x00, 0x3e, 0x53, 0x79, 0x73, 0x74, 0x65, 
1292                         0x6d, 0x2e, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x2e, 0x46, 
1293                         0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x69, 
1294                         0x65, 0x77, 0x49, 0x74, 0x65, 0x6d, 0x2b, 0x4c, 0x69, 0x73, 0x74, 
1295                         0x56, 0x69, 0x65, 0x77, 0x53, 0x75, 0x62, 0x49, 0x74, 0x65, 0x6d, 
1296                         0x2b, 0x53, 0x75, 0x62, 0x49, 0x74, 0x65, 0x6d, 0x53, 0x74, 0x79, 
1297                         0x6c, 0x65, 0x03, 0x00, 0x00, 0x00, 0x09, 0x62, 0x61, 0x63, 0x6b, 
1298                         0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x09, 0x66, 0x6f, 0x72, 0x65, 0x43, 
1299                         0x6f, 0x6c, 0x6f, 0x72, 0x04, 0x66, 0x6f, 0x6e, 0x74, 0x04, 0x04, 
1300                         0x04, 0x14, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72, 
1301                         0x61, 0x77, 0x69, 0x6e, 0x67, 0x2e, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 
1302                         0x07, 0x00, 0x00, 0x00, 0x14, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 
1303                         0x2e, 0x44, 0x72, 0x61, 0x77, 0x69, 0x6e, 0x67, 0x2e, 0x43, 0x6f, 
1304                         0x6c, 0x6f, 0x72, 0x07, 0x00, 0x00, 0x00, 0x13, 0x53, 0x79, 0x73, 
1305                         0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72, 0x61, 0x77, 0x69, 0x6e, 0x67, 
1306                         0x2e, 0x46, 0x6f, 0x6e, 0x74, 0x07, 0x00, 0x00, 0x00, 0x02, 0x00, 
1307                         0x00, 0x00, 0x05, 0x08, 0x00, 0x00, 0x00, 0x14, 0x53, 0x79, 0x73, 
1308                         0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72, 0x61, 0x77, 0x69, 0x6e, 0x67, 
1309                         0x2e, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x04, 0x00, 0x00, 0x00, 0x05, 
1310                         0x76, 0x61, 0x6c, 0x75, 0x65, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 
1311                         0x0a, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 
1312                         0x04, 0x6e, 0x61, 0x6d, 0x65, 0x00, 0x00, 0x00, 0x01, 0x09, 0x07, 
1313                         0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0xff, 0x00, 0x00, 
1314                         0x00, 0x00, 0x07, 0x00, 0x4f, 0x00, 0x06, 0x09, 0x00, 0x00, 0x00, 
1315                         0x05, 0x47, 0x72, 0x65, 0x65, 0x6e, 0x01, 0x0a, 0x00, 0x00, 0x00, 
1316                         0x08, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 
1317                         0x00, 0x07, 0x00, 0xa6, 0x00, 0x06, 0x0b, 0x00, 0x00, 0x00, 0x06, 
1318                         0x59, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x09, 0x0c, 0x00, 0x00, 0x00, 
1319                         0x05, 0x0c, 0x00, 0x00, 0x00, 0x13, 0x53, 0x79, 0x73, 0x74, 0x65, 
1320                         0x6d, 0x2e, 0x44, 0x72, 0x61, 0x77, 0x69, 0x6e, 0x67, 0x2e, 0x46, 
1321                         0x6f, 0x6e, 0x74, 0x04, 0x00, 0x00, 0x00, 0x04, 0x4e, 0x61, 0x6d, 
1322                         0x65, 0x04, 0x53, 0x69, 0x7a, 0x65, 0x05, 0x53, 0x74, 0x79, 0x6c, 
1323                         0x65, 0x04, 0x55, 0x6e, 0x69, 0x74, 0x01, 0x00, 0x04, 0x04, 0x0b, 
1324                         0x18, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72, 0x61, 
1325                         0x77, 0x69, 0x6e, 0x67, 0x2e, 0x46, 0x6f, 0x6e, 0x74, 0x53, 0x74, 
1326                         0x79, 0x6c, 0x65, 0x07, 0x00, 0x00, 0x00, 0x1b, 0x53, 0x79, 0x73, 
1327                         0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72, 0x61, 0x77, 0x69, 0x6e, 0x67, 
1328                         0x2e, 0x47, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x55, 0x6e, 
1329                         0x69, 0x74, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 
1330                         0x0d, 0x00, 0x00, 0x00, 0x05, 0x41, 0x72, 0x69, 0x61, 0x6c, 0x00, 
1331                         0x00, 0x40, 0x41, 0x05, 0x0e, 0x00, 0x00, 0x00, 0x18, 0x53, 0x79, 
1332                         0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x72, 0x61, 0x77, 0x69, 0x6e, 
1333                         0x67, 0x2e, 0x46, 0x6f, 0x6e, 0x74, 0x53, 0x74, 0x79, 0x6c, 0x65, 
1334                         0x01, 0x00, 0x00, 0x00, 0x07, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 
1335                         0x5f, 0x00, 0x08, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
1336                         0x05, 0x0f, 0x00, 0x00, 0x00, 0x1b, 0x53, 0x79, 0x73, 0x74, 0x65, 
1337                         0x6d, 0x2e, 0x44, 0x72, 0x61, 0x77, 0x69, 0x6e, 0x67, 0x2e, 0x47, 
1338                         0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x55, 0x6e, 0x69, 0x74, 
1339                         0x01, 0x00, 0x00, 0x00, 0x07, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 
1340                         0x5f, 0x00, 0x08, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 
1341                         0x0b };
1342         }
1343
1344         [TestFixture]
1345         public class ListViewSubItemCollectionTest : TestHelper
1346         {
1347                 [Test]
1348                 public void Ctor ()
1349                 {
1350                         ListViewItem item = new ListViewItem ();
1351                         item.Text = "MAIN";
1352
1353                         ListViewItem.ListViewSubItemCollection sub_items;
1354                         sub_items = new ListViewItem.ListViewSubItemCollection (item);
1355
1356                         Assert.AreEqual (1, sub_items.Count, "#A1");
1357                         Assert.AreEqual ("MAIN", sub_items [0].Text, "#A2");
1358
1359                         sub_items.Add ("A");
1360
1361                         Assert.AreEqual (2, sub_items.Count, "#B1");
1362                         Assert.AreEqual ("A", sub_items [1].Text, "#B2");
1363                 }
1364
1365                 [Test]
1366                 public void AddRange1 ()
1367                 {
1368                         ListViewItem item = new ListViewItem ();
1369                         ListViewItem.ListViewSubItem subItemA = item.SubItems.Add ("A");
1370
1371                         Assert.AreEqual (2, item.SubItems.Count, "#A1");
1372                         Assert.IsNotNull (item.SubItems [0], "#A2");
1373                         Assert.AreEqual (string.Empty, item.SubItems [0].Text, "#A3");
1374
1375                         ListViewItem.ListViewSubItem subItemB = new ListViewItem.ListViewSubItem ();
1376                         subItemB.Text = "B";
1377                         ListViewItem.ListViewSubItem subItemC = new ListViewItem.ListViewSubItem ();
1378                         subItemB.Text = "C";
1379
1380                         item.SubItems.AddRange (new ListViewItem.ListViewSubItem [] {
1381                                 subItemB, null, subItemC });
1382                         Assert.AreEqual (4, item.SubItems.Count, "#B1");
1383                         Assert.IsNotNull (item.SubItems [0], "#B2");
1384                         Assert.AreEqual (string.Empty, item.SubItems [0].Text, "#B3");
1385                         Assert.IsNotNull (item.SubItems [1], "#B3");
1386                         Assert.AreSame (subItemA, item.SubItems [1], "#B4");
1387                         Assert.IsNotNull (item.SubItems [2], "#B5");
1388                         Assert.AreSame (subItemB, item.SubItems [2], "#B6");
1389                         Assert.IsNotNull (item.SubItems [3], "#B7");
1390                         Assert.AreSame (subItemC, item.SubItems [3], "#B8");
1391                 }
1392
1393                 [Test]
1394                 public void AddRange1_Null ()
1395                 {
1396                         ListViewItem item = new ListViewItem ();
1397                         try {
1398                                 item.SubItems.AddRange ((ListViewItem.ListViewSubItem []) null);
1399                                 Assert.Fail ("#1");
1400                         } catch (ArgumentNullException ex) {
1401                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1402                                 Assert.IsNotNull (ex.Message, "#3");
1403                                 Assert.IsNotNull (ex.ParamName, "#4");
1404                                 Assert.AreEqual ("items", ex.ParamName, "#5");
1405                                 Assert.IsNull (ex.InnerException, "#6");
1406                         }
1407                 }
1408
1409                 [Test]
1410                 public void AddRange2 ()
1411                 {
1412                         string subItemAText = "A";
1413                         string subItemBText = "B";
1414                         string subItemCText = "B";
1415
1416                         ListViewItem item = new ListViewItem ();
1417                         item.SubItems.Add (subItemAText);
1418
1419                         Assert.AreEqual (2, item.SubItems.Count, "#A1");
1420                         Assert.IsNotNull (item.SubItems [0], "#A2");
1421                         Assert.AreEqual (string.Empty, item.SubItems [0].Text, "#A3");
1422                         Assert.IsNotNull (item.SubItems [1], "#A4");
1423                         Assert.AreEqual (subItemAText, item.SubItems [1].Text, "#A5");
1424
1425                         item.SubItems.AddRange (new string [] { subItemBText, null, subItemCText });
1426                         Assert.AreEqual (4, item.SubItems.Count, "#B1");
1427                         Assert.IsNotNull (item.SubItems [0], "#B2");
1428                         Assert.AreEqual (string.Empty, item.SubItems [0].Text, "#B3");
1429                         Assert.IsNotNull (item.SubItems [1], "#B4");
1430                         Assert.AreSame (subItemAText, item.SubItems [1].Text, "#B5");
1431                         Assert.IsNotNull (item.SubItems [2], "#B6");
1432                         Assert.AreSame (subItemBText, item.SubItems [2].Text, "#B7");
1433                         Assert.IsNotNull (item.SubItems [3], "#B8");
1434                         Assert.AreSame (subItemCText, item.SubItems [3].Text, "#B9");
1435                 }
1436
1437                 [Test]
1438                 public void AddRange2_Null ()
1439                 {
1440                         ListViewItem item = new ListViewItem ();
1441                         try {
1442                                 item.SubItems.AddRange ((string []) null);
1443                                 Assert.Fail ("#1");
1444                         } catch (ArgumentNullException ex) {
1445                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1446                                 Assert.IsNotNull (ex.Message, "#3");
1447                                 Assert.IsNotNull (ex.ParamName, "#4");
1448                                 Assert.AreEqual ("items", ex.ParamName, "#5");
1449                                 Assert.IsNull (ex.InnerException, "#6");
1450                         }
1451                 }
1452
1453                 [Test]
1454                 public void AddRange3 ()
1455                 {
1456                         string subItemAText = "A";
1457                         string subItemBText = "B";
1458                         string subItemCText = "B";
1459                         Font font = new Font ("Arial", 14);
1460
1461                         ListViewItem item = new ListViewItem ();
1462                         item.SubItems.Add (subItemAText);
1463
1464                         Assert.AreEqual (2, item.SubItems.Count, "#A1");
1465                         Assert.IsNotNull (item.SubItems [0], "#A2");
1466                         Assert.AreEqual (string.Empty, item.SubItems [0].Text, "#A3");
1467                         Assert.IsNotNull (item.SubItems [1], "#A4");
1468                         Assert.AreEqual (subItemAText, item.SubItems [1].Text, "#A5");
1469
1470                         item.SubItems.AddRange (new string [] { subItemBText, null, subItemCText },
1471                                 Color.Blue, Color.Red, font);
1472                         Assert.AreEqual (4, item.SubItems.Count, "#B1");
1473                         Assert.IsNotNull (item.SubItems [0], "#B2");
1474                         Assert.AreEqual (string.Empty, item.SubItems [0].Text, "#B3");
1475                         Assert.IsNotNull (item.SubItems [1], "#C1");
1476                         Assert.AreSame (subItemAText, item.SubItems [1].Text, "#C2");
1477                         Assert.IsNotNull (item.SubItems [2], "#D1");
1478                         Assert.AreSame (subItemBText, item.SubItems [2].Text, "#D2");
1479                         Assert.AreEqual (Color.Blue, item.SubItems [2].ForeColor, "#D3");
1480                         Assert.AreEqual (Color.Red, item.SubItems [2].BackColor, "#D4");
1481                         Assert.AreSame (font, item.SubItems [2].Font, "#D5");
1482                         Assert.IsNotNull (item.SubItems [3], "#E1");
1483                         Assert.AreSame (subItemCText, item.SubItems [3].Text, "#E2");
1484                         Assert.AreEqual (Color.Blue, item.SubItems [3].ForeColor, "#E3");
1485                         Assert.AreEqual (Color.Red, item.SubItems [3].BackColor, "#E4");
1486                         Assert.AreSame (font, item.SubItems [3].Font, "#E6");
1487                 }
1488
1489                 [Test]
1490                 public void AddRange3_Items_Null ()
1491                 {
1492                         ListViewItem item = new ListViewItem ();
1493                         try {
1494                                 item.SubItems.AddRange ((string []) null, Color.Blue, Color.Red,
1495                                         new Font ("Arial", 14));
1496                                 Assert.Fail ("#1");
1497                         } catch (ArgumentNullException ex) {
1498                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1499                                 Assert.IsNotNull (ex.Message, "#3");
1500                                 Assert.IsNotNull (ex.ParamName, "#4");
1501                                 Assert.AreEqual ("items", ex.ParamName, "#5");
1502                                 Assert.IsNull (ex.InnerException, "#6");
1503                         }
1504                 }
1505
1506                 [Test]
1507                 public void AddRange4 ()
1508                 {
1509                         ListViewItem item = new ListViewItem ();
1510                         Assert.AreEqual (1, item.SubItems.Count, "#1");
1511
1512                         item.SubItems.AddRange (new string [3]);
1513                         Assert.AreEqual (1, item.SubItems.Count, "#2");
1514
1515                         item.SubItems.AddRange (new ListViewItem.ListViewSubItem [3]);
1516                         Assert.AreEqual (1, item.SubItems.Count, "#3");
1517                 }
1518
1519                 [Test]
1520                 public void Clear ()
1521                 {
1522                         ListViewItem item = new ListViewItem ();
1523                         item.SubItems.AddRange (new string [] { "A", "B", "C" });
1524                         item.SubItems.Clear ();
1525                         Assert.AreEqual (1, item.SubItems.Count, "#1");
1526                         Assert.IsNotNull (item.SubItems [0].Text, "#2");
1527                         Assert.AreEqual (string.Empty, item.SubItems [0].Text, "#3");
1528                 }
1529
1530                 [Test]
1531                 public void RemoveAt ()
1532                 {
1533                         ListViewItem item = new ListViewItem ();
1534                         item.SubItems.AddRange (new string [] { "A", "B" });
1535                         Assert.AreEqual (3, item.SubItems.Count, "#A1");
1536                         Assert.IsNotNull (item.SubItems [0].Text, "#A2");
1537                         Assert.AreEqual (string.Empty, item.SubItems [0].Text, "#A3");
1538                         Assert.IsNotNull (item.SubItems [1].Text, "#A4");
1539                         Assert.AreEqual ("A", item.SubItems [1].Text, "#A5");
1540                         Assert.IsNotNull (item.SubItems [2].Text, "#A6");
1541                         Assert.AreEqual ("B", item.SubItems [2].Text, "#A7");
1542
1543                         item.SubItems.RemoveAt (1);
1544
1545                         Assert.AreEqual (2, item.SubItems.Count, "#B1");
1546                         Assert.IsNotNull (item.SubItems [0].Text, "#B2");
1547                         Assert.AreEqual (string.Empty, item.SubItems [0].Text, "#B3");
1548                         Assert.IsNotNull (item.SubItems [1].Text, "#B4");
1549                         Assert.AreEqual ("B", item.SubItems [1].Text, "#B5");
1550
1551                         item.SubItems.RemoveAt (0);
1552
1553                         Assert.AreEqual (1, item.SubItems.Count, "#C1");
1554                         Assert.IsNotNull (item.SubItems [0].Text, "#C2");
1555                         Assert.AreEqual ("B", item.SubItems [0].Text, "#C3");
1556
1557                         item.SubItems.RemoveAt (0);
1558
1559                         Assert.AreEqual (1, item.SubItems.Count, "#D1");
1560                         Assert.IsNotNull (item.SubItems [0].Text, "#D2");
1561                         Assert.AreEqual (string.Empty, item.SubItems [0].Text, "#D3");
1562                 }
1563         }
1564 }