Author: spouliot
Date: 2006-05-30 15:01:40 -0400 (Tue, 30 May 2006)
New Revision: 61279

Added:
   trunk/mcs/class/System.Drawing/Test/System.Drawing/FontFamilyTest.cs
Modified:
   trunk/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog
   trunk/mcs/class/System.Drawing/Test/System.Drawing/TestFont.cs
Log:
2006-05-30  Sebastien Pouliot  <[EMAIL PROTECTED]>

        * FontFamilyTest.cs: New. Unit tests for FontFamily.
        * TestFont.cs: Added more test cases to Font.



Modified: trunk/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog
===================================================================
--- trunk/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog        
2006-05-30 18:59:37 UTC (rev 61278)
+++ trunk/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog        
2006-05-30 19:01:40 UTC (rev 61279)
@@ -1,3 +1,8 @@
+2006-05-30  Sebastien Pouliot  <[EMAIL PROTECTED]>
+
+       * FontFamilyTest.cs: New. Unit tests for FontFamily.
+       * TestFont.cs: Added more test cases to Font.
+
 2006-05-29  Sebastien Pouliot  <[EMAIL PROTECTED]>
 
        * TestImageFormatConverter.cs: Added test cases for all well known

Added: trunk/mcs/class/System.Drawing/Test/System.Drawing/FontFamilyTest.cs
===================================================================
--- trunk/mcs/class/System.Drawing/Test/System.Drawing/FontFamilyTest.cs        
2006-05-30 18:59:37 UTC (rev 61278)
+++ trunk/mcs/class/System.Drawing/Test/System.Drawing/FontFamilyTest.cs        
2006-05-30 19:01:40 UTC (rev 61279)
@@ -0,0 +1,212 @@
+//
+// System.Drawing.FontFamily unit tests
+//
+// Authors:
+//     Sebastien Pouliot  <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Text;
+using System.Security.Permissions;
+using NUnit.Framework;
+
+namespace MonoTests.System.Drawing {
+
+       [TestFixture]
+       [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+       public class FontFamilyTest {
+
+               private Bitmap bitmap;
+               private Graphics graphic;
+               private string name;
+
+               [TestFixtureSetUp]
+               public void FixtureSetUp ()
+               {
+                       bitmap = new Bitmap (10, 10);
+                       graphic = Graphics.FromImage (bitmap);
+                       using (FontFamily ff = new FontFamily 
(GenericFontFamilies.Monospace)) {
+                               name = ff.Name;
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void FontFamily_String_Null ()
+               {
+                       new FontFamily (null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               [Category ("NotWorking")] // libgdiplus/fontconfig always 
return something
+               public void FontFamily_String_Empty ()
+               {
+                       new FontFamily (String.Empty);
+               }
+
+               private void CheckMono (FontFamily ff)
+               {
+                       Assert.IsTrue (ff.Equals (FontFamily.GenericMonospace), 
"GenericMonospace");
+#if NET_2_0
+                       // note: Mono has this behaviour on both 1.1 and 2.0 
profiles
+                       Assert.AreEqual (ff.Name.GetHashCode (), ff.GetHashCode 
(), "GetHashCode");
+#endif
+               }
+
+               [Test]
+               public void FontFamily_String ()
+               {
+                       FontFamily ff = new FontFamily (name);
+                       CheckMono (ff);
+                       FontStyle style = FontStyle.Bold;
+                       Assert.AreEqual (ff.Name, ff.GetName (0), "GetName");
+                       Assert.IsTrue ((ff.GetCellAscent (style) > 0), 
"GetCellAscent");
+                       Assert.IsTrue ((ff.GetCellDescent (style) > 0), 
"GetCellDescent");
+                       Assert.IsTrue ((ff.GetEmHeight (style) > 0), 
"GetEmHeight");
+                       Assert.IsTrue ((ff.GetLineSpacing (style) > 0), 
"GetLineSpacing");
+                       Assert.IsTrue (ff.IsStyleAvailable (style), 
"IsStyleAvailable");
+               }
+
+               [Test]
+               public void FontFamily_String_FontCollection_Null ()
+               {
+                       FontFamily ff = new FontFamily (name, null);
+                       CheckMono (ff);
+               }
+
+               [Test]
+               public void FontFamily_String_InstalledFontCollection ()
+               {
+                       FontFamily ff = new FontFamily (name, new 
InstalledFontCollection ());
+                       CheckMono (ff);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void FontFamily_String_PrivateFontCollection ()
+               {
+                       new FontFamily (name, new PrivateFontCollection ());
+               }
+
+               [Test]
+               public void FontFamily_Monospace ()
+               {
+                       FontFamily ff = new FontFamily 
(GenericFontFamilies.Monospace);
+                       CheckMono (ff);
+               }
+
+               [Test]
+               public void FontFamily_SansSerif ()
+               {
+                       FontFamily ff = new FontFamily 
(GenericFontFamilies.SansSerif);
+                       Assert.IsTrue (ff.Equals (FontFamily.GenericSansSerif), 
"GenericSansSerif");
+#if NET_2_0
+                       // note: Mono has this behaviour on both 1.1 and 2.0 
profiles
+                       Assert.AreEqual (ff.Name.GetHashCode (), ff.GetHashCode 
(), "GetHashCode");
+#endif
+               }
+
+               [Test]
+               public void FontFamily_Serif ()
+               {
+                       FontFamily ff = new FontFamily 
(GenericFontFamilies.Serif);
+                       Assert.IsTrue (ff.Equals (FontFamily.GenericSerif), 
"GenericSerif");
+#if NET_2_0
+                       // note: Mono has this behaviour on both 1.1 and 2.0 
profiles
+                       Assert.AreEqual (ff.Name.GetHashCode (), ff.GetHashCode 
(), "GetHashCode");
+#endif
+               }
+
+               [Test]
+               public void FontFamily_Invalid ()
+               {
+                       FontFamily ff = new FontFamily 
((GenericFontFamilies)Int32.MinValue);
+                       // default to Monospace
+                       Assert.IsTrue (ff.Equals (FontFamily.GenericMonospace), 
"GenericMonospace");
+                       CheckMono (ff);
+               }
+
+               [Test]
+               public void GenericMonospace ()
+               {
+                       FontFamily ff = FontFamily.GenericMonospace;
+                       string ts = ff.ToString ();
+                       Assert.AreEqual ('[', ts[0], "[");
+                       Assert.IsTrue ((ts.IndexOf (name) >= 0), "ToString");
+                       Assert.AreEqual (']', ts[ts.Length - 1], "]");
+               }
+
+               [Test]
+               public void GenericSansSerif ()
+               {
+                       FontFamily ff = FontFamily.GenericSansSerif;
+                       string name = ff.Name;
+                       ff.Dispose ();
+                       Assert.AreEqual (name, 
FontFamily.GenericSansSerif.Name, "Name");
+               }
+
+               [Test]
+               public void GenericSerif ()
+               {
+                       FontFamily ff = FontFamily.GenericSerif;
+                       string name = ff.Name;
+                       ff.Dispose ();
+                       Assert.AreEqual (name, FontFamily.GenericSerif.Name, 
"Name");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void GetFamilies_Null ()
+               {
+                       FontFamily.GetFamilies (null);
+               }
+
+               [Test]
+               public void GetFamilies ()
+               {
+                       FontFamily[] ffc = FontFamily.GetFamilies (graphic);
+                       Assert.AreEqual (ffc.Length, 
FontFamily.Families.Length, "Length");
+               }
+
+               [Test]
+               public void Dispose_Double ()
+               {
+                       FontFamily ff = FontFamily.GenericSerif;
+                       ff.Dispose ();
+                       ff.Dispose ();
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void Dispose_UseAfter ()
+               {
+                       FontFamily ff = FontFamily.GenericMonospace;
+                       ff.Dispose ();
+                       Assert.AreEqual (name, ff.Name, "Name");
+               }
+       }
+}


Property changes on: 
trunk/mcs/class/System.Drawing/Test/System.Drawing/FontFamilyTest.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/mcs/class/System.Drawing/Test/System.Drawing/TestFont.cs
===================================================================
--- trunk/mcs/class/System.Drawing/Test/System.Drawing/TestFont.cs      
2006-05-30 18:59:37 UTC (rev 61278)
+++ trunk/mcs/class/System.Drawing/Test/System.Drawing/TestFont.cs      
2006-05-30 19:01:40 UTC (rev 61279)
@@ -31,7 +31,7 @@
 using NUnit.Framework;
 using System;
 using System.Drawing;
-using System.Drawing.Imaging;
+using System.Drawing.Text;
 using System.Security;
 using System.Security.Permissions;
 using System.Runtime.InteropServices;
@@ -40,7 +40,17 @@
 
        [TestFixture]
        public class FontTest {
-               
+
+               private string name;
+
+               [TestFixtureSetUp]
+               public void FixtureSetUp ()
+               {
+                       using (FontFamily ff = new FontFamily 
(GenericFontFamilies.Monospace)) {
+                               name = ff.Name;
+                       }
+               }
+
                // Test basic Font clone, properties and contructor
                [Test]
                [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
@@ -115,5 +125,268 @@
                        Assert.AreEqual (f.Name, lf.lfFaceName, "lfFaceName");
                }
 #endif
+               [Test]
+#if ONLY_1_1
+               [ExpectedException (typeof (ArgumentNullException))]
+#endif
+               public void Font_StringNull_Float ()
+               {
+                       string family = null;
+                       Font f = new Font (family, 12.5f);
+                       Assert.AreEqual (FontFamily.GenericSansSerif, 
f.FontFamily, "FontFamily");
+                       Assert.AreEqual (f.Name, f.FontFamily.Name, "Name");
+                       Assert.AreEqual (12.5f, f.Size, "Size");
+                       Assert.AreEqual (12.5f, f.SizeInPoints, "SizeInPoints");
+                       Assert.AreEqual (GraphicsUnit.Point, f.Unit, "Unit");
+               }
+
+               [Test]
+               public void Font_String_Float ()
+               {
+                       Font f = new Font (name, 12.5f);
+                       Assert.AreEqual (FontFamily.GenericMonospace, 
f.FontFamily, "FontFamily");
+                       Assert.IsFalse (f.Bold, "Bold");
+                       Assert.AreEqual (1, f.GdiCharSet, "GdiCharSet");
+                       Assert.IsFalse (f.GdiVerticalFont, "GdiVerticalFont");
+                       Assert.IsTrue (f.Height > 0, "Height");
+                       Assert.IsFalse (f.Italic, "Italic");
+                       Assert.AreEqual (f.Name, f.FontFamily.Name, "Name");
+                       Assert.AreEqual (12.5f, f.Size, "Size");
+                       Assert.AreEqual (12.5f, f.SizeInPoints, "SizeInPoints");
+                       Assert.IsFalse (f.Strikeout, "Strikeout");
+                       Assert.IsFalse (f.Underline, "Underline");
+                       Assert.AreEqual (GraphicsUnit.Point, f.Unit, "Unit");
+               }
+
+               [Test]
+               public void Font_String_Float_FontStyle ()
+               {
+                       Font f = new Font (name, 12.5f, FontStyle.Bold);
+                       Assert.AreEqual (FontFamily.GenericMonospace, 
f.FontFamily, "FontFamily");
+                       Assert.IsTrue (f.Bold, "Bold");
+                       Assert.AreEqual (1, f.GdiCharSet, "GdiCharSet");
+                       Assert.IsFalse (f.GdiVerticalFont, "GdiVerticalFont");
+                       Assert.IsTrue (f.Height > 0, "Height");
+                       Assert.IsFalse (f.Italic, "Italic");
+                       Assert.AreEqual (f.Name, f.FontFamily.Name, "Name");
+                       Assert.AreEqual (12.5f, f.Size, "Size");
+                       Assert.AreEqual (12.5f, f.SizeInPoints, "SizeInPoints");
+                       Assert.IsFalse (f.Strikeout, "Strikeout");
+                       Assert.IsFalse (f.Underline, "Underline");
+                       Assert.AreEqual (GraphicsUnit.Point, f.Unit, "Unit");
+               }
+
+               [Test]
+               public void Font_String_Float_FontStyle_GraphicsUnit ()
+               {
+                       Font f = new Font (name, 12.5f, FontStyle.Italic, 
GraphicsUnit.Pixel);
+                       Assert.IsFalse (f.Bold, "Bold");
+                       Assert.AreEqual (1, f.GdiCharSet, "GdiCharSet");
+                       Assert.IsFalse (f.GdiVerticalFont, "GdiVerticalFont");
+                       Assert.IsTrue (f.Height > 0, "Height");
+                       Assert.IsTrue (f.Italic, "Italic");
+                       Assert.AreEqual (FontFamily.GenericMonospace, 
f.FontFamily, "FontFamily");
+                       Assert.AreEqual (f.Name, f.FontFamily.Name, "Name");
+                       Assert.AreEqual (12.5f, f.Size, "Size");
+                       Assert.AreEqual (9.375f, f.SizeInPoints, 
"SizeInPoints");
+                       Assert.IsFalse (f.Strikeout, "Strikeout");
+                       Assert.IsFalse (f.Underline, "Underline");
+                       Assert.AreEqual (GraphicsUnit.Pixel, f.Unit, "Unit");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void Font_String_Float_FontStyle_GraphicsUnit_Display ()
+               {
+                       new Font (name, 12.5f, FontStyle.Italic, 
GraphicsUnit.Display);
+               }
+
+               [Test]
+               public void Font_String_Float_FontStyle_GraphicsUnit_Byte ()
+               {
+                       Font f = new Font (name, 12.5f, FontStyle.Strikeout, 
GraphicsUnit.Inch, Byte.MaxValue);
+                       Assert.IsFalse (f.Bold, "Bold");
+                       Assert.AreEqual (Byte.MaxValue, f.GdiCharSet, 
"GdiCharSet");
+                       Assert.IsFalse (f.GdiVerticalFont, "GdiVerticalFont");
+                       Assert.IsTrue (f.Height > 0, "Height");
+                       Assert.IsFalse (f.Italic, "Italic");
+                       Assert.AreEqual (FontFamily.GenericMonospace, 
f.FontFamily, "FontFamily");
+                       Assert.AreEqual (f.Name, f.FontFamily.Name, "Name");
+                       Assert.AreEqual (12.5f, f.Size, "Size");
+                       Assert.AreEqual (900f, f.SizeInPoints, "SizeInPoints");
+                       Assert.IsTrue (f.Strikeout, "Strikeout");
+                       Assert.IsFalse (f.Underline, "Underline");
+                       Assert.AreEqual (GraphicsUnit.Inch, f.Unit, "Unit");
+               }
+
+               [Test]
+               public void Font_String_Float_FontStyle_GraphicsUnit_Byte_Bool 
()
+               {
+                       Font f = new Font (name, 12.5f, FontStyle.Underline, 
GraphicsUnit.Document, Byte.MinValue, true);
+                       Assert.IsFalse (f.Bold, "Bold");
+                       Assert.AreEqual (Byte.MinValue, f.GdiCharSet, 
"GdiCharSet");
+                       Assert.IsTrue (f.GdiVerticalFont, "GdiVerticalFont");
+                       Assert.IsTrue (f.Height > 0, "Height");
+                       Assert.IsFalse (f.Italic, "Italic");
+                       Assert.AreEqual (FontFamily.GenericMonospace, 
f.FontFamily, "FontFamily");
+                       Assert.AreEqual (f.Name, f.FontFamily.Name, "Name");
+                       Assert.AreEqual (12.5f, f.Size, "Size");
+                       Assert.AreEqual (3f, f.SizeInPoints, "SizeInPoints");
+                       Assert.IsFalse (f.Strikeout, "Strikeout");
+                       Assert.IsTrue (f.Underline, "Underline");
+                       Assert.AreEqual (GraphicsUnit.Document, f.Unit, "Unit");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void Font_FontFamilyNull_Float ()
+               {
+                       FontFamily ff = null;
+                       new Font (ff, 12.5f);
+               }
+
+               [Test]
+               public void Font_FontFamily_Float ()
+               {
+                       Font f = new Font (FontFamily.GenericMonospace, 12.5f);
+                       Assert.AreEqual (FontFamily.GenericMonospace, 
f.FontFamily, "FontFamily");
+                       Assert.IsFalse (f.Bold, "Bold");
+                       Assert.AreEqual (1, f.GdiCharSet, "GdiCharSet");
+                       Assert.IsFalse (f.GdiVerticalFont, "GdiVerticalFont");
+                       Assert.IsTrue (f.Height > 0, "Height");
+                       Assert.IsFalse (f.Italic, "Italic");
+                       Assert.AreEqual (f.Name, f.FontFamily.Name, "Name");
+                       Assert.AreEqual (12.5f, f.Size, "Size");
+                       Assert.AreEqual (12.5f, f.SizeInPoints, "SizeInPoints");
+                       Assert.IsFalse (f.Strikeout, "Strikeout");
+                       Assert.IsFalse (f.Underline, "Underline");
+                       Assert.AreEqual (GraphicsUnit.Point, f.Unit, "Unit");
+               }
+
+               [Test]
+               public void Font_FontFamily_Float_FontStyle ()
+               {
+                       Font f = new Font (FontFamily.GenericMonospace, 12.5f, 
FontStyle.Bold);
+                       Assert.AreEqual (FontFamily.GenericMonospace, 
f.FontFamily, "FontFamily");
+                       Assert.IsTrue (f.Bold, "Bold");
+                       Assert.AreEqual (1, f.GdiCharSet, "GdiCharSet");
+                       Assert.IsFalse (f.GdiVerticalFont, "GdiVerticalFont");
+                       Assert.IsTrue (f.Height > 0, "Height");
+                       Assert.IsFalse (f.Italic, "Italic");
+                       Assert.AreEqual (f.Name, f.FontFamily.Name, "Name");
+                       Assert.AreEqual (12.5f, f.Size, "Size");
+                       Assert.AreEqual (12.5f, f.SizeInPoints, "SizeInPoints");
+                       Assert.IsFalse (f.Strikeout, "Strikeout");
+                       Assert.IsFalse (f.Underline, "Underline");
+                       Assert.AreEqual (GraphicsUnit.Point, f.Unit, "Unit");
+               }
+
+               [Test]
+               public void Font_FontFamily_Float_FontStyle_GraphicsUnit ()
+               {
+                       Font f = new Font (FontFamily.GenericMonospace, 12.5f, 
FontStyle.Italic, GraphicsUnit.Millimeter);
+                       Assert.IsFalse (f.Bold, "Bold");
+                       Assert.AreEqual (1, f.GdiCharSet, "GdiCharSet");
+                       Assert.IsFalse (f.GdiVerticalFont, "GdiVerticalFont");
+                       Assert.IsTrue (f.Height > 0, "Height");
+                       Assert.IsTrue (f.Italic, "Italic");
+                       Assert.AreEqual (FontFamily.GenericMonospace, 
f.FontFamily, "FontFamily");
+                       Assert.AreEqual (f.Name, f.FontFamily.Name, "Name");
+                       Assert.AreEqual (12.5f, f.Size, "Size");
+                       Assert.AreEqual (35.43307f, f.SizeInPoints, 
"SizeInPoints");
+                       Assert.IsFalse (f.Strikeout, "Strikeout");
+                       Assert.IsFalse (f.Underline, "Underline");
+                       Assert.AreEqual (GraphicsUnit.Millimeter, f.Unit, 
"Unit");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void 
Font_FontFamily_Float_FontStyle_GraphicsUnit_Display ()
+               {
+                       new Font (FontFamily.GenericMonospace, 12.5f, 
FontStyle.Italic, GraphicsUnit.Display);
+               }
+
+               [Test]
+               public void Font_FontFamily_Float_FontStyle_GraphicsUnit_Byte ()
+               {
+                       Font f = new Font (FontFamily.GenericMonospace, 12.5f, 
FontStyle.Strikeout, GraphicsUnit.Inch, Byte.MaxValue);
+                       Assert.IsFalse (f.Bold, "Bold");
+                       Assert.AreEqual (Byte.MaxValue, f.GdiCharSet, 
"GdiCharSet");
+                       Assert.IsFalse (f.GdiVerticalFont, "GdiVerticalFont");
+                       Assert.IsTrue (f.Height > 0, "Height");
+                       Assert.IsFalse (f.Italic, "Italic");
+                       Assert.AreEqual (FontFamily.GenericMonospace, 
f.FontFamily, "FontFamily");
+                       Assert.AreEqual (f.Name, f.FontFamily.Name, "Name");
+                       Assert.AreEqual (12.5f, f.Size, "Size");
+                       Assert.AreEqual (900f, f.SizeInPoints, "SizeInPoints");
+                       Assert.IsTrue (f.Strikeout, "Strikeout");
+                       Assert.IsFalse (f.Underline, "Underline");
+                       Assert.AreEqual (GraphicsUnit.Inch, f.Unit, "Unit");
+               }
+
+               [Test]
+               public void 
Font_FontFamily_Float_FontStyle_GraphicsUnit_Byte_Bool ()
+               {
+                       Font f = new Font (FontFamily.GenericMonospace, 12.5f, 
FontStyle.Underline, GraphicsUnit.Document, Byte.MinValue, true);
+                       Assert.IsFalse (f.Bold, "Bold");
+                       Assert.AreEqual (Byte.MinValue, f.GdiCharSet, 
"GdiCharSet");
+                       Assert.IsTrue (f.GdiVerticalFont, "GdiVerticalFont");
+                       Assert.IsTrue (f.Height > 0, "Height");
+                       Assert.IsFalse (f.Italic, "Italic");
+                       Assert.AreEqual (FontFamily.GenericMonospace, 
f.FontFamily, "FontFamily");
+                       Assert.AreEqual (f.Name, f.FontFamily.Name, "Name");
+                       Assert.AreEqual (12.5f, f.Size, "Size");
+                       Assert.AreEqual (3f, f.SizeInPoints, "SizeInPoints");
+                       Assert.IsFalse (f.Strikeout, "Strikeout");
+                       Assert.IsTrue (f.Underline, "Underline");
+                       Assert.AreEqual (GraphicsUnit.Document, f.Unit, "Unit");
+               }
+
+               [Test]
+               public void Dispose_Double ()
+               {
+                       Font f = new Font (name, 12.5f);
+                       f.Dispose ();
+                       f.Dispose ();
+               }
+
+               [Test]
+               public void Dispose_UseAfter_Works ()
+               {
+                       Font f = new Font (name, 12.5f);
+                       string fname = f.Name;
+                       f.Dispose ();
+                       // most properties don't throw, everything seems to be 
cached
+                       Assert.AreEqual (fname, f.Name, "Name");
+                       Assert.AreEqual (12.5f, f.Size, "Size");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void Dispose_Height ()
+               {
+                       Font f = new Font (name, 12.5f);
+                       f.Dispose ();
+                       Assert.AreEqual (0, f.Height, "Name");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void Dispose_ToLogFont ()
+               {
+                       Font f = new Font (name, 12.5f);
+                       f.Dispose ();
+                       LOGFONT lf = new LOGFONT();
+                       f.ToLogFont (lf);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void Dispose_ToHFont ()
+               {
+                       Font f = new Font (name, 12.5f);
+                       f.Dispose ();
+                       f.ToHfont ();
+               }
        }
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to