2006-12-19 Daniel Nauck <dna@mono-project.de>
[mono.git] / mcs / class / Managed.Windows.Forms / Test / System.Windows.Forms / DataGridTest.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.Collections;
29 using System.ComponentModel;
30 using System.Drawing;
31 using System.Windows.Forms;
32 using System.Xml;
33 using NUnit.Framework;
34 using System.Data;
35
36 namespace MonoTests.System.Windows.Forms
37 {
38         // Helper classes
39
40         class TestDataGrid : DataGrid 
41         {
42                 public TestDataGrid () 
43                 {
44
45                 }
46
47                 public CurrencyManager Manager {
48                         get {
49                                 return ListManager;
50                         }
51                 }       
52         }
53
54         [TestFixture]
55         public class DataGridTest
56         {
57                 private bool eventhandled;
58
59                 [TearDown]
60                 public void Clean() {}
61
62                 [SetUp]
63                 public void GetReady ()
64                 {
65                 }
66
67                 [Test]
68                 public void TestDefaultValues ()
69                 {
70                         DataGrid dg = new DataGrid ();
71
72                         Assert.AreEqual (true, dg.AllowNavigation, "AllowNavigation property");
73                         Assert.AreEqual (true, dg.AllowSorting, "AllowSorting property");
74                         Assert.AreEqual (BorderStyle.Fixed3D, dg.BorderStyle, "BorderStyle property");
75                         Assert.AreEqual (string.Empty, dg.CaptionText, "CaptionText property");
76                         Assert.AreEqual (true, dg.CaptionVisible, "CaptionVisible property");
77                         Assert.AreEqual (true, dg.ColumnHeadersVisible, "ColumnHeadersVisible property");
78                         Assert.AreEqual (new DataGridCell (), dg.CurrentCell, "CurrentCell property");
79                         Assert.AreEqual (-1, dg.CurrentRowIndex, "CurrentRowIndex property");
80                         Assert.AreEqual (string.Empty, dg.DataMember, "DataMember property");
81                         Assert.AreEqual (null, dg.DataSource, "DataSource property");
82                         Assert.AreEqual (0, dg.FirstVisibleColumn, "FirstVisibleColumn property");
83                         Assert.AreEqual (false, dg.FlatMode, "FlatMode property");
84                         Assert.AreEqual (DataGridLineStyle.Solid, dg.GridLineStyle, "GridLineStyle property");
85                         Assert.AreEqual (DataGridParentRowsLabelStyle.Both, dg.ParentRowsLabelStyle, "ParentRowsLabelStyle property");
86                         Assert.AreEqual (true, dg.ParentRowsVisible, "ParentRowsVisible property");
87                         Assert.AreEqual (75, dg.PreferredColumnWidth, "PreferredColumnWidth property");
88                         //Assert.AreEqual (16, dg.PreferredRowHeight, "PreferredRowHeight property");
89                         Assert.AreEqual (false, dg.ReadOnly, "ReadOnly property");
90                         Assert.AreEqual (true, dg.RowHeadersVisible, "RowHeadersVisible property");
91                         Assert.AreEqual (35, dg.RowHeaderWidth, "RowHeaderWidth property");
92                         Assert.AreEqual (null, dg.Site, "Site property");
93                         Assert.AreEqual (string.Empty, dg.Text, "Text property");
94                         Assert.AreEqual (0, dg.VisibleColumnCount, "VisibleColumnCount property");
95
96                         // Font
97                         Assert.IsFalse (dg.Font.Bold, "Font Bold");
98 #if NET_2_0
99                         Assert.IsTrue (dg.Font.IsSystemFont, "Font IsSystemFont");
100 #endif
101                         Assert.IsFalse (dg.Font.Italic, "Font Italic");
102                         Assert.IsFalse (dg.Font.Strikeout, "Font Strikeout");
103                         Assert.IsFalse (dg.Font.Underline, "Font Underline");
104                 }
105
106                 [Test]
107                 public void TestAllowNavigationChangedEvent ()
108                 {
109                         DataGrid dg = new DataGrid ();
110                         eventhandled = false;
111                         dg.AllowNavigationChanged += new EventHandler (OnEventHandler);
112                         dg.AllowNavigation = !dg.AllowNavigation;
113                         Assert.AreEqual (true, eventhandled, "A1");
114                 }
115
116                 [Test]
117                 public void TestBackgroundColorChangedEvent ()
118                 {
119                         DataGrid dg = new DataGrid ();
120                         eventhandled = false;
121                         dg.BackgroundColorChanged  += new EventHandler (OnEventHandler);
122                         dg.BackgroundColor = Color.Red;
123                         Assert.AreEqual (true, eventhandled, "A1");
124                 }
125
126                 [Test]
127                 public void TestBorderStyleChangedEvent ()
128                 {
129                         DataGrid dg = new DataGrid ();
130                         eventhandled = false;
131                         dg.BorderStyleChanged  += new EventHandler (OnEventHandler);
132                         dg.BorderStyle = BorderStyle.None;
133                         Assert.AreEqual (true, eventhandled, "A1");
134                 }
135
136                 [Test]
137                 public void TestCaptionVisibleChangedEvent ()
138                 {
139                         DataGrid dg = new DataGrid ();
140                         eventhandled = false;
141                         dg.CaptionVisibleChanged += new EventHandler (OnEventHandler);
142                         dg.CaptionVisible = !dg.CaptionVisible;
143                         Assert.AreEqual (true, eventhandled, "A1");
144                 }
145
146                 [Test]
147                 public void TestFlatModeChangedEvent ()
148                 {
149                         DataGrid dg = new DataGrid ();
150                         eventhandled = false;
151                         dg.FlatModeChanged += new EventHandler (OnEventHandler);
152                         dg.FlatMode = !dg.FlatMode;
153                         Assert.AreEqual (true, eventhandled, "A1");
154                 }
155
156                 [Test]
157                 public void CaptionFont ()
158                 {
159                         DataGrid dg = new DataGrid ();
160
161                         // default values
162                         Assert.IsTrue (dg.CaptionFont.Bold, "#A1");
163                         Assert.AreEqual (dg.CaptionFont.FontFamily, dg.Font.FontFamily, "#A2");
164                         Assert.AreEqual (dg.CaptionFont.Height, dg.Font.Height, "#A3");
165 #if NET_2_0
166                         Assert.AreEqual (dg.CaptionFont.IsSystemFont, dg.Font.IsSystemFont, "#A4");
167 #endif
168                         Assert.AreEqual (dg.CaptionFont.Italic, dg.Font.Italic, "#A5");
169                         Assert.AreEqual (dg.CaptionFont.Name, dg.Font.Name, "#A6");
170                         Assert.AreEqual (dg.CaptionFont.Size, dg.Font.Size, "#A7");
171                         Assert.AreEqual (dg.CaptionFont.SizeInPoints, dg.Font.SizeInPoints, "#A8");
172                         Assert.AreEqual (dg.CaptionFont.Strikeout, dg.Font.Strikeout, "#A9");
173                         Assert.AreEqual (dg.CaptionFont.Underline, dg.Font.Underline, "#A10");
174                         Assert.AreEqual (dg.CaptionFont.Unit, dg.Font.Unit, "#A11");
175
176                         // modifying Font affects CaptionFont, except for FontStyle
177                         dg.Font = new Font (dg.Font.FontFamily, 3, FontStyle.Italic);
178                         Assert.IsTrue (dg.CaptionFont.Bold, "#B1");
179                         Assert.IsFalse (dg.Font.Bold, "#B2");
180                         Assert.IsFalse (dg.CaptionFont.Italic, "#B3");
181                         Assert.IsTrue (dg.Font.Italic, "#B4");
182                         Assert.AreEqual (3, dg.Font.SizeInPoints, "#B5");
183                         Assert.AreEqual (dg.CaptionFont.SizeInPoints, dg.Font.SizeInPoints, "#B6");
184
185                         // explicitly setting CaptionFont removes link between CaptionFont
186                         // and Font
187                         dg.CaptionFont = dg.Font;
188                         Assert.AreSame (dg.CaptionFont, dg.Font, "#C1");
189                         dg.Font = new Font (dg.Font.FontFamily, 7, FontStyle.Bold);
190                         Assert.IsFalse (dg.CaptionFont.Bold, "#C2");
191                         Assert.IsTrue (dg.Font.Bold, "#C3");
192                         Assert.AreEqual (7, dg.Font.SizeInPoints, "#C4");
193                         Assert.AreEqual (3, dg.CaptionFont.SizeInPoints, "#C5");
194                 }
195
196                 [Test]
197                 [NUnit.Framework.Category ("NotWorking")]
198                 public void HeaderFont ()
199                 {
200                         DataGrid dg = new DataGrid ();
201                         dg.Font = new Font (dg.Font, FontStyle.Italic);
202                         Assert.AreSame (dg.HeaderFont, dg.Font, "#1");
203
204                         // explicitly setting HeaderFont removes link between HeaderFont
205                         // and Font
206                         dg.HeaderFont = dg.Font;
207                         Assert.AreSame (dg.HeaderFont, dg.Font, "#2");
208                         dg.Font = new Font (dg.Font, FontStyle.Regular);
209                         Assert.IsTrue (dg.HeaderFont.Italic, "#3");
210                         Assert.IsFalse (dg.Font.Italic, "#4");
211                 }
212
213                 [Test]
214                 public void TestParentRowsLabelStyleChangedEvent ()
215                 {
216                         DataGrid dg = new DataGrid ();
217                         eventhandled = false;
218                         dg.ParentRowsLabelStyleChanged  += new EventHandler (OnEventHandler);
219                         dg.ParentRowsLabelStyle = DataGridParentRowsLabelStyle.None;
220                         Assert.AreEqual (true, eventhandled, "A1");
221                 }
222
223                 [Test]
224                 public void TestParentRowsVisibleChangedEvent ()
225                 {
226                         DataGrid dg = new DataGrid ();
227                         eventhandled = false;
228                         dg.ParentRowsVisibleChanged  += new EventHandler (OnEventHandler);
229                         dg.ParentRowsVisible = !dg.ParentRowsVisible;
230                         Assert.AreEqual (true, eventhandled, "A1");
231                 }
232                 
233                 [Test]
234                 public void TestReadOnlyChangedEvent ()
235                 {
236                         DataGrid dg = new DataGrid ();
237                         eventhandled = false;
238                         dg.ReadOnlyChanged  += new EventHandler (OnEventHandler);
239                         dg.ReadOnly = !dg.ReadOnly;
240                         Assert.AreEqual (true, eventhandled, "A1");
241                 }
242
243                 public void OnEventHandler (object sender, EventArgs e)
244                 {
245                         eventhandled = true;
246                 }
247
248                 // Property exceptions
249
250                 [Test]
251                 [ExpectedException (typeof (ArgumentException))]
252                 public void GridLineColorException ()
253                 {
254                         DataGrid dg = new DataGrid ();
255                         dg.GridLineColor = Color.Empty;
256                 }
257
258                 [Test]
259                 [ExpectedException (typeof (ArgumentException))]
260                 public void HeaderBackColorException ()
261                 {
262                         DataGrid dg = new DataGrid ();
263                         dg.HeaderBackColor = Color.Empty;
264                 }
265
266                 [Test]
267                 [ExpectedException (typeof (ArgumentException))]
268                 public void PreferredColumnWidthException ()
269                 {
270                         DataGrid dg = new DataGrid ();
271                         dg.PreferredColumnWidth = -1;
272                 }
273                 
274                 [Test]
275                 public void ResetAlternatingBackColor ()
276                 {
277                         DataGrid dg = new DataGrid ();
278                         DataGrid dg2 = new DataGrid ();
279                         dg2.AlternatingBackColor = Color.Red;
280                         dg2.ResetAlternatingBackColor ();
281                         Assert.AreEqual (dg.AlternatingBackColor, dg2.AlternatingBackColor, "A1");
282                 }
283                 
284                 // Test reset colour methods
285                 [Test]
286                 public void ResetBackColorMethod ()
287                 {
288                         DataGrid dg = new DataGrid ();
289                         DataGrid dg2 = new DataGrid ();
290                         dg2.BackColor = Color.Red;
291                         dg2.ResetBackColor ();
292                         Assert.AreEqual (dg.BackColor, dg2.BackColor, "A1");
293                 }
294
295                 [Test]
296                 public void ResetForeColorMethod ()
297                 {
298                         DataGrid dg = new DataGrid ();
299                         DataGrid dg2 = new DataGrid ();
300                         dg2.ForeColor = Color.Red;
301                         dg2.ResetForeColor ();
302                         Assert.AreEqual (dg.ForeColor, dg2.ForeColor, "A1");
303                 }
304
305                 [Test]
306                 public void ResetGridLineColorMethod ()
307                 {                       
308                         DataGrid dg = new DataGrid ();
309                         DataGrid dg2 = new DataGrid ();
310                         dg2.GridLineColor = Color.Red;
311                         dg2.ResetGridLineColor ();
312                         Assert.AreEqual (dg.GridLineColor, dg2.GridLineColor, "A1");
313                 }
314
315                 [Test]
316                 public void ResetHeaderBackColorMethod ()
317                 {
318                         DataGrid dg = new DataGrid ();
319                         DataGrid dg2 = new DataGrid ();
320                         dg2.HeaderBackColor = Color.Red;
321                         dg2.ResetHeaderBackColor ();
322                         Assert.AreEqual (dg.HeaderBackColor, dg2.HeaderBackColor, "A1");
323                 }
324
325                 [Test]
326                 public void ResetHeaderFontMethod ()
327                 {
328                 }
329
330                 [Test]
331                 public void ResetHeaderForeColorMethod ()
332                 {
333                         DataGrid dg = new DataGrid ();
334                         DataGrid dg2 = new DataGrid ();
335                         dg2.HeaderForeColor = Color.Red;
336                         dg2.ResetHeaderForeColor ();
337                         Assert.AreEqual (dg.HeaderForeColor, dg2.HeaderForeColor, "A1");
338                 }
339
340                 [Test]
341                 public void ResetLinkColorMethod ()
342                 {
343                         DataGrid dg = new DataGrid ();
344                         DataGrid dg2 = new DataGrid ();
345                         dg2.LinkColor = Color.Red;
346                         dg2.ResetLinkColor ();
347                         Assert.AreEqual (dg.LinkColor, dg2.LinkColor, "A1");
348                 }
349
350                 [Test]
351                 public void ResetLinkHoverColor ()
352                 {
353                         DataGrid dg = new DataGrid ();
354                         DataGrid dg2 = new DataGrid ();
355                         dg2.LinkHoverColor = Color.Red;
356                         dg2.ResetLinkHoverColor ();
357                         Assert.AreEqual (dg.LinkHoverColor, dg2.LinkHoverColor, "A1");
358                 }
359
360                 [Test]          
361                 public void ResetSelectionBackColor ()
362                 {                       
363                         DataGrid dg = new DataGrid ();
364                         DataGrid dg2 = new DataGrid ();
365                         dg2.SelectionBackColor = Color.Red;
366                         dg2.ResetSelectionBackColor ();
367                         Assert.AreEqual (dg.SelectionBackColor, dg2.SelectionBackColor, "A1");
368                 }
369
370                 [Test]
371                 public void ResetSelectionForeColor ()
372                 {
373                         DataGrid dg = new DataGrid ();
374                         DataGrid dg2 = new DataGrid ();
375                         dg2.SelectionForeColor = Color.Red;
376                         dg2.ResetSelectionForeColor ();
377                         Assert.AreEqual (dg.SelectionForeColor, dg2.SelectionForeColor, "A1");
378                 }
379
380                 [Test]
381                 public void TestSetDataBinding ()
382                 {
383                         DataGrid dg = new DataGrid ();
384                         DataSet ds = new DataSet ("DataSet");
385                         DataTable dt = new DataTable ("DataTable");
386                         DataColumn dc = new DataColumn ("C");
387                         ds.Tables.Add (dt);
388
389                         dg.SetDataBinding (ds, "DataTable");
390                 }
391
392                 int data_source_changed_count = 0;
393                 void OnDataSourceChanged (object sender, EventArgs e)
394                 {
395                         data_source_changed_count ++;
396                 }
397
398                 [Test]
399                 public void TestManager1 ()
400                 {
401                         TestDataGrid dg = new TestDataGrid ();
402
403                         data_source_changed_count = 0;
404                         dg.DataSourceChanged += new EventHandler (OnDataSourceChanged);
405
406                         /* make sure everything is fine to start with */
407                         Assert.IsNull (dg.Manager, "A1");
408                         Assert.IsNull (dg.DataSource, "A2");
409                         Assert.AreEqual (dg.DataMember, "", "A3");
410                         // NotWorking Assert.AreEqual (0, data_source_changed_count, "A4");
411                 }
412
413                 [Test]
414                 public void TestManagerSetDataMember ()
415                 {
416                         TestDataGrid dg = new TestDataGrid ();
417
418                         data_source_changed_count = 0;
419                         dg.DataSourceChanged += new EventHandler (OnDataSourceChanged);
420
421                         /* set the datamember to something */
422                         dg.DataMember = "hi there";
423                         Assert.IsNull (dg.Manager, "A1");
424                         // NotWorking Assert.AreEqual (0, data_source_changed_count, "A2");
425                 }
426
427                 [Test]
428                 public void TestManagerSetDataSource ()
429                 {
430                         TestDataGrid dg = new TestDataGrid ();
431
432                         data_source_changed_count = 0;
433                         dg.DataSourceChanged += new EventHandler (OnDataSourceChanged);
434
435                         /* set our datasource to something */
436                         dg = new TestDataGrid ();
437                         DataSet ds = new DataSet ("DataSet");
438                         DataTable dt = new DataTable ("DataTable");
439                         DataColumn dc = new DataColumn ("C");
440                         ds.Tables.Add (dt);
441
442                         dg.DataSource = ds;
443                         Assert.IsNull (dg.Manager, "A1");
444
445                         /* set the datamember to something as well.. anything yet? */
446                         dg.DataMember = "DataTable";
447                         Assert.IsNull (dg.Manager, "A2");
448                         Assert.AreEqual (0, data_source_changed_count, "A3");
449                 }
450
451                 [Test]
452                 public void TestManagerCreateHandle ()
453                 {
454                         TestDataGrid dg = new TestDataGrid ();
455
456                         data_source_changed_count = 0;
457                         dg.DataSourceChanged += new EventHandler (OnDataSourceChanged);
458
459                         /* set our datasource to something */
460                         dg = new TestDataGrid ();
461                         DataSet ds = new DataSet ("DataSet");
462                         DataTable dt = new DataTable ("DataTable");
463                         DataColumn dc = new DataColumn ("C");
464                         ds.Tables.Add (dt);
465
466                         dg.DataSource = ds;
467
468                         /* cause the control to create its handle and
469                          * see if that does anything */
470                         Assert.IsNotNull (dg.Handle, "A1");
471                         Assert.IsNull (dg.Manager, "A2");
472                         Assert.AreEqual (0, data_source_changed_count, "A3");
473                 }
474
475                 [Test]
476                 public void TestManagerSetBindingContext ()
477                 {
478                         TestDataGrid dg = new TestDataGrid ();
479
480                         data_source_changed_count = 0;
481                         dg.DataSourceChanged += new EventHandler (OnDataSourceChanged);
482
483                         /* set our datasource to something */
484                         dg = new TestDataGrid ();
485                         DataSet ds = new DataSet ("DataSet");
486                         DataTable dt = new DataTable ("DataTable");
487                         DataColumn dc = new DataColumn ("C");
488                         ds.Tables.Add (dt);
489
490                         dg.DataSource = ds;
491                         dg.DataMember = "DataTable";
492
493                         /* now set the BindingContext and see if something changes */
494                         dg.BindingContext = new BindingContext ();
495                         Assert.IsNotNull (dg.Manager, "A1");
496                         Assert.AreEqual (0, data_source_changed_count, "A2");
497                 }
498
499                 [Test]
500                 public void TestManagerAfterSetBindingContext ()
501                 {
502                         TestDataGrid dg = new TestDataGrid ();
503
504                         data_source_changed_count = 0;
505                         dg.DataSourceChanged += new EventHandler (OnDataSourceChanged);
506
507                         dg.BindingContext = new BindingContext ();
508
509                         /* set our datasource to something */
510                         dg = new TestDataGrid ();
511                         DataSet ds = new DataSet ("DataSet");
512                         DataTable dt = new DataTable ("DataTable");
513                         DataColumn dc = new DataColumn ("C");
514                         ds.Tables.Add (dt);
515
516                         dg.DataSource = ds;
517                         Assert.IsNull (dg.Manager, "A1");
518
519                         dg.DataMember = "DataTable";
520                         Assert.IsNull (dg.Manager, "A2");
521
522                         dg.BindingContext = new BindingContext ();
523                         Assert.IsNotNull (dg.Manager, "A3");
524                         // NotWorking Assert.AreEqual (0, data_source_changed_count, "A4");
525                 }
526
527                 [Test]
528                 public void TestManagerSetDataMemberAfterSetBindingContext ()
529                 {
530                         TestDataGrid dg = new TestDataGrid ();
531
532                         data_source_changed_count = 0;
533                         dg.DataSourceChanged += new EventHandler (OnDataSourceChanged);
534
535                         /* set our datasource to something */
536                         dg = new TestDataGrid ();
537                         DataSet ds = new DataSet ("DataSet");
538                         DataTable dt = new DataTable ("DataTable");
539                         DataColumn dc = new DataColumn ("C");
540                         ds.Tables.Add (dt);
541
542                         dg.DataSource = ds;
543
544                         dg.BindingContext = new BindingContext ();
545                         Assert.AreEqual (0, data_source_changed_count, "A1");
546
547                         CurrencyManager mgr = dg.Manager;
548
549                         dg.DataMember = "DataTable";
550                         Assert.IsNotNull (dg.Manager, "A2");
551                         Assert.IsTrue (mgr != dg.Manager, "A3");
552                         Assert.AreEqual (0, data_source_changed_count, "A4");
553                 }
554
555                 [Test]
556                 public void TestManagerSetDataSourceAfterSetBindingContext ()
557                 {
558                         TestDataGrid dg = new TestDataGrid ();
559
560                         data_source_changed_count = 0;
561                         dg.DataSourceChanged += new EventHandler (OnDataSourceChanged);
562
563                         /* set our datasource to something */
564                         dg = new TestDataGrid ();
565                         DataSet ds = new DataSet ("DataSet");
566                         DataTable dt = new DataTable ("DataTable");
567                         DataColumn dc = new DataColumn ("C");
568                         ds.Tables.Add (dt);
569
570                         dg.DataMember = "DataTable";
571
572                         dg.BindingContext = new BindingContext ();
573                         Assert.AreEqual (0, data_source_changed_count, "A1");
574
575                         CurrencyManager mgr = dg.Manager;
576
577                         dg.DataSource = ds;
578                         Assert.IsNotNull (dg.Manager, "A2");
579                         Assert.IsTrue (mgr != dg.Manager, "A3");
580                         Assert.AreEqual (0, data_source_changed_count, "A4");
581                 }
582
583                 [Test]
584                 public void TestManagerSetDataSourceAfterSetBindingContextWithHandle ()
585                 {
586                         TestDataGrid dg = new TestDataGrid ();
587
588                         data_source_changed_count = 0;
589                         dg.DataSourceChanged += new EventHandler (OnDataSourceChanged);
590
591                         /* set our datasource to something */
592                         dg = new TestDataGrid ();
593                         DataSet ds = new DataSet ("DataSet");
594                         DataTable dt = new DataTable ("DataTable");
595                         DataColumn dc = new DataColumn ("C");
596                         ds.Tables.Add (dt);
597
598                         /* cause the control to create its handle and
599                          * see if that does anything */
600                         Assert.IsNotNull (dg.Handle, "A1");
601
602                         dg.DataSource = new ArrayList ();
603
604                         dg.BindingContext = new BindingContext ();
605                         Assert.AreEqual (0, data_source_changed_count, "A2");
606
607                         dg.DataSource = ds;
608                         Assert.AreEqual (0, data_source_changed_count, "A3");
609                 }
610         }
611 }