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