ChangeLog: Updated ChangeLog.
[mono.git] / mcs / class / System.Drawing / Test / System.Drawing / TestSystemBrushes.cs
1 // Tests for System.Drawing.SystemBrushes.cs
2 //
3 // Author: Ravindra (rkumar@novell.com)
4 //
5 // Copyright (c) 2004 Novell, Inc. http://www.novell.com
6 //
7
8 using NUnit.Framework;
9 using System;
10 using System.Drawing;
11
12 namespace MonoTests.System.Drawing
13 {
14         [TestFixture]   
15         public class SystemBrushesTest : Assertion
16         {
17                 [TearDown]
18                 public void TearDown () {}
19
20                 [SetUp]
21                 public void SetUp () {}
22
23                 [Test]
24                 public void TestActiveBorder ()
25                 {
26                         SolidBrush brush;
27                         brush = (SolidBrush) SystemBrushes.ActiveBorder;
28                         Assert ("P1#1", brush.Color.IsSystemColor);
29                         AssertEquals ("P1#2", SystemColors.ActiveBorder, brush.Color);
30
31                         try {
32                                 brush.Color = Color.Red;
33                                 Fail ("P1#3: must throw ArgumentException");
34                         } catch (Exception e) {
35                                 Assert ("P1#3", e is ArgumentException);
36                         }
37
38                         try {
39                                 brush.Color = SystemColors.ActiveBorder;
40                                 Fail ("P1#4: must throw ArgumentException");
41                         } catch (Exception e) {
42                                 Assert ("P1#4", e is ArgumentException);
43                         }
44
45                         try {
46                                 brush.Dispose();
47                                 Fail ("P1#5: must throw ArgumentException");
48                         } catch (Exception e) {
49                                 Assert ("P1#5", e is ArgumentException);
50                         }
51                 }
52
53                 [Test]
54                 public void TestActiveCaption ()
55                 {
56                         SolidBrush brush;
57                         brush = (SolidBrush) SystemBrushes.ActiveCaption;
58                         Assert ("P2#1", brush.Color.IsSystemColor);
59                         AssertEquals ("P2#2", SystemColors.ActiveCaption, brush.Color);
60
61                         try {
62                                 brush.Color = Color.Red;
63                                 Fail ("P2#3: must throw ArgumentException");
64                         } catch (Exception e) {
65                                 Assert ("P2#3", e is ArgumentException);
66                         }
67
68                         try {
69                                 brush.Color = SystemColors.ActiveCaption;
70                                 Fail ("P2#4: must throw ArgumentException");
71                         } catch (Exception e) {
72                                 Assert ("P2#4", e is ArgumentException);
73                         }
74
75                         try {
76                                 brush.Dispose();
77                                 Fail ("P2#5: must throw ArgumentException");
78                         } catch (Exception e) {
79                                 Assert ("P2#5", e is ArgumentException);
80                         }
81
82                 }
83
84                 [Test]
85                 public void TestActiveCaptionText ()
86                 {
87                         SolidBrush brush;
88                         brush = (SolidBrush) SystemBrushes.ActiveCaptionText;
89                         Assert ("P3#1", brush.Color.IsSystemColor);
90                         AssertEquals ("P3#2", SystemColors.ActiveCaptionText, brush.Color);
91
92                         try {
93                                 brush.Color = Color.Red;
94                                 Fail ("P3#3: must throw ArgumentException");
95                         } catch (Exception e) {
96                                 Assert ("P3#3", e is ArgumentException);
97                         }
98
99                         try {
100                                 brush.Color = SystemColors.ActiveCaptionText;
101                                 Fail ("P3#4: must throw ArgumentException");
102                         } catch (Exception e) {
103                                 Assert ("P3#4", e is ArgumentException);
104                         }
105
106                         try {
107                                 brush.Dispose();
108                                 Fail ("P3#5: must throw ArgumentException");
109                         } catch (Exception e) {
110                                 Assert ("P3#5", e is ArgumentException);
111                         }
112                 }
113
114                 [Test]
115                 public void TestAppWorkspace ()
116                 {
117                         SolidBrush brush;
118                         brush = (SolidBrush) SystemBrushes.AppWorkspace;
119                         Assert ("P4#1", brush.Color.IsSystemColor);
120                         AssertEquals ("P4#2", SystemColors.AppWorkspace, brush.Color);
121
122                         try {
123                                 brush.Color = Color.Red;
124                                 Fail ("P4#3: must throw ArgumentException");
125                         } catch (Exception e) {
126                                 Assert ("P4#3", e is ArgumentException);
127                         }
128
129                         try {
130                                 brush.Color = SystemColors.AppWorkspace;
131                                 Fail ("P4#4: must throw ArgumentException");
132                         } catch (Exception e) {
133                                 Assert ("P4#4", e is ArgumentException);
134                         }
135
136                         try {
137                                 brush.Dispose();
138                                 Fail ("P4#5: must throw ArgumentException");
139                         } catch (Exception e) {
140                                 Assert ("P4#5", e is ArgumentException);
141                         }
142                 }
143
144                 [Test]
145                 public void TestControl ()
146                 {
147                         SolidBrush brush;
148                         brush = (SolidBrush) SystemBrushes.Control;
149                         Assert ("P5#1", brush.Color.IsSystemColor);
150                         AssertEquals ("P5#2", SystemColors.Control, brush.Color);
151
152                         try {
153                                 brush.Color = Color.Red;
154                                 Fail ("P5#3: must throw ArgumentException");
155                         } catch (Exception e) {
156                                 Assert ("P5#3", e is ArgumentException);
157                         }
158
159                         try {
160                                 brush.Color = SystemColors.Control;
161                                 Fail ("P5#4: must throw ArgumentException");
162                         } catch (Exception e) {
163                                 Assert ("P5#4", e is ArgumentException);
164                         }
165
166                         try {
167                                 brush.Dispose();
168                                 Fail ("P5#5: must throw ArgumentException");
169                         } catch (Exception e) {
170                                 Assert ("P5#5", e is ArgumentException);
171                         }
172
173                 }
174
175                 [Test]
176                 public void TestControlDark ()
177                 {
178                         SolidBrush brush;
179                         brush = (SolidBrush) SystemBrushes.ControlDark;
180                         Assert ("P6#1", brush.Color.IsSystemColor);
181                         AssertEquals ("P6#2", SystemColors.ControlDark, brush.Color);
182
183                         try {
184                                 brush.Color = Color.Red;
185                                 Fail ("P6#3: must throw ArgumentException");
186                         } catch (Exception e) {
187                                 Assert ("P6#3", e is ArgumentException);
188                         }
189
190                         try {
191                                 brush.Color = SystemColors.ControlDark;
192                                 Fail ("P6#4: must throw ArgumentException");
193                         } catch (Exception e) {
194                                 Assert ("P6#4", e is ArgumentException);
195                         }
196
197                         try {
198                                 brush.Dispose();
199                                 Fail ("P6#5: must throw ArgumentException");
200                         } catch (Exception e) {
201                                 Assert ("P6#5", e is ArgumentException);
202                         }
203                 }
204
205                 [Test]
206                 public void TestControlDarkDark ()
207                 {
208                         SolidBrush brush;
209                         brush = (SolidBrush) SystemBrushes.ControlDarkDark;
210                         Assert ("P7#1", brush.Color.IsSystemColor);
211                         AssertEquals ("P7#2", SystemColors.ControlDarkDark, brush.Color);
212
213                         try {
214                                 brush.Color = Color.Red;
215                                 Fail ("P7#3: must throw ArgumentException");
216                         } catch (Exception e) {
217                                 Assert ("P7#3", e is ArgumentException);
218                         }
219
220                         try {
221                                 brush.Color = SystemColors.ControlDarkDark;
222                                 Fail ("P7#4: must throw ArgumentException");
223                         } catch (Exception e) {
224                                 Assert ("P7#4", e is ArgumentException);
225                         }
226
227                         try {
228                                 brush.Dispose();
229                                 Fail ("P7#5: must throw ArgumentException");
230                         } catch (Exception e) {
231                                 Assert ("P7#5", e is ArgumentException);
232                         }
233                 }
234
235                 [Test]
236                 public void TestControlLight ()
237                 {
238                         SolidBrush brush;
239                         brush = (SolidBrush) SystemBrushes.ControlLight;
240                         Assert ("P8#1", brush.Color.IsSystemColor);
241                         AssertEquals ("P8#2", SystemColors.ControlLight, brush.Color);
242
243                         try {
244                                 brush.Color = Color.Red;
245                                 Fail ("P8#3: must throw ArgumentException");
246                         } catch (Exception e) {
247                                 Assert ("P8#3", e is ArgumentException);
248                         }
249
250                         try {
251                                 brush.Color = SystemColors.ControlLight;
252                                 Fail ("P8#4: must throw ArgumentException");
253                         } catch (Exception e) {
254                                 Assert ("P8#4", e is ArgumentException);
255                         }
256
257                         try {
258                                 brush.Dispose();
259                                 Fail ("P8#5: must throw ArgumentException");
260                         } catch (Exception e) {
261                                 Assert ("P8#5", e is ArgumentException);
262                         }
263                 }
264
265                 [Test]
266                 public void TestControlLightLight ()
267                 {
268                         SolidBrush brush;
269                         brush = (SolidBrush) SystemBrushes.ControlLightLight;
270                         Assert ("P9#1", brush.Color.IsSystemColor);
271                         AssertEquals ("P9#2", SystemColors.ControlLightLight, brush.Color);
272
273                         try {
274                                 brush.Color = Color.Red;
275                                 Fail ("P9#3: must throw ArgumentException");
276                         } catch (Exception e) {
277                                 Assert ("P9#3", e is ArgumentException);
278                         }
279
280                         try {
281                                 brush.Color = SystemColors.ControlLightLight;
282                                 Fail ("P9#4: must throw ArgumentException");
283                         } catch (Exception e) {
284                                 Assert ("P9#4", e is ArgumentException);
285                         }
286
287                         try {
288                                 brush.Dispose();
289                                 Fail ("P9#5: must throw ArgumentException");
290                         } catch (Exception e) {
291                                 Assert ("P9#5", e is ArgumentException);
292                         }
293                 }
294
295                 [Test]
296                 public void TestControlText ()
297                 {
298                         SolidBrush brush;
299                         brush = (SolidBrush) SystemBrushes.ControlText;
300                         Assert ("P10#1", brush.Color.IsSystemColor);
301                         AssertEquals ("P10#2", SystemColors.ControlText, brush.Color);
302
303                         try {
304                                 brush.Color = Color.Red;
305                                 Fail ("P10#3: must throw ArgumentException");
306                         } catch (Exception e) {
307                                 Assert ("P10#3", e is ArgumentException);
308                         }
309
310                         try {
311                                 brush.Color = SystemColors.ControlText;
312                                 Fail ("P10#4: must throw ArgumentException");
313                         } catch (Exception e) {
314                                 Assert ("P10#4", e is ArgumentException);
315                         }
316
317                         try {
318                                 brush.Dispose();
319                                 Fail ("P10#5: must throw ArgumentException");
320                         } catch (Exception e) {
321                                 Assert ("P10#5", e is ArgumentException);
322                         }
323                 }
324
325
326                 [Test]
327                 public void TestDesktop ()
328                 {
329                         SolidBrush brush;
330                         brush = (SolidBrush) SystemBrushes.Desktop;
331                         Assert ("P11#1", brush.Color.IsSystemColor);
332                         AssertEquals ("P11#2", SystemColors.Desktop, brush.Color);
333
334                         try {
335                                 brush.Color = Color.Red;
336                                 Fail ("P11#3: must throw ArgumentException");
337                         } catch (Exception e) {
338                                 Assert ("P11#3", e is ArgumentException);
339                         }
340
341                         try {
342                                 brush.Color = SystemColors.Desktop;
343                                 Fail ("P11#4: must throw ArgumentException");
344                         } catch (Exception e) {
345                                 Assert ("P11#4", e is ArgumentException);
346                         }
347
348                         try {
349                                 brush.Dispose();
350                                 Fail ("P11#5: must throw ArgumentException");
351                         } catch (Exception e) {
352                                 Assert ("P11#5", e is ArgumentException);
353                         }
354                 }
355
356                 [Test]
357                 public void TestHighlight ()
358                 {
359                         SolidBrush brush;
360                         brush = (SolidBrush) SystemBrushes.Highlight;
361                         Assert ("P12#1", brush.Color.IsSystemColor);
362                         AssertEquals ("P12#2", SystemColors.Highlight, brush.Color);
363
364                         try {
365                                 brush.Color = Color.Red;
366                                 Fail ("P12#3: must throw ArgumentException");
367                         } catch (Exception e) {
368                                 Assert ("P12#3", e is ArgumentException);
369                         }
370
371                         try {
372                                 brush.Color = SystemColors.Highlight;
373                                 Fail ("P12#4: must throw ArgumentException");
374                         } catch (Exception e) {
375                                 Assert ("P12#4", e is ArgumentException);
376                         }
377
378                         try {
379                                 brush.Dispose();
380                                 Fail ("P12#5: must throw ArgumentException");
381                         } catch (Exception e) {
382                                 Assert ("P12#5", e is ArgumentException);
383                         }
384                 }
385
386                 [Test]
387                 public void TestHighlightText ()
388                 {
389                         SolidBrush brush;
390                         brush = (SolidBrush) SystemBrushes.HighlightText;
391                         Assert ("P13#1", brush.Color.IsSystemColor);
392                         AssertEquals ("P13#2", SystemColors.HighlightText, brush.Color);
393
394                         try {
395                                 brush.Color = Color.Red;
396                                 Fail ("P13#3: must throw ArgumentException");
397                         } catch (Exception e) {
398                                 Assert ("P13#3", e is ArgumentException);
399                         }
400
401                         try {
402                                 brush.Color = SystemColors.HighlightText;
403                                 Fail ("P13#4: must throw ArgumentException");
404                         } catch (Exception e) {
405                                 Assert ("P13#4", e is ArgumentException);
406                         }
407
408                         try {
409                                 brush.Dispose();
410                                 Fail ("P13#5: must throw ArgumentException");
411                         } catch (Exception e) {
412                                 Assert ("P13#5", e is ArgumentException);
413                         }
414                 }
415
416                 [Test]
417                 public void TestHotTrack ()
418                 {
419                         SolidBrush brush;
420                         brush = (SolidBrush) SystemBrushes.HotTrack;
421                         Assert ("P14#1", brush.Color.IsSystemColor);
422                         AssertEquals ("P14#2", SystemColors.HotTrack, brush.Color);
423
424                         try {
425                                 brush.Color = Color.Red;
426                                 Fail ("P14#3: must throw ArgumentException");
427                         } catch (Exception e) {
428                                 Assert ("P14#3", e is ArgumentException);
429                         }
430
431                         try {
432                                 brush.Color = SystemColors.HotTrack;
433                                 Fail ("P14#4: must throw ArgumentException");
434                         } catch (Exception e) {
435                                 Assert ("P14#4", e is ArgumentException);
436                         }
437
438                         try {
439                                 brush.Dispose();
440                                 Fail ("P14#5: must throw ArgumentException");
441                         } catch (Exception e) {
442                                 Assert ("P14#5", e is ArgumentException);
443                         }
444                 }
445
446                 [Test]
447                 public void TestInactiveBorder ()
448                 {
449                         SolidBrush brush;
450                         brush = (SolidBrush) SystemBrushes.InactiveBorder;
451                         Assert ("P15#1", brush.Color.IsSystemColor);
452                         AssertEquals ("P15#2", SystemColors.InactiveBorder, brush.Color);
453
454                         try {
455                                 brush.Color = Color.Red;
456                                 Fail ("P15#3: must throw ArgumentException");
457                         } catch (Exception e) {
458                                 Assert ("P15#3", e is ArgumentException);
459                         }
460
461                         try {
462                                 brush.Color = SystemColors.InactiveBorder;
463                                 Fail ("P15#4: must throw ArgumentException");
464                         } catch (Exception e) {
465                                 Assert ("P15#4", e is ArgumentException);
466                         }
467
468                         try {
469                                 brush.Dispose();
470                                 Fail ("P15#5: must throw ArgumentException");
471                         } catch (Exception e) {
472                                 Assert ("P15#5", e is ArgumentException);
473                         }
474                 }
475
476                 [Test]
477                 public void TestInactiveCaption ()
478                 {
479                         SolidBrush brush;
480                         brush = (SolidBrush) SystemBrushes.InactiveCaption;
481                         Assert ("P16#1", brush.Color.IsSystemColor);
482                         AssertEquals ("P16#2", SystemColors.InactiveCaption, brush.Color);
483
484                         try {
485                                 brush.Color = Color.Red;
486                                 Fail ("P16#3: must throw ArgumentException");
487                         } catch (Exception e) {
488                                 Assert ("P16#3", e is ArgumentException);
489                         }
490
491                         try {
492                                 brush.Color = SystemColors.InactiveCaption;
493                                 Fail ("P16#4: must throw ArgumentException");
494                         } catch (Exception e) {
495                                 Assert ("P16#4", e is ArgumentException);
496                         }
497
498                         try {
499                                 brush.Dispose();
500                                 Fail ("P16#5: must throw ArgumentException");
501                         } catch (Exception e) {
502                                 Assert ("P16#5", e is ArgumentException);
503                         }
504                 }
505
506                 [Test]
507                 public void TestInfo ()
508                 {
509                         SolidBrush brush;
510                         brush = (SolidBrush) SystemBrushes.Info;
511                         Assert ("P17#1", brush.Color.IsSystemColor);
512                         AssertEquals ("P17#2", SystemColors.Info, brush.Color);
513
514                         try {
515                                 brush.Color = Color.Red;
516                                 Fail ("P17#3: must throw ArgumentException");
517                         } catch (Exception e) {
518                                 Assert ("P17#3", e is ArgumentException);
519                         }
520
521                         try {
522                                 brush.Color = SystemColors.Info;
523                                 Fail ("P17#4: must throw ArgumentException");
524                         } catch (Exception e) {
525                                 Assert ("P17#4", e is ArgumentException);
526                         }
527
528                         try {
529                                 brush.Dispose();
530                                 Fail ("P17#5: must throw ArgumentException");
531                         } catch (Exception e) {
532                                 Assert ("P17#5", e is ArgumentException);
533                         }
534                 }
535
536                 [Test]
537                 public void TestMenu ()
538                 {
539                         SolidBrush brush;
540                         brush = (SolidBrush) SystemBrushes.Menu;
541                         Assert ("P18#1", brush.Color.IsSystemColor);
542                         AssertEquals ("P18#2", SystemColors.Menu, brush.Color);
543
544                         try {
545                                 brush.Color = Color.Red;
546                                 Fail ("P18#3: must throw ArgumentException");
547                         } catch (Exception e) {
548                                 Assert ("P18#3", e is ArgumentException);
549                         }
550
551                         try {
552                                 brush.Color = SystemColors.Menu;
553                                 Fail ("P18#4: must throw ArgumentException");
554                         } catch (Exception e) {
555                                 Assert ("P18#4", e is ArgumentException);
556                         }
557
558                         try {
559                                 brush.Dispose();
560                                 Fail ("P18#5: must throw ArgumentException");
561                         } catch (Exception e) {
562                                 Assert ("P18#5", e is ArgumentException);
563                         }
564                 }
565
566                 [Test]
567                 public void TestScrollBar ()
568                 {
569                         SolidBrush brush;
570                         brush = (SolidBrush) SystemBrushes.ScrollBar;
571                         Assert ("P19#1", brush.Color.IsSystemColor);
572                         AssertEquals ("P19#2", SystemColors.ScrollBar, brush.Color);
573
574                         try {
575                                 brush.Color = Color.Red;
576                                 Fail ("P19#3: must throw ArgumentException");
577                         } catch (Exception e) {
578                                 Assert ("P19#3", e is ArgumentException);
579                         }
580
581                         try {
582                                 brush.Color = SystemColors.ScrollBar;
583                                 Fail ("P19#4: must throw ArgumentException");
584                         } catch (Exception e) {
585                                 Assert ("P19#4", e is ArgumentException);
586                         }
587
588                         try {
589                                 brush.Dispose();
590                                 Fail ("P19#5: must throw ArgumentException");
591                         } catch (Exception e) {
592                                 Assert ("P19#5", e is ArgumentException);
593                         }
594                 }
595
596                 [Test]
597                 public void TestWindow ()
598                 {
599                         SolidBrush brush;
600                         brush = (SolidBrush) SystemBrushes.Window;
601                         Assert ("P20#1", brush.Color.IsSystemColor);
602                         AssertEquals ("P20#2", SystemColors.Window, brush.Color);
603
604                         try {
605                                 brush.Color = Color.Red;
606                                 Fail ("P20#3: must throw ArgumentException");
607                         } catch (Exception e) {
608                                 Assert ("P20#3", e is ArgumentException);
609                         }
610
611                         try {
612                                 brush.Color = SystemColors.Window;
613                                 Fail ("P20#4: must throw ArgumentException");
614                         } catch (Exception e) {
615                                 Assert ("P20#4", e is ArgumentException);
616                         }
617
618                         try {
619                                 brush.Dispose();
620                                 Fail ("P20#5: must throw ArgumentException");
621                         } catch (Exception e) {
622                                 Assert ("P20#5", e is ArgumentException);
623                         }
624                 }
625
626                 [Test]
627                 public void TestWindowText ()
628                 {
629                         SolidBrush brush;
630                         brush = (SolidBrush) SystemBrushes.WindowText;
631                         Assert ("P21#1", brush.Color.IsSystemColor);
632                         AssertEquals ("P21#2", SystemColors.WindowText, brush.Color);
633
634                         try {
635                                 brush.Color = Color.Red;
636                                 Fail ("P21#3: must throw ArgumentException");
637                         } catch (Exception e) {
638                                 Assert ("P21#3", e is ArgumentException);
639                         }
640
641                         try {
642                                 brush.Color = SystemColors.WindowText;
643                                 Fail ("P21#4: must throw ArgumentException");
644                         } catch (Exception e) {
645                                 Assert ("P21#4", e is ArgumentException);
646                         }
647
648                         try {
649                                 brush.Dispose();
650                                 Fail ("P21#5: must throw ArgumentException");
651                         } catch (Exception e) {
652                                 Assert ("P21#5", e is ArgumentException);
653                         }
654                 }
655
656                 [Test]
657                 public void TestFromSystemColor ()
658                 {
659                         SolidBrush brush;
660
661                         brush = (SolidBrush) SystemBrushes.FromSystemColor (SystemColors.Menu);
662                         AssertEquals ("M1#1", SystemColors.Menu, brush.Color);
663
664                         try {
665                                 brush.Color = Color.Red;
666                                 Fail ("M1#2: must throw ArgumentException");
667                         } catch (Exception e) {
668                                 Assert ("M1#2", e is ArgumentException);
669                         }
670
671                         try {
672                                 brush.Color = SystemColors.Menu;
673                                 Fail ("M1#3: must throw ArgumentException");
674                         } catch (Exception e) {
675                                 Assert ("M1#3", e is ArgumentException);
676                         }
677
678                         try {
679                                 brush.Dispose();
680                                 Fail ("M1#4: must throw ArgumentException");
681                         } catch (Exception e) {
682                                 Assert ("M1#4", e is ArgumentException);
683                         }
684
685
686                         try {
687                                 brush = (SolidBrush) SystemBrushes.FromSystemColor (Color.Red);
688                                 Fail ("M2#1: must throw ArgumentException");
689                         } catch (Exception e) {
690                                 Assert ("M2#1", e is ArgumentException);
691                         }
692                 }
693         }
694 }