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;
34 namespace MonoTests.System.Drawing
37 public class SystemBrushesTest : Assertion
40 public void TearDown () {}
43 public void SetUp () {}
46 public void TestActiveBorder ()
49 brush = (SolidBrush) SystemBrushes.ActiveBorder;
50 Assert ("P1#1", brush.Color.IsSystemColor);
51 AssertEquals ("P1#2", SystemColors.ActiveBorder, brush.Color);
54 brush.Color = Color.Red;
55 Fail ("P1#3: must throw ArgumentException");
56 } catch (Exception e) {
57 Assert ("P1#3", e is ArgumentException);
61 brush.Color = SystemColors.ActiveBorder;
62 Fail ("P1#4: must throw ArgumentException");
63 } catch (Exception e) {
64 Assert ("P1#4", e is ArgumentException);
69 Fail ("P1#5: must throw ArgumentException");
70 } catch (Exception e) {
71 Assert ("P1#5", e is ArgumentException);
76 public void TestActiveCaption ()
79 brush = (SolidBrush) SystemBrushes.ActiveCaption;
80 Assert ("P2#1", brush.Color.IsSystemColor);
81 AssertEquals ("P2#2", SystemColors.ActiveCaption, brush.Color);
84 brush.Color = Color.Red;
85 Fail ("P2#3: must throw ArgumentException");
86 } catch (Exception e) {
87 Assert ("P2#3", e is ArgumentException);
91 brush.Color = SystemColors.ActiveCaption;
92 Fail ("P2#4: must throw ArgumentException");
93 } catch (Exception e) {
94 Assert ("P2#4", e is ArgumentException);
99 Fail ("P2#5: must throw ArgumentException");
100 } catch (Exception e) {
101 Assert ("P2#5", e is ArgumentException);
107 public void TestActiveCaptionText ()
110 brush = (SolidBrush) SystemBrushes.ActiveCaptionText;
111 Assert ("P3#1", brush.Color.IsSystemColor);
112 AssertEquals ("P3#2", SystemColors.ActiveCaptionText, brush.Color);
115 brush.Color = Color.Red;
116 Fail ("P3#3: must throw ArgumentException");
117 } catch (Exception e) {
118 Assert ("P3#3", e is ArgumentException);
122 brush.Color = SystemColors.ActiveCaptionText;
123 Fail ("P3#4: must throw ArgumentException");
124 } catch (Exception e) {
125 Assert ("P3#4", e is ArgumentException);
130 Fail ("P3#5: must throw ArgumentException");
131 } catch (Exception e) {
132 Assert ("P3#5", e is ArgumentException);
137 public void TestAppWorkspace ()
140 brush = (SolidBrush) SystemBrushes.AppWorkspace;
141 Assert ("P4#1", brush.Color.IsSystemColor);
142 AssertEquals ("P4#2", SystemColors.AppWorkspace, brush.Color);
145 brush.Color = Color.Red;
146 Fail ("P4#3: must throw ArgumentException");
147 } catch (Exception e) {
148 Assert ("P4#3", e is ArgumentException);
152 brush.Color = SystemColors.AppWorkspace;
153 Fail ("P4#4: must throw ArgumentException");
154 } catch (Exception e) {
155 Assert ("P4#4", e is ArgumentException);
160 Fail ("P4#5: must throw ArgumentException");
161 } catch (Exception e) {
162 Assert ("P4#5", e is ArgumentException);
167 public void TestControl ()
170 brush = (SolidBrush) SystemBrushes.Control;
171 Assert ("P5#1", brush.Color.IsSystemColor);
172 AssertEquals ("P5#2", SystemColors.Control, brush.Color);
175 brush.Color = Color.Red;
176 Fail ("P5#3: must throw ArgumentException");
177 } catch (Exception e) {
178 Assert ("P5#3", e is ArgumentException);
182 brush.Color = SystemColors.Control;
183 Fail ("P5#4: must throw ArgumentException");
184 } catch (Exception e) {
185 Assert ("P5#4", e is ArgumentException);
190 Fail ("P5#5: must throw ArgumentException");
191 } catch (Exception e) {
192 Assert ("P5#5", e is ArgumentException);
198 public void TestControlDark ()
201 brush = (SolidBrush) SystemBrushes.ControlDark;
202 Assert ("P6#1", brush.Color.IsSystemColor);
203 AssertEquals ("P6#2", SystemColors.ControlDark, brush.Color);
206 brush.Color = Color.Red;
207 Fail ("P6#3: must throw ArgumentException");
208 } catch (Exception e) {
209 Assert ("P6#3", e is ArgumentException);
213 brush.Color = SystemColors.ControlDark;
214 Fail ("P6#4: must throw ArgumentException");
215 } catch (Exception e) {
216 Assert ("P6#4", e is ArgumentException);
221 Fail ("P6#5: must throw ArgumentException");
222 } catch (Exception e) {
223 Assert ("P6#5", e is ArgumentException);
228 public void TestControlDarkDark ()
231 brush = (SolidBrush) SystemBrushes.ControlDarkDark;
232 Assert ("P7#1", brush.Color.IsSystemColor);
233 AssertEquals ("P7#2", SystemColors.ControlDarkDark, brush.Color);
236 brush.Color = Color.Red;
237 Fail ("P7#3: must throw ArgumentException");
238 } catch (Exception e) {
239 Assert ("P7#3", e is ArgumentException);
243 brush.Color = SystemColors.ControlDarkDark;
244 Fail ("P7#4: must throw ArgumentException");
245 } catch (Exception e) {
246 Assert ("P7#4", e is ArgumentException);
251 Fail ("P7#5: must throw ArgumentException");
252 } catch (Exception e) {
253 Assert ("P7#5", e is ArgumentException);
258 public void TestControlLight ()
261 brush = (SolidBrush) SystemBrushes.ControlLight;
262 Assert ("P8#1", brush.Color.IsSystemColor);
263 AssertEquals ("P8#2", SystemColors.ControlLight, brush.Color);
266 brush.Color = Color.Red;
267 Fail ("P8#3: must throw ArgumentException");
268 } catch (Exception e) {
269 Assert ("P8#3", e is ArgumentException);
273 brush.Color = SystemColors.ControlLight;
274 Fail ("P8#4: must throw ArgumentException");
275 } catch (Exception e) {
276 Assert ("P8#4", e is ArgumentException);
281 Fail ("P8#5: must throw ArgumentException");
282 } catch (Exception e) {
283 Assert ("P8#5", e is ArgumentException);
288 public void TestControlLightLight ()
291 brush = (SolidBrush) SystemBrushes.ControlLightLight;
292 Assert ("P9#1", brush.Color.IsSystemColor);
293 AssertEquals ("P9#2", SystemColors.ControlLightLight, brush.Color);
296 brush.Color = Color.Red;
297 Fail ("P9#3: must throw ArgumentException");
298 } catch (Exception e) {
299 Assert ("P9#3", e is ArgumentException);
303 brush.Color = SystemColors.ControlLightLight;
304 Fail ("P9#4: must throw ArgumentException");
305 } catch (Exception e) {
306 Assert ("P9#4", e is ArgumentException);
311 Fail ("P9#5: must throw ArgumentException");
312 } catch (Exception e) {
313 Assert ("P9#5", e is ArgumentException);
318 public void TestControlText ()
321 brush = (SolidBrush) SystemBrushes.ControlText;
322 Assert ("P10#1", brush.Color.IsSystemColor);
323 AssertEquals ("P10#2", SystemColors.ControlText, brush.Color);
326 brush.Color = Color.Red;
327 Fail ("P10#3: must throw ArgumentException");
328 } catch (Exception e) {
329 Assert ("P10#3", e is ArgumentException);
333 brush.Color = SystemColors.ControlText;
334 Fail ("P10#4: must throw ArgumentException");
335 } catch (Exception e) {
336 Assert ("P10#4", e is ArgumentException);
341 Fail ("P10#5: must throw ArgumentException");
342 } catch (Exception e) {
343 Assert ("P10#5", e is ArgumentException);
349 public void TestDesktop ()
352 brush = (SolidBrush) SystemBrushes.Desktop;
353 Assert ("P11#1", brush.Color.IsSystemColor);
354 AssertEquals ("P11#2", SystemColors.Desktop, brush.Color);
357 brush.Color = Color.Red;
358 Fail ("P11#3: must throw ArgumentException");
359 } catch (Exception e) {
360 Assert ("P11#3", e is ArgumentException);
364 brush.Color = SystemColors.Desktop;
365 Fail ("P11#4: must throw ArgumentException");
366 } catch (Exception e) {
367 Assert ("P11#4", e is ArgumentException);
372 Fail ("P11#5: must throw ArgumentException");
373 } catch (Exception e) {
374 Assert ("P11#5", e is ArgumentException);
379 public void TestHighlight ()
382 brush = (SolidBrush) SystemBrushes.Highlight;
383 Assert ("P12#1", brush.Color.IsSystemColor);
384 AssertEquals ("P12#2", SystemColors.Highlight, brush.Color);
387 brush.Color = Color.Red;
388 Fail ("P12#3: must throw ArgumentException");
389 } catch (Exception e) {
390 Assert ("P12#3", e is ArgumentException);
394 brush.Color = SystemColors.Highlight;
395 Fail ("P12#4: must throw ArgumentException");
396 } catch (Exception e) {
397 Assert ("P12#4", e is ArgumentException);
402 Fail ("P12#5: must throw ArgumentException");
403 } catch (Exception e) {
404 Assert ("P12#5", e is ArgumentException);
409 public void TestHighlightText ()
412 brush = (SolidBrush) SystemBrushes.HighlightText;
413 Assert ("P13#1", brush.Color.IsSystemColor);
414 AssertEquals ("P13#2", SystemColors.HighlightText, brush.Color);
417 brush.Color = Color.Red;
418 Fail ("P13#3: must throw ArgumentException");
419 } catch (Exception e) {
420 Assert ("P13#3", e is ArgumentException);
424 brush.Color = SystemColors.HighlightText;
425 Fail ("P13#4: must throw ArgumentException");
426 } catch (Exception e) {
427 Assert ("P13#4", e is ArgumentException);
432 Fail ("P13#5: must throw ArgumentException");
433 } catch (Exception e) {
434 Assert ("P13#5", e is ArgumentException);
439 public void TestHotTrack ()
442 brush = (SolidBrush) SystemBrushes.HotTrack;
443 Assert ("P14#1", brush.Color.IsSystemColor);
444 AssertEquals ("P14#2", SystemColors.HotTrack, brush.Color);
447 brush.Color = Color.Red;
448 Fail ("P14#3: must throw ArgumentException");
449 } catch (Exception e) {
450 Assert ("P14#3", e is ArgumentException);
454 brush.Color = SystemColors.HotTrack;
455 Fail ("P14#4: must throw ArgumentException");
456 } catch (Exception e) {
457 Assert ("P14#4", e is ArgumentException);
462 Fail ("P14#5: must throw ArgumentException");
463 } catch (Exception e) {
464 Assert ("P14#5", e is ArgumentException);
469 public void TestInactiveBorder ()
472 brush = (SolidBrush) SystemBrushes.InactiveBorder;
473 Assert ("P15#1", brush.Color.IsSystemColor);
474 AssertEquals ("P15#2", SystemColors.InactiveBorder, brush.Color);
477 brush.Color = Color.Red;
478 Fail ("P15#3: must throw ArgumentException");
479 } catch (Exception e) {
480 Assert ("P15#3", e is ArgumentException);
484 brush.Color = SystemColors.InactiveBorder;
485 Fail ("P15#4: must throw ArgumentException");
486 } catch (Exception e) {
487 Assert ("P15#4", e is ArgumentException);
492 Fail ("P15#5: must throw ArgumentException");
493 } catch (Exception e) {
494 Assert ("P15#5", e is ArgumentException);
499 public void TestInactiveCaption ()
502 brush = (SolidBrush) SystemBrushes.InactiveCaption;
503 Assert ("P16#1", brush.Color.IsSystemColor);
504 AssertEquals ("P16#2", SystemColors.InactiveCaption, brush.Color);
507 brush.Color = Color.Red;
508 Fail ("P16#3: must throw ArgumentException");
509 } catch (Exception e) {
510 Assert ("P16#3", e is ArgumentException);
514 brush.Color = SystemColors.InactiveCaption;
515 Fail ("P16#4: must throw ArgumentException");
516 } catch (Exception e) {
517 Assert ("P16#4", e is ArgumentException);
522 Fail ("P16#5: must throw ArgumentException");
523 } catch (Exception e) {
524 Assert ("P16#5", e is ArgumentException);
529 public void TestInfo ()
532 brush = (SolidBrush) SystemBrushes.Info;
533 Assert ("P17#1", brush.Color.IsSystemColor);
534 AssertEquals ("P17#2", SystemColors.Info, brush.Color);
537 brush.Color = Color.Red;
538 Fail ("P17#3: must throw ArgumentException");
539 } catch (Exception e) {
540 Assert ("P17#3", e is ArgumentException);
544 brush.Color = SystemColors.Info;
545 Fail ("P17#4: must throw ArgumentException");
546 } catch (Exception e) {
547 Assert ("P17#4", e is ArgumentException);
552 Fail ("P17#5: must throw ArgumentException");
553 } catch (Exception e) {
554 Assert ("P17#5", e is ArgumentException);
559 public void TestMenu ()
562 brush = (SolidBrush) SystemBrushes.Menu;
563 Assert ("P18#1", brush.Color.IsSystemColor);
564 AssertEquals ("P18#2", SystemColors.Menu, brush.Color);
567 brush.Color = Color.Red;
568 Fail ("P18#3: must throw ArgumentException");
569 } catch (Exception e) {
570 Assert ("P18#3", e is ArgumentException);
574 brush.Color = SystemColors.Menu;
575 Fail ("P18#4: must throw ArgumentException");
576 } catch (Exception e) {
577 Assert ("P18#4", e is ArgumentException);
582 Fail ("P18#5: must throw ArgumentException");
583 } catch (Exception e) {
584 Assert ("P18#5", e is ArgumentException);
589 public void TestScrollBar ()
592 brush = (SolidBrush) SystemBrushes.ScrollBar;
593 Assert ("P19#1", brush.Color.IsSystemColor);
594 AssertEquals ("P19#2", SystemColors.ScrollBar, brush.Color);
597 brush.Color = Color.Red;
598 Fail ("P19#3: must throw ArgumentException");
599 } catch (Exception e) {
600 Assert ("P19#3", e is ArgumentException);
604 brush.Color = SystemColors.ScrollBar;
605 Fail ("P19#4: must throw ArgumentException");
606 } catch (Exception e) {
607 Assert ("P19#4", e is ArgumentException);
612 Fail ("P19#5: must throw ArgumentException");
613 } catch (Exception e) {
614 Assert ("P19#5", e is ArgumentException);
619 public void TestWindow ()
622 brush = (SolidBrush) SystemBrushes.Window;
623 Assert ("P20#1", brush.Color.IsSystemColor);
624 AssertEquals ("P20#2", SystemColors.Window, brush.Color);
627 brush.Color = Color.Red;
628 Fail ("P20#3: must throw ArgumentException");
629 } catch (Exception e) {
630 Assert ("P20#3", e is ArgumentException);
634 brush.Color = SystemColors.Window;
635 Fail ("P20#4: must throw ArgumentException");
636 } catch (Exception e) {
637 Assert ("P20#4", e is ArgumentException);
642 Fail ("P20#5: must throw ArgumentException");
643 } catch (Exception e) {
644 Assert ("P20#5", e is ArgumentException);
649 public void TestWindowText ()
652 brush = (SolidBrush) SystemBrushes.WindowText;
653 Assert ("P21#1", brush.Color.IsSystemColor);
654 AssertEquals ("P21#2", SystemColors.WindowText, brush.Color);
657 brush.Color = Color.Red;
658 Fail ("P21#3: must throw ArgumentException");
659 } catch (Exception e) {
660 Assert ("P21#3", e is ArgumentException);
664 brush.Color = SystemColors.WindowText;
665 Fail ("P21#4: must throw ArgumentException");
666 } catch (Exception e) {
667 Assert ("P21#4", e is ArgumentException);
672 Fail ("P21#5: must throw ArgumentException");
673 } catch (Exception e) {
674 Assert ("P21#5", e is ArgumentException);
679 public void TestFromSystemColor ()
683 brush = (SolidBrush) SystemBrushes.FromSystemColor (SystemColors.Menu);
684 AssertEquals ("M1#1", SystemColors.Menu, brush.Color);
687 brush.Color = Color.Red;
688 Fail ("M1#2: must throw ArgumentException");
689 } catch (Exception e) {
690 Assert ("M1#2", e is ArgumentException);
694 brush.Color = SystemColors.Menu;
695 Fail ("M1#3: must throw ArgumentException");
696 } catch (Exception e) {
697 Assert ("M1#3", e is ArgumentException);
702 Fail ("M1#4: must throw ArgumentException");
703 } catch (Exception e) {
704 Assert ("M1#4", e is ArgumentException);
709 brush = (SolidBrush) SystemBrushes.FromSystemColor (Color.Red);
710 Fail ("M2#1: must throw ArgumentException");
711 } catch (Exception e) {
712 Assert ("M2#1", e is ArgumentException);