2 // Tests for System.Drawing.SystemFontsTest
5 // Gert Driesen <drieseng@users.sourceforge.net>
6 // Sebastien Pouliot <sebastien@ximian.com>
8 // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com)
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 using NUnit.Framework;
37 namespace MonoTests.System.Drawing {
40 public class SystemFontsTest {
43 public void DefaultFont ()
45 Font f = SystemFonts.DefaultFont;
46 Assert.IsFalse (f.Bold, "#1");
48 Assert.AreEqual (true, f.IsSystemFont, "#3");
49 Assert.IsFalse (f.Italic, "#4");
50 Assert.AreEqual (8.25, f.Size, "#6");
51 Assert.AreEqual (8.25, f.SizeInPoints, "#7");
52 Assert.IsFalse (f.Strikeout, "#8");
53 Assert.IsFalse (f.Underline, "#9");
54 Assert.AreEqual (GraphicsUnit.Point, f.Unit, "#10");
58 [Category ("NotWorking")] // on Unix mapping is done to Bitstream Vera Sans
59 public void DefaultFont_Names ()
61 Font f = SystemFonts.DefaultFont;
62 Assert.AreEqual ("Microsoft Sans Serif", f.FontFamily.Name, "#1");
63 Assert.AreEqual ("Microsoft Sans Serif", f.Name, "#2");
67 public void SystemFontName ()
69 Assert.AreEqual ("CaptionFont", SystemFonts.CaptionFont.SystemFontName, "CaptionFont");
70 Assert.AreEqual ("DefaultFont", SystemFonts.DefaultFont.SystemFontName, "DefaultFont");
71 Assert.AreEqual ("DialogFont", SystemFonts.DialogFont.SystemFontName, "DialogFont");
72 Assert.AreEqual ("IconTitleFont", SystemFonts.IconTitleFont.SystemFontName, "IconTitleFont");
73 Assert.AreEqual ("MenuFont", SystemFonts.MenuFont.SystemFontName, "MenuFont");
74 Assert.AreEqual ("MessageBoxFont", SystemFonts.MessageBoxFont.SystemFontName, "MessageBoxFont");
75 Assert.AreEqual ("SmallCaptionFont", SystemFonts.SmallCaptionFont.SystemFontName, "SmallCaptionFont");
76 Assert.AreEqual ("StatusFont", SystemFonts.StatusFont.SystemFontName, "StatusFont");
80 public void GetFontByName ()
82 Assert.AreEqual ("CaptionFont", SystemFonts.GetFontByName ("CaptionFont").SystemFontName, "CaptionFont");
83 Assert.AreEqual ("DefaultFont", SystemFonts.GetFontByName ("DefaultFont").SystemFontName, "DefaultFont");
84 Assert.AreEqual ("DialogFont", SystemFonts.GetFontByName ("DialogFont").SystemFontName, "DialogFont");
85 Assert.AreEqual ("IconTitleFont", SystemFonts.GetFontByName ("IconTitleFont").SystemFontName, "IconTitleFont");
86 Assert.AreEqual ("MenuFont", SystemFonts.GetFontByName ("MenuFont").SystemFontName, "MenuFont");
87 Assert.AreEqual ("MessageBoxFont", SystemFonts.GetFontByName ("MessageBoxFont").SystemFontName, "MessageBoxFont");
88 Assert.AreEqual ("SmallCaptionFont", SystemFonts.GetFontByName ("SmallCaptionFont").SystemFontName, "SmallCaptionFont");
89 Assert.AreEqual ("StatusFont", SystemFonts.GetFontByName ("StatusFont").SystemFontName, "StatusFont");
93 public void GetFontByName_Invalid ()
95 Assert.IsNull (SystemFonts.GetFontByName (null), "null");
96 Assert.IsNull (SystemFonts.GetFontByName (String.Empty), "Empty");
97 Assert.IsNull (SystemFonts.GetFontByName ("defaultfont"), "lowercase");
98 Assert.IsNull (SystemFonts.GetFontByName ("DEFAULTFONT"), "UPPERCASE");
104 Font f1 = SystemFonts.CaptionFont;
105 Font f2 = SystemFonts.CaptionFont;
106 Assert.IsFalse (Object.ReferenceEquals (f1, f2), "property-property");
107 f2 = SystemFonts.GetFontByName ("CaptionFont");
108 Assert.IsFalse (Object.ReferenceEquals (f1, f2), "property-GetFontByName");
112 [ExpectedException (typeof (ArgumentException))]
113 public void Dispose_Instance ()
115 Font f1 = SystemFonts.CaptionFont;
116 float height = f1.GetHeight (72f);
122 public void Dispose_Property ()
124 float height = SystemFonts.CaptionFont.GetHeight (72f);
125 SystemFonts.CaptionFont.Dispose ();
126 Assert.AreEqual (height, SystemFonts.CaptionFont.GetHeight (72f), "height");