1 // Tests for System.Drawing.SystemBrushes.cs
3 // Author: Ravindra (rkumar@novell.com)
7 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
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:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
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.
30 using NUnit.Framework;
33 using System.Security.Permissions;
35 namespace MonoTests.System.Drawing
38 [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
39 public class SystemBrushesTest : Assertion
42 public void TearDown () {}
45 public void SetUp () {}
48 public void TestActiveBorder ()
51 brush = (SolidBrush) SystemBrushes.ActiveBorder;
52 Assert ("P1#1", brush.Color.IsSystemColor);
53 AssertEquals ("P1#2", SystemColors.ActiveBorder, brush.Color);
56 brush.Color = Color.Red;
57 Fail ("P1#3: must throw ArgumentException");
58 } catch (ArgumentException) {
59 Assert ("P1#3", true);
63 brush.Color = SystemColors.ActiveBorder;
64 Fail ("P1#4: must throw ArgumentException");
65 } catch (ArgumentException) {
66 Assert ("P1#4", true);
71 Fail ("P1#5: must throw ArgumentException");
72 } catch (ArgumentException) {
73 Assert ("P1#5", true);
78 public void TestActiveCaption ()
81 brush = (SolidBrush) SystemBrushes.ActiveCaption;
82 Assert ("P2#1", brush.Color.IsSystemColor);
83 AssertEquals ("P2#2", SystemColors.ActiveCaption, brush.Color);
86 brush.Color = Color.Red;
87 Fail ("P2#3: must throw ArgumentException");
88 } catch (Exception e) {
89 Assert ("P2#3", e is ArgumentException);
93 brush.Color = SystemColors.ActiveCaption;
94 Fail ("P2#4: must throw ArgumentException");
95 } catch (Exception e) {
96 Assert ("P2#4", e is ArgumentException);
101 Fail ("P2#5: must throw ArgumentException");
102 } catch (Exception e) {
103 Assert ("P2#5", e is ArgumentException);
109 public void TestActiveCaptionText ()
112 brush = (SolidBrush) SystemBrushes.ActiveCaptionText;
113 Assert ("P3#1", brush.Color.IsSystemColor);
114 AssertEquals ("P3#2", SystemColors.ActiveCaptionText, brush.Color);
117 brush.Color = Color.Red;
118 Fail ("P3#3: must throw ArgumentException");
119 } catch (Exception e) {
120 Assert ("P3#3", e is ArgumentException);
124 brush.Color = SystemColors.ActiveCaptionText;
125 Fail ("P3#4: must throw ArgumentException");
126 } catch (Exception e) {
127 Assert ("P3#4", e is ArgumentException);
132 Fail ("P3#5: must throw ArgumentException");
133 } catch (Exception e) {
134 Assert ("P3#5", e is ArgumentException);
139 public void TestAppWorkspace ()
142 brush = (SolidBrush) SystemBrushes.AppWorkspace;
143 Assert ("P4#1", brush.Color.IsSystemColor);
144 AssertEquals ("P4#2", SystemColors.AppWorkspace, brush.Color);
147 brush.Color = Color.Red;
148 Fail ("P4#3: must throw ArgumentException");
149 } catch (Exception e) {
150 Assert ("P4#3", e is ArgumentException);
154 brush.Color = SystemColors.AppWorkspace;
155 Fail ("P4#4: must throw ArgumentException");
156 } catch (Exception e) {
157 Assert ("P4#4", e is ArgumentException);
162 Fail ("P4#5: must throw ArgumentException");
163 } catch (Exception e) {
164 Assert ("P4#5", e is ArgumentException);
169 public void TestControl ()
172 brush = (SolidBrush) SystemBrushes.Control;
173 Assert ("P5#1", brush.Color.IsSystemColor);
174 AssertEquals ("P5#2", SystemColors.Control, brush.Color);
177 brush.Color = Color.Red;
178 Fail ("P5#3: must throw ArgumentException");
179 } catch (Exception e) {
180 Assert ("P5#3", e is ArgumentException);
184 brush.Color = SystemColors.Control;
185 Fail ("P5#4: must throw ArgumentException");
186 } catch (Exception e) {
187 Assert ("P5#4", e is ArgumentException);
192 Fail ("P5#5: must throw ArgumentException");
193 } catch (Exception e) {
194 Assert ("P5#5", e is ArgumentException);
200 public void TestControlDark ()
203 brush = (SolidBrush) SystemBrushes.ControlDark;
204 Assert ("P6#1", brush.Color.IsSystemColor);
205 AssertEquals ("P6#2", SystemColors.ControlDark, brush.Color);
208 brush.Color = Color.Red;
209 Fail ("P6#3: must throw ArgumentException");
210 } catch (Exception e) {
211 Assert ("P6#3", e is ArgumentException);
215 brush.Color = SystemColors.ControlDark;
216 Fail ("P6#4: must throw ArgumentException");
217 } catch (Exception e) {
218 Assert ("P6#4", e is ArgumentException);
223 Fail ("P6#5: must throw ArgumentException");
224 } catch (Exception e) {
225 Assert ("P6#5", e is ArgumentException);
230 public void TestControlDarkDark ()
233 brush = (SolidBrush) SystemBrushes.ControlDarkDark;
234 Assert ("P7#1", brush.Color.IsSystemColor);
235 AssertEquals ("P7#2", SystemColors.ControlDarkDark, brush.Color);
238 brush.Color = Color.Red;
239 Fail ("P7#3: must throw ArgumentException");
240 } catch (Exception e) {
241 Assert ("P7#3", e is ArgumentException);
245 brush.Color = SystemColors.ControlDarkDark;
246 Fail ("P7#4: must throw ArgumentException");
247 } catch (Exception e) {
248 Assert ("P7#4", e is ArgumentException);
253 Fail ("P7#5: must throw ArgumentException");
254 } catch (Exception e) {
255 Assert ("P7#5", e is ArgumentException);
260 public void TestControlLight ()
263 brush = (SolidBrush) SystemBrushes.ControlLight;
264 Assert ("P8#1", brush.Color.IsSystemColor);
265 AssertEquals ("P8#2", SystemColors.ControlLight, brush.Color);
268 brush.Color = Color.Red;
269 Fail ("P8#3: must throw ArgumentException");
270 } catch (Exception e) {
271 Assert ("P8#3", e is ArgumentException);
275 brush.Color = SystemColors.ControlLight;
276 Fail ("P8#4: must throw ArgumentException");
277 } catch (Exception e) {
278 Assert ("P8#4", e is ArgumentException);
283 Fail ("P8#5: must throw ArgumentException");
284 } catch (Exception e) {
285 Assert ("P8#5", e is ArgumentException);
290 public void TestControlLightLight ()
293 brush = (SolidBrush) SystemBrushes.ControlLightLight;
294 Assert ("P9#1", brush.Color.IsSystemColor);
295 AssertEquals ("P9#2", SystemColors.ControlLightLight, brush.Color);
298 brush.Color = Color.Red;
299 Fail ("P9#3: must throw ArgumentException");
300 } catch (Exception e) {
301 Assert ("P9#3", e is ArgumentException);
305 brush.Color = SystemColors.ControlLightLight;
306 Fail ("P9#4: must throw ArgumentException");
307 } catch (Exception e) {
308 Assert ("P9#4", e is ArgumentException);
313 Fail ("P9#5: must throw ArgumentException");
314 } catch (Exception e) {
315 Assert ("P9#5", e is ArgumentException);
320 public void TestControlText ()
323 brush = (SolidBrush) SystemBrushes.ControlText;
324 Assert ("P10#1", brush.Color.IsSystemColor);
325 AssertEquals ("P10#2", SystemColors.ControlText, brush.Color);
328 brush.Color = Color.Red;
329 Fail ("P10#3: must throw ArgumentException");
330 } catch (Exception e) {
331 Assert ("P10#3", e is ArgumentException);
335 brush.Color = SystemColors.ControlText;
336 Fail ("P10#4: must throw ArgumentException");
337 } catch (Exception e) {
338 Assert ("P10#4", e is ArgumentException);
343 Fail ("P10#5: must throw ArgumentException");
344 } catch (Exception e) {
345 Assert ("P10#5", e is ArgumentException);
351 public void TestDesktop ()
354 brush = (SolidBrush) SystemBrushes.Desktop;
355 Assert ("P11#1", brush.Color.IsSystemColor);
356 AssertEquals ("P11#2", SystemColors.Desktop, brush.Color);
359 brush.Color = Color.Red;
360 Fail ("P11#3: must throw ArgumentException");
361 } catch (Exception e) {
362 Assert ("P11#3", e is ArgumentException);
366 brush.Color = SystemColors.Desktop;
367 Fail ("P11#4: must throw ArgumentException");
368 } catch (Exception e) {
369 Assert ("P11#4", e is ArgumentException);
374 Fail ("P11#5: must throw ArgumentException");
375 } catch (Exception e) {
376 Assert ("P11#5", e is ArgumentException);
381 public void TestHighlight ()
384 brush = (SolidBrush) SystemBrushes.Highlight;
385 Assert ("P12#1", brush.Color.IsSystemColor);
386 AssertEquals ("P12#2", SystemColors.Highlight, brush.Color);
389 brush.Color = Color.Red;
390 Fail ("P12#3: must throw ArgumentException");
391 } catch (Exception e) {
392 Assert ("P12#3", e is ArgumentException);
396 brush.Color = SystemColors.Highlight;
397 Fail ("P12#4: must throw ArgumentException");
398 } catch (Exception e) {
399 Assert ("P12#4", e is ArgumentException);
404 Fail ("P12#5: must throw ArgumentException");
405 } catch (Exception e) {
406 Assert ("P12#5", e is ArgumentException);
411 public void TestHighlightText ()
414 brush = (SolidBrush) SystemBrushes.HighlightText;
415 Assert ("P13#1", brush.Color.IsSystemColor);
416 AssertEquals ("P13#2", SystemColors.HighlightText, brush.Color);
419 brush.Color = Color.Red;
420 Fail ("P13#3: must throw ArgumentException");
421 } catch (Exception e) {
422 Assert ("P13#3", e is ArgumentException);
426 brush.Color = SystemColors.HighlightText;
427 Fail ("P13#4: must throw ArgumentException");
428 } catch (Exception e) {
429 Assert ("P13#4", e is ArgumentException);
434 Fail ("P13#5: must throw ArgumentException");
435 } catch (Exception e) {
436 Assert ("P13#5", e is ArgumentException);
441 public void TestHotTrack ()
444 brush = (SolidBrush) SystemBrushes.HotTrack;
445 Assert ("P14#1", brush.Color.IsSystemColor);
446 AssertEquals ("P14#2", SystemColors.HotTrack, brush.Color);
449 brush.Color = Color.Red;
450 Fail ("P14#3: must throw ArgumentException");
451 } catch (Exception e) {
452 Assert ("P14#3", e is ArgumentException);
456 brush.Color = SystemColors.HotTrack;
457 Fail ("P14#4: must throw ArgumentException");
458 } catch (Exception e) {
459 Assert ("P14#4", e is ArgumentException);
464 Fail ("P14#5: must throw ArgumentException");
465 } catch (Exception e) {
466 Assert ("P14#5", e is ArgumentException);
471 public void TestInactiveBorder ()
474 brush = (SolidBrush) SystemBrushes.InactiveBorder;
475 Assert ("P15#1", brush.Color.IsSystemColor);
476 AssertEquals ("P15#2", SystemColors.InactiveBorder, brush.Color);
479 brush.Color = Color.Red;
480 Fail ("P15#3: must throw ArgumentException");
481 } catch (Exception e) {
482 Assert ("P15#3", e is ArgumentException);
486 brush.Color = SystemColors.InactiveBorder;
487 Fail ("P15#4: must throw ArgumentException");
488 } catch (Exception e) {
489 Assert ("P15#4", e is ArgumentException);
494 Fail ("P15#5: must throw ArgumentException");
495 } catch (Exception e) {
496 Assert ("P15#5", e is ArgumentException);
501 public void TestInactiveCaption ()
504 brush = (SolidBrush) SystemBrushes.InactiveCaption;
505 Assert ("P16#1", brush.Color.IsSystemColor);
506 AssertEquals ("P16#2", SystemColors.InactiveCaption, brush.Color);
509 brush.Color = Color.Red;
510 Fail ("P16#3: must throw ArgumentException");
511 } catch (Exception e) {
512 Assert ("P16#3", e is ArgumentException);
516 brush.Color = SystemColors.InactiveCaption;
517 Fail ("P16#4: must throw ArgumentException");
518 } catch (Exception e) {
519 Assert ("P16#4", e is ArgumentException);
524 Fail ("P16#5: must throw ArgumentException");
525 } catch (Exception e) {
526 Assert ("P16#5", e is ArgumentException);
531 public void TestInfo ()
534 brush = (SolidBrush) SystemBrushes.Info;
535 Assert ("P17#1", brush.Color.IsSystemColor);
536 AssertEquals ("P17#2", SystemColors.Info, brush.Color);
539 brush.Color = Color.Red;
540 Fail ("P17#3: must throw ArgumentException");
541 } catch (Exception e) {
542 Assert ("P17#3", e is ArgumentException);
546 brush.Color = SystemColors.Info;
547 Fail ("P17#4: must throw ArgumentException");
548 } catch (Exception e) {
549 Assert ("P17#4", e is ArgumentException);
554 Fail ("P17#5: must throw ArgumentException");
555 } catch (Exception e) {
556 Assert ("P17#5", e is ArgumentException);
561 public void TestMenu ()
564 brush = (SolidBrush) SystemBrushes.Menu;
565 Assert ("P18#1", brush.Color.IsSystemColor);
566 AssertEquals ("P18#2", SystemColors.Menu, brush.Color);
569 brush.Color = Color.Red;
570 Fail ("P18#3: must throw ArgumentException");
571 } catch (Exception e) {
572 Assert ("P18#3", e is ArgumentException);
576 brush.Color = SystemColors.Menu;
577 Fail ("P18#4: must throw ArgumentException");
578 } catch (Exception e) {
579 Assert ("P18#4", e is ArgumentException);
584 Fail ("P18#5: must throw ArgumentException");
585 } catch (Exception e) {
586 Assert ("P18#5", e is ArgumentException);
591 public void TestScrollBar ()
594 brush = (SolidBrush) SystemBrushes.ScrollBar;
595 Assert ("P19#1", brush.Color.IsSystemColor);
596 AssertEquals ("P19#2", SystemColors.ScrollBar, brush.Color);
599 brush.Color = Color.Red;
600 Fail ("P19#3: must throw ArgumentException");
601 } catch (Exception e) {
602 Assert ("P19#3", e is ArgumentException);
606 brush.Color = SystemColors.ScrollBar;
607 Fail ("P19#4: must throw ArgumentException");
608 } catch (Exception e) {
609 Assert ("P19#4", e is ArgumentException);
614 Fail ("P19#5: must throw ArgumentException");
615 } catch (Exception e) {
616 Assert ("P19#5", e is ArgumentException);
621 public void TestWindow ()
624 brush = (SolidBrush) SystemBrushes.Window;
625 Assert ("P20#1", brush.Color.IsSystemColor);
626 AssertEquals ("P20#2", SystemColors.Window, brush.Color);
629 brush.Color = Color.Red;
630 Fail ("P20#3: must throw ArgumentException");
631 } catch (Exception e) {
632 Assert ("P20#3", e is ArgumentException);
636 brush.Color = SystemColors.Window;
637 Fail ("P20#4: must throw ArgumentException");
638 } catch (Exception e) {
639 Assert ("P20#4", e is ArgumentException);
644 Fail ("P20#5: must throw ArgumentException");
645 } catch (Exception e) {
646 Assert ("P20#5", e is ArgumentException);
651 public void TestWindowText ()
654 brush = (SolidBrush) SystemBrushes.WindowText;
655 Assert ("P21#1", brush.Color.IsSystemColor);
656 AssertEquals ("P21#2", SystemColors.WindowText, brush.Color);
659 brush.Color = Color.Red;
660 Fail ("P21#3: must throw ArgumentException");
661 } catch (Exception e) {
662 Assert ("P21#3", e is ArgumentException);
666 brush.Color = SystemColors.WindowText;
667 Fail ("P21#4: must throw ArgumentException");
668 } catch (Exception e) {
669 Assert ("P21#4", e is ArgumentException);
674 Fail ("P21#5: must throw ArgumentException");
675 } catch (Exception e) {
676 Assert ("P21#5", e is ArgumentException);
681 public void TestFromSystemColor ()
685 brush = (SolidBrush) SystemBrushes.FromSystemColor (SystemColors.Menu);
686 AssertEquals ("M1#1", SystemColors.Menu, brush.Color);
689 brush.Color = Color.Red;
690 Fail ("M1#2: must throw ArgumentException");
691 } catch (Exception e) {
692 Assert ("M1#2", e is ArgumentException);
696 brush.Color = SystemColors.Menu;
697 Fail ("M1#3: must throw ArgumentException");
698 } catch (Exception e) {
699 Assert ("M1#3", e is ArgumentException);
704 Fail ("M1#4: must throw ArgumentException");
705 } catch (Exception e) {
706 Assert ("M1#4", e is ArgumentException);
711 brush = (SolidBrush) SystemBrushes.FromSystemColor (Color.Red);
712 Fail ("M2#1: must throw ArgumentException");
713 } catch (Exception e) {
714 Assert ("M2#1", e is ArgumentException);