1 // Tests for System.Drawing.SystemBrushes.cs
3 // Author: Ravindra (rkumar@novell.com)
5 // Copyright (c) 2004 Novell, Inc. http://www.novell.com
12 namespace MonoTests.System.Drawing
15 public class SystemBrushesTest : Assertion
18 public void TearDown () {}
21 public void SetUp () {}
24 public void TestActiveBorder ()
27 brush = (SolidBrush) SystemBrushes.ActiveBorder;
28 Assert ("P1#1", brush.Color.IsSystemColor);
29 AssertEquals ("P1#2", SystemColors.ActiveBorder, brush.Color);
32 brush.Color = Color.Red;
33 Fail ("P1#3: must throw ArgumentException");
34 } catch (Exception e) {
35 Assert ("P1#3", e is ArgumentException);
39 brush.Color = SystemColors.ActiveBorder;
40 Fail ("P1#4: must throw ArgumentException");
41 } catch (Exception e) {
42 Assert ("P1#4", e is ArgumentException);
47 Fail ("P1#5: must throw ArgumentException");
48 } catch (Exception e) {
49 Assert ("P1#5", e is ArgumentException);
54 public void TestActiveCaption ()
57 brush = (SolidBrush) SystemBrushes.ActiveCaption;
58 Assert ("P2#1", brush.Color.IsSystemColor);
59 AssertEquals ("P2#2", SystemColors.ActiveCaption, brush.Color);
62 brush.Color = Color.Red;
63 Fail ("P2#3: must throw ArgumentException");
64 } catch (Exception e) {
65 Assert ("P2#3", e is ArgumentException);
69 brush.Color = SystemColors.ActiveCaption;
70 Fail ("P2#4: must throw ArgumentException");
71 } catch (Exception e) {
72 Assert ("P2#4", e is ArgumentException);
77 Fail ("P2#5: must throw ArgumentException");
78 } catch (Exception e) {
79 Assert ("P2#5", e is ArgumentException);
85 public void TestActiveCaptionText ()
88 brush = (SolidBrush) SystemBrushes.ActiveCaptionText;
89 Assert ("P3#1", brush.Color.IsSystemColor);
90 AssertEquals ("P3#2", SystemColors.ActiveCaptionText, brush.Color);
93 brush.Color = Color.Red;
94 Fail ("P3#3: must throw ArgumentException");
95 } catch (Exception e) {
96 Assert ("P3#3", e is ArgumentException);
100 brush.Color = SystemColors.ActiveCaptionText;
101 Fail ("P3#4: must throw ArgumentException");
102 } catch (Exception e) {
103 Assert ("P3#4", e is ArgumentException);
108 Fail ("P3#5: must throw ArgumentException");
109 } catch (Exception e) {
110 Assert ("P3#5", e is ArgumentException);
115 public void TestAppWorkspace ()
118 brush = (SolidBrush) SystemBrushes.AppWorkspace;
119 Assert ("P4#1", brush.Color.IsSystemColor);
120 AssertEquals ("P4#2", SystemColors.AppWorkspace, brush.Color);
123 brush.Color = Color.Red;
124 Fail ("P4#3: must throw ArgumentException");
125 } catch (Exception e) {
126 Assert ("P4#3", e is ArgumentException);
130 brush.Color = SystemColors.AppWorkspace;
131 Fail ("P4#4: must throw ArgumentException");
132 } catch (Exception e) {
133 Assert ("P4#4", e is ArgumentException);
138 Fail ("P4#5: must throw ArgumentException");
139 } catch (Exception e) {
140 Assert ("P4#5", e is ArgumentException);
145 public void TestControl ()
148 brush = (SolidBrush) SystemBrushes.Control;
149 Assert ("P5#1", brush.Color.IsSystemColor);
150 AssertEquals ("P5#2", SystemColors.Control, brush.Color);
153 brush.Color = Color.Red;
154 Fail ("P5#3: must throw ArgumentException");
155 } catch (Exception e) {
156 Assert ("P5#3", e is ArgumentException);
160 brush.Color = SystemColors.Control;
161 Fail ("P5#4: must throw ArgumentException");
162 } catch (Exception e) {
163 Assert ("P5#4", e is ArgumentException);
168 Fail ("P5#5: must throw ArgumentException");
169 } catch (Exception e) {
170 Assert ("P5#5", e is ArgumentException);
176 public void TestControlDark ()
179 brush = (SolidBrush) SystemBrushes.ControlDark;
180 Assert ("P6#1", brush.Color.IsSystemColor);
181 AssertEquals ("P6#2", SystemColors.ControlDark, brush.Color);
184 brush.Color = Color.Red;
185 Fail ("P6#3: must throw ArgumentException");
186 } catch (Exception e) {
187 Assert ("P6#3", e is ArgumentException);
191 brush.Color = SystemColors.ControlDark;
192 Fail ("P6#4: must throw ArgumentException");
193 } catch (Exception e) {
194 Assert ("P6#4", e is ArgumentException);
199 Fail ("P6#5: must throw ArgumentException");
200 } catch (Exception e) {
201 Assert ("P6#5", e is ArgumentException);
206 public void TestControlDarkDark ()
209 brush = (SolidBrush) SystemBrushes.ControlDarkDark;
210 Assert ("P7#1", brush.Color.IsSystemColor);
211 AssertEquals ("P7#2", SystemColors.ControlDarkDark, brush.Color);
214 brush.Color = Color.Red;
215 Fail ("P7#3: must throw ArgumentException");
216 } catch (Exception e) {
217 Assert ("P7#3", e is ArgumentException);
221 brush.Color = SystemColors.ControlDarkDark;
222 Fail ("P7#4: must throw ArgumentException");
223 } catch (Exception e) {
224 Assert ("P7#4", e is ArgumentException);
229 Fail ("P7#5: must throw ArgumentException");
230 } catch (Exception e) {
231 Assert ("P7#5", e is ArgumentException);
236 public void TestControlLight ()
239 brush = (SolidBrush) SystemBrushes.ControlLight;
240 Assert ("P8#1", brush.Color.IsSystemColor);
241 AssertEquals ("P8#2", SystemColors.ControlLight, brush.Color);
244 brush.Color = Color.Red;
245 Fail ("P8#3: must throw ArgumentException");
246 } catch (Exception e) {
247 Assert ("P8#3", e is ArgumentException);
251 brush.Color = SystemColors.ControlLight;
252 Fail ("P8#4: must throw ArgumentException");
253 } catch (Exception e) {
254 Assert ("P8#4", e is ArgumentException);
259 Fail ("P8#5: must throw ArgumentException");
260 } catch (Exception e) {
261 Assert ("P8#5", e is ArgumentException);
266 public void TestControlLightLight ()
269 brush = (SolidBrush) SystemBrushes.ControlLightLight;
270 Assert ("P9#1", brush.Color.IsSystemColor);
271 AssertEquals ("P9#2", SystemColors.ControlLightLight, brush.Color);
274 brush.Color = Color.Red;
275 Fail ("P9#3: must throw ArgumentException");
276 } catch (Exception e) {
277 Assert ("P9#3", e is ArgumentException);
281 brush.Color = SystemColors.ControlLightLight;
282 Fail ("P9#4: must throw ArgumentException");
283 } catch (Exception e) {
284 Assert ("P9#4", e is ArgumentException);
289 Fail ("P9#5: must throw ArgumentException");
290 } catch (Exception e) {
291 Assert ("P9#5", e is ArgumentException);
296 public void TestControlText ()
299 brush = (SolidBrush) SystemBrushes.ControlText;
300 Assert ("P10#1", brush.Color.IsSystemColor);
301 AssertEquals ("P10#2", SystemColors.ControlText, brush.Color);
304 brush.Color = Color.Red;
305 Fail ("P10#3: must throw ArgumentException");
306 } catch (Exception e) {
307 Assert ("P10#3", e is ArgumentException);
311 brush.Color = SystemColors.ControlText;
312 Fail ("P10#4: must throw ArgumentException");
313 } catch (Exception e) {
314 Assert ("P10#4", e is ArgumentException);
319 Fail ("P10#5: must throw ArgumentException");
320 } catch (Exception e) {
321 Assert ("P10#5", e is ArgumentException);
327 public void TestDesktop ()
330 brush = (SolidBrush) SystemBrushes.Desktop;
331 Assert ("P11#1", brush.Color.IsSystemColor);
332 AssertEquals ("P11#2", SystemColors.Desktop, brush.Color);
335 brush.Color = Color.Red;
336 Fail ("P11#3: must throw ArgumentException");
337 } catch (Exception e) {
338 Assert ("P11#3", e is ArgumentException);
342 brush.Color = SystemColors.Desktop;
343 Fail ("P11#4: must throw ArgumentException");
344 } catch (Exception e) {
345 Assert ("P11#4", e is ArgumentException);
350 Fail ("P11#5: must throw ArgumentException");
351 } catch (Exception e) {
352 Assert ("P11#5", e is ArgumentException);
357 public void TestHighlight ()
360 brush = (SolidBrush) SystemBrushes.Highlight;
361 Assert ("P12#1", brush.Color.IsSystemColor);
362 AssertEquals ("P12#2", SystemColors.Highlight, brush.Color);
365 brush.Color = Color.Red;
366 Fail ("P12#3: must throw ArgumentException");
367 } catch (Exception e) {
368 Assert ("P12#3", e is ArgumentException);
372 brush.Color = SystemColors.Highlight;
373 Fail ("P12#4: must throw ArgumentException");
374 } catch (Exception e) {
375 Assert ("P12#4", e is ArgumentException);
380 Fail ("P12#5: must throw ArgumentException");
381 } catch (Exception e) {
382 Assert ("P12#5", e is ArgumentException);
387 public void TestHighlightText ()
390 brush = (SolidBrush) SystemBrushes.HighlightText;
391 Assert ("P13#1", brush.Color.IsSystemColor);
392 AssertEquals ("P13#2", SystemColors.HighlightText, brush.Color);
395 brush.Color = Color.Red;
396 Fail ("P13#3: must throw ArgumentException");
397 } catch (Exception e) {
398 Assert ("P13#3", e is ArgumentException);
402 brush.Color = SystemColors.HighlightText;
403 Fail ("P13#4: must throw ArgumentException");
404 } catch (Exception e) {
405 Assert ("P13#4", e is ArgumentException);
410 Fail ("P13#5: must throw ArgumentException");
411 } catch (Exception e) {
412 Assert ("P13#5", e is ArgumentException);
417 public void TestHotTrack ()
420 brush = (SolidBrush) SystemBrushes.HotTrack;
421 Assert ("P14#1", brush.Color.IsSystemColor);
422 AssertEquals ("P14#2", SystemColors.HotTrack, brush.Color);
425 brush.Color = Color.Red;
426 Fail ("P14#3: must throw ArgumentException");
427 } catch (Exception e) {
428 Assert ("P14#3", e is ArgumentException);
432 brush.Color = SystemColors.HotTrack;
433 Fail ("P14#4: must throw ArgumentException");
434 } catch (Exception e) {
435 Assert ("P14#4", e is ArgumentException);
440 Fail ("P14#5: must throw ArgumentException");
441 } catch (Exception e) {
442 Assert ("P14#5", e is ArgumentException);
447 public void TestInactiveBorder ()
450 brush = (SolidBrush) SystemBrushes.InactiveBorder;
451 Assert ("P15#1", brush.Color.IsSystemColor);
452 AssertEquals ("P15#2", SystemColors.InactiveBorder, brush.Color);
455 brush.Color = Color.Red;
456 Fail ("P15#3: must throw ArgumentException");
457 } catch (Exception e) {
458 Assert ("P15#3", e is ArgumentException);
462 brush.Color = SystemColors.InactiveBorder;
463 Fail ("P15#4: must throw ArgumentException");
464 } catch (Exception e) {
465 Assert ("P15#4", e is ArgumentException);
470 Fail ("P15#5: must throw ArgumentException");
471 } catch (Exception e) {
472 Assert ("P15#5", e is ArgumentException);
477 public void TestInactiveCaption ()
480 brush = (SolidBrush) SystemBrushes.InactiveCaption;
481 Assert ("P16#1", brush.Color.IsSystemColor);
482 AssertEquals ("P16#2", SystemColors.InactiveCaption, brush.Color);
485 brush.Color = Color.Red;
486 Fail ("P16#3: must throw ArgumentException");
487 } catch (Exception e) {
488 Assert ("P16#3", e is ArgumentException);
492 brush.Color = SystemColors.InactiveCaption;
493 Fail ("P16#4: must throw ArgumentException");
494 } catch (Exception e) {
495 Assert ("P16#4", e is ArgumentException);
500 Fail ("P16#5: must throw ArgumentException");
501 } catch (Exception e) {
502 Assert ("P16#5", e is ArgumentException);
507 public void TestInfo ()
510 brush = (SolidBrush) SystemBrushes.Info;
511 Assert ("P17#1", brush.Color.IsSystemColor);
512 AssertEquals ("P17#2", SystemColors.Info, brush.Color);
515 brush.Color = Color.Red;
516 Fail ("P17#3: must throw ArgumentException");
517 } catch (Exception e) {
518 Assert ("P17#3", e is ArgumentException);
522 brush.Color = SystemColors.Info;
523 Fail ("P17#4: must throw ArgumentException");
524 } catch (Exception e) {
525 Assert ("P17#4", e is ArgumentException);
530 Fail ("P17#5: must throw ArgumentException");
531 } catch (Exception e) {
532 Assert ("P17#5", e is ArgumentException);
537 public void TestMenu ()
540 brush = (SolidBrush) SystemBrushes.Menu;
541 Assert ("P18#1", brush.Color.IsSystemColor);
542 AssertEquals ("P18#2", SystemColors.Menu, brush.Color);
545 brush.Color = Color.Red;
546 Fail ("P18#3: must throw ArgumentException");
547 } catch (Exception e) {
548 Assert ("P18#3", e is ArgumentException);
552 brush.Color = SystemColors.Menu;
553 Fail ("P18#4: must throw ArgumentException");
554 } catch (Exception e) {
555 Assert ("P18#4", e is ArgumentException);
560 Fail ("P18#5: must throw ArgumentException");
561 } catch (Exception e) {
562 Assert ("P18#5", e is ArgumentException);
567 public void TestScrollBar ()
570 brush = (SolidBrush) SystemBrushes.ScrollBar;
571 Assert ("P19#1", brush.Color.IsSystemColor);
572 AssertEquals ("P19#2", SystemColors.ScrollBar, brush.Color);
575 brush.Color = Color.Red;
576 Fail ("P19#3: must throw ArgumentException");
577 } catch (Exception e) {
578 Assert ("P19#3", e is ArgumentException);
582 brush.Color = SystemColors.ScrollBar;
583 Fail ("P19#4: must throw ArgumentException");
584 } catch (Exception e) {
585 Assert ("P19#4", e is ArgumentException);
590 Fail ("P19#5: must throw ArgumentException");
591 } catch (Exception e) {
592 Assert ("P19#5", e is ArgumentException);
597 public void TestWindow ()
600 brush = (SolidBrush) SystemBrushes.Window;
601 Assert ("P20#1", brush.Color.IsSystemColor);
602 AssertEquals ("P20#2", SystemColors.Window, brush.Color);
605 brush.Color = Color.Red;
606 Fail ("P20#3: must throw ArgumentException");
607 } catch (Exception e) {
608 Assert ("P20#3", e is ArgumentException);
612 brush.Color = SystemColors.Window;
613 Fail ("P20#4: must throw ArgumentException");
614 } catch (Exception e) {
615 Assert ("P20#4", e is ArgumentException);
620 Fail ("P20#5: must throw ArgumentException");
621 } catch (Exception e) {
622 Assert ("P20#5", e is ArgumentException);
627 public void TestWindowText ()
630 brush = (SolidBrush) SystemBrushes.WindowText;
631 Assert ("P21#1", brush.Color.IsSystemColor);
632 AssertEquals ("P21#2", SystemColors.WindowText, brush.Color);
635 brush.Color = Color.Red;
636 Fail ("P21#3: must throw ArgumentException");
637 } catch (Exception e) {
638 Assert ("P21#3", e is ArgumentException);
642 brush.Color = SystemColors.WindowText;
643 Fail ("P21#4: must throw ArgumentException");
644 } catch (Exception e) {
645 Assert ("P21#4", e is ArgumentException);
650 Fail ("P21#5: must throw ArgumentException");
651 } catch (Exception e) {
652 Assert ("P21#5", e is ArgumentException);
657 public void TestFromSystemColor ()
661 brush = (SolidBrush) SystemBrushes.FromSystemColor (SystemColors.Menu);
662 AssertEquals ("M1#1", SystemColors.Menu, brush.Color);
665 brush.Color = Color.Red;
666 Fail ("M1#2: must throw ArgumentException");
667 } catch (Exception e) {
668 Assert ("M1#2", e is ArgumentException);
672 brush.Color = SystemColors.Menu;
673 Fail ("M1#3: must throw ArgumentException");
674 } catch (Exception e) {
675 Assert ("M1#3", e is ArgumentException);
680 Fail ("M1#4: must throw ArgumentException");
681 } catch (Exception e) {
682 Assert ("M1#4", e is ArgumentException);
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);