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