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
42 public void TearDown () {}
45 public void SetUp () {}
48 public void TestActiveBorder ()
51 brush = (SolidBrush) SystemBrushes.ActiveBorder;
52 Assert.IsTrue (brush.Color.IsSystemColor, "P1#1");
53 Assert.AreEqual (SystemColors.ActiveBorder, brush.Color, "P1#2");
56 brush.Color = Color.Red;
57 Assert.Fail ("P1#3: must throw ArgumentException");
58 } catch (ArgumentException) {
59 Assert.IsTrue (true, "P1#3");
63 brush.Color = SystemColors.ActiveBorder;
64 Assert.Fail ("P1#4: must throw ArgumentException");
65 } catch (ArgumentException) {
66 Assert.IsTrue (true, "P1#4");
71 Assert.Fail ("P1#5: must throw ArgumentException");
72 } catch (ArgumentException) {
73 Assert.IsTrue (true, "P1#5");
78 public void TestActiveCaption ()
81 brush = (SolidBrush) SystemBrushes.ActiveCaption;
82 Assert.IsTrue (brush.Color.IsSystemColor, "P2#1");
83 Assert.AreEqual (SystemColors.ActiveCaption, brush.Color, "P2#2");
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");
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");
101 Assert.Fail ("P2#5: must throw ArgumentException");
102 } catch (Exception e) {
103 Assert.IsTrue (e is ArgumentException, "P2#5");
109 public void TestActiveCaptionText ()
112 brush = (SolidBrush) SystemBrushes.ActiveCaptionText;
113 Assert.IsTrue (brush.Color.IsSystemColor, "P3#1");
114 Assert.AreEqual (SystemColors.ActiveCaptionText, brush.Color, "P3#2");
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");
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");
132 Assert.Fail ("P3#5: must throw ArgumentException");
133 } catch (Exception e) {
134 Assert.IsTrue (e is ArgumentException, "P3#5");
139 public void TestAppWorkspace ()
142 brush = (SolidBrush) SystemBrushes.AppWorkspace;
143 Assert.IsTrue (brush.Color.IsSystemColor, "P4#1");
144 Assert.AreEqual (SystemColors.AppWorkspace, brush.Color, "P4#2");
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");
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");
162 Assert.Fail ("P4#5: must throw ArgumentException");
163 } catch (Exception e) {
164 Assert.IsTrue (e is ArgumentException, "P4#5");
169 public void TestControl ()
172 brush = (SolidBrush) SystemBrushes.Control;
173 Assert.IsTrue (brush.Color.IsSystemColor, "P5#1");
174 Assert.AreEqual (SystemColors.Control, brush.Color, "P5#2");
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");
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");
192 Assert.Fail ("P5#5: must throw ArgumentException");
193 } catch (Exception e) {
194 Assert.IsTrue (e is ArgumentException, "P5#5");
200 public void TestControlDark ()
203 brush = (SolidBrush) SystemBrushes.ControlDark;
204 Assert.IsTrue (brush.Color.IsSystemColor, "P6#1");
205 Assert.AreEqual (SystemColors.ControlDark, brush.Color, "P6#2");
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");
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");
223 Assert.Fail ("P6#5: must throw ArgumentException");
224 } catch (Exception e) {
225 Assert.IsTrue (e is ArgumentException, "P6#5");
230 public void TestControlDarkDark ()
233 brush = (SolidBrush) SystemBrushes.ControlDarkDark;
234 Assert.IsTrue (brush.Color.IsSystemColor, "P7#1");
235 Assert.AreEqual (SystemColors.ControlDarkDark, brush.Color, "P7#2");
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");
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");
253 Assert.Fail ("P7#5: must throw ArgumentException");
254 } catch (Exception e) {
255 Assert.IsTrue (e is ArgumentException, "P7#5");
260 public void TestControlLight ()
263 brush = (SolidBrush) SystemBrushes.ControlLight;
264 Assert.IsTrue (brush.Color.IsSystemColor, "P8#1");
265 Assert.AreEqual (SystemColors.ControlLight, brush.Color, "P8#2");
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");
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");
283 Assert.Fail ("P8#5: must throw ArgumentException");
284 } catch (Exception e) {
285 Assert.IsTrue (e is ArgumentException, "P8#5");
290 public void TestControlLightLight ()
293 brush = (SolidBrush) SystemBrushes.ControlLightLight;
294 Assert.IsTrue (brush.Color.IsSystemColor, "P9#1");
295 Assert.AreEqual (SystemColors.ControlLightLight, brush.Color, "P9#2");
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");
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");
313 Assert.Fail ("P9#5: must throw ArgumentException");
314 } catch (Exception e) {
315 Assert.IsTrue (e is ArgumentException, "P9#5");
320 public void TestControlText ()
323 brush = (SolidBrush) SystemBrushes.ControlText;
324 Assert.IsTrue (brush.Color.IsSystemColor, "P10#1");
325 Assert.AreEqual (SystemColors.ControlText, brush.Color, "P10#2");
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");
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");
343 Assert.Fail ("P10#5: must throw ArgumentException");
344 } catch (Exception e) {
345 Assert.IsTrue (e is ArgumentException, "P10#5");
351 public void TestDesktop ()
354 brush = (SolidBrush) SystemBrushes.Desktop;
355 Assert.IsTrue (brush.Color.IsSystemColor, "P11#1");
356 Assert.AreEqual (SystemColors.Desktop, brush.Color, "P11#2");
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");
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");
374 Assert.Fail ("P11#5: must throw ArgumentException");
375 } catch (Exception e) {
376 Assert.IsTrue (e is ArgumentException, "P11#5");
381 public void TestHighlight ()
384 brush = (SolidBrush) SystemBrushes.Highlight;
385 Assert.IsTrue (brush.Color.IsSystemColor, "P12#1");
386 Assert.AreEqual (SystemColors.Highlight, brush.Color, "P12#2");
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");
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");
404 Assert.Fail ("P12#5: must throw ArgumentException");
405 } catch (Exception e) {
406 Assert.IsTrue (e is ArgumentException, "P12#5");
411 public void TestHighlightText ()
414 brush = (SolidBrush) SystemBrushes.HighlightText;
415 Assert.IsTrue (brush.Color.IsSystemColor, "P13#1");
416 Assert.AreEqual (SystemColors.HighlightText, brush.Color, "P13#2");
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");
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");
434 Assert.Fail ("P13#5: must throw ArgumentException");
435 } catch (Exception e) {
436 Assert.IsTrue (e is ArgumentException, "P13#5");
441 public void TestHotTrack ()
444 brush = (SolidBrush) SystemBrushes.HotTrack;
445 Assert.IsTrue (brush.Color.IsSystemColor, "P14#1");
446 Assert.AreEqual (SystemColors.HotTrack, brush.Color, "P14#2");
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");
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");
464 Assert.Fail ("P14#5: must throw ArgumentException");
465 } catch (Exception e) {
466 Assert.IsTrue (e is ArgumentException, "P14#5");
471 public void TestInactiveBorder ()
474 brush = (SolidBrush) SystemBrushes.InactiveBorder;
475 Assert.IsTrue (brush.Color.IsSystemColor, "P15#1");
476 Assert.AreEqual (SystemColors.InactiveBorder, brush.Color, "P15#2");
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");
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");
494 Assert.Fail ("P15#5: must throw ArgumentException");
495 } catch (Exception e) {
496 Assert.IsTrue (e is ArgumentException, "P15#5");
501 public void TestInactiveCaption ()
504 brush = (SolidBrush) SystemBrushes.InactiveCaption;
505 Assert.IsTrue (brush.Color.IsSystemColor, "P16#1");
506 Assert.AreEqual (SystemColors.InactiveCaption, brush.Color, "P16#2");
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");
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");
524 Assert.Fail ("P16#5: must throw ArgumentException");
525 } catch (Exception e) {
526 Assert.IsTrue (e is ArgumentException, "P16#5");
531 public void TestInfo ()
534 brush = (SolidBrush) SystemBrushes.Info;
535 Assert.IsTrue (brush.Color.IsSystemColor, "P17#1");
536 Assert.AreEqual (SystemColors.Info, brush.Color, "P17#2");
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");
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");
554 Assert.Fail ("P17#5: must throw ArgumentException");
555 } catch (Exception e) {
556 Assert.IsTrue (e is ArgumentException, "P17#5");
561 public void TestMenu ()
564 brush = (SolidBrush) SystemBrushes.Menu;
565 Assert.IsTrue (brush.Color.IsSystemColor, "P18#1");
566 Assert.AreEqual (SystemColors.Menu, brush.Color, "P18#2");
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");
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");
584 Assert.Fail ("P18#5: must throw ArgumentException");
585 } catch (Exception e) {
586 Assert.IsTrue (e is ArgumentException, "P18#5");
591 public void TestScrollBar ()
594 brush = (SolidBrush) SystemBrushes.ScrollBar;
595 Assert.IsTrue (brush.Color.IsSystemColor, "P19#1");
596 Assert.AreEqual (SystemColors.ScrollBar, brush.Color, "P19#2");
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");
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");
614 Assert.Fail ("P19#5: must throw ArgumentException");
615 } catch (Exception e) {
616 Assert.IsTrue (e is ArgumentException, "P19#5");
621 public void TestWindow ()
624 brush = (SolidBrush) SystemBrushes.Window;
625 Assert.IsTrue (brush.Color.IsSystemColor, "P20#1");
626 Assert.AreEqual (SystemColors.Window, brush.Color, "P20#2");
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");
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");
644 Assert.Fail ("P20#5: must throw ArgumentException");
645 } catch (Exception e) {
646 Assert.IsTrue (e is ArgumentException, "P20#5");
651 public void TestWindowText ()
654 brush = (SolidBrush) SystemBrushes.WindowText;
655 Assert.IsTrue (brush.Color.IsSystemColor, "P21#1");
656 Assert.AreEqual (SystemColors.WindowText, brush.Color, "P21#2");
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");
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");
674 Assert.Fail ("P21#5: must throw ArgumentException");
675 } catch (Exception e) {
676 Assert.IsTrue (e is ArgumentException, "P21#5");
681 public void TestFromSystemColor ()
685 brush = (SolidBrush) SystemBrushes.FromSystemColor (SystemColors.Menu);
686 Assert.AreEqual (SystemColors.Menu, brush.Color, "M1#1");
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");
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");
704 Assert.Fail ("M1#4: must throw ArgumentException");
705 } catch (Exception e) {
706 Assert.IsTrue (e is ArgumentException, "M1#4");
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");