X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem.Drawing%2FTest%2FSystem.Drawing%2FTestFont.cs;h=e1f3660f707e9689ef4ebbd09bbaaecdd32a8528;hb=d1be740678b8f7a411518f7489e74178ac0a726a;hp=5f854fab2e5da2a584298c6da3f2814e46b3ac70;hpb=811674bc6331c98d33134e2a37a7c7dd66402227;p=mono.git diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestFont.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestFont.cs index 5f854fab2e5..e1f3660f707 100644 --- a/mcs/class/System.Drawing/Test/System.Drawing/TestFont.cs +++ b/mcs/class/System.Drawing/Test/System.Drawing/TestFont.cs @@ -120,7 +120,6 @@ namespace MonoTests.System.Drawing{ [Test] [Category ("CAS")] - [ExpectedException (typeof (SecurityException))] [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)] public void ToLogFont_DenyUnmanagedCode () { @@ -130,7 +129,7 @@ namespace MonoTests.System.Drawing{ lf = new LOGFONT(); f = new Font("Arial", 10); - f.ToLogFont(lf); + Assert.Throws (() => f.ToLogFont(lf)); } [Test] @@ -167,12 +166,11 @@ namespace MonoTests.System.Drawing{ [Test] [SecurityPermission (SecurityAction.Assert, UnmanagedCode = true)] - [ExpectedException (typeof (ArgumentException))] public void ToLogFont_TooSmall () { Font f = new Font ("Arial", 10); object o = new object (); - f.ToLogFont (o); + Assert.Throws (() => f.ToLogFont (o)); // no PInvoke conversion exists !?!? } @@ -188,11 +186,10 @@ namespace MonoTests.System.Drawing{ [Test] [SecurityPermission (SecurityAction.Assert, UnmanagedCode = true)] - [ExpectedException (typeof (AccessViolationException))] public void ToLogFont_Null () { Font f = new Font ("Arial", 10); - f.ToLogFont (null); + Assert.Throws (() => f.ToLogFont (null)); } [Test] public void Font_StringNull_Float () @@ -260,10 +257,9 @@ namespace MonoTests.System.Drawing{ } [Test] - [ExpectedException (typeof (ArgumentException))] public void Font_String_Float_FontStyle_GraphicsUnit_Display () { - new Font (name, 12.5f, FontStyle.Italic, GraphicsUnit.Display); + Assert.Throws (() => new Font (name, 12.5f, FontStyle.Italic, GraphicsUnit.Display)); } [Test] @@ -303,19 +299,17 @@ namespace MonoTests.System.Drawing{ } [Test] - [ExpectedException (typeof (ArgumentNullException))] public void Font_FontFamilyNull_Float () { FontFamily ff = null; - new Font (ff, 12.5f); + Assert.Throws (() => new Font (ff, 12.5f)); } [Test] - [ExpectedException (typeof (NullReferenceException))] public void Font_FontNull_FontStyle () { Font f = null; - new Font (f, FontStyle.Bold); + Assert.Throws (() => new Font (f, FontStyle.Bold)); } [Test] @@ -373,10 +367,9 @@ namespace MonoTests.System.Drawing{ } [Test] - [ExpectedException (typeof (ArgumentException))] public void Font_FontFamily_Float_FontStyle_GraphicsUnit_Display () { - new Font (FontFamily.GenericMonospace, 12.5f, FontStyle.Italic, GraphicsUnit.Display); + Assert.Throws (() => new Font (FontFamily.GenericMonospace, 12.5f, FontStyle.Italic, GraphicsUnit.Display)); } [Test] @@ -435,22 +428,20 @@ namespace MonoTests.System.Drawing{ } [Test] - [ExpectedException (typeof (ArgumentException))] public void Dispose_Height () { Font f = new Font (name, 12.5f); f.Dispose (); - Assert.AreEqual (0, f.Height, "Name"); + Assert.Throws (() => { var x = f.Height; }); } [Test] - [ExpectedException (typeof (ArgumentException))] public void Dispose_ToLogFont () { Font f = new Font (name, 12.5f); f.Dispose (); LOGFONT lf = new LOGFONT(); - f.ToLogFont (lf); + Assert.Throws (() => f.ToLogFont (lf)); } [Test] @@ -503,22 +494,20 @@ namespace MonoTests.System.Drawing{ } [Test] - [ExpectedException (typeof (ArgumentException))] public void Dispose_ToHFont () { Font f = new Font (name, 12.5f); f.Dispose (); - f.ToHfont (); + Assert.Throws (() => f.ToHfont ()); } [Test] - [ExpectedException (typeof (ArgumentException))] [Category ("NotWorking")] public void UnavailableStyleException () { // Marked NotWorking because it is dependent on what fonts/styles are available // on the OS. This test is written for Windows. - Font f = new Font ("Monotype Corsiva", 8, FontStyle.Regular); + Assert.Throws (() => new Font ("Monotype Corsiva", 8, FontStyle.Regular)); } [Test] @@ -547,11 +536,10 @@ namespace MonoTests.System.Drawing{ } [Test] - [ExpectedException (typeof (ArgumentNullException))] public void GetHeight_Graphics_Null () { using (Font f = new Font (name, 12.5f)) { - Assert.AreEqual (0, f.GetHeight (null), "0"); + Assert.Throws (() => f.GetHeight (null)); } } @@ -566,34 +554,36 @@ namespace MonoTests.System.Drawing{ Assert.IsFalse (f1.GetHashCode () == f3.GetHashCode (), "2) Fonts with different styles should have different HashCodes"); } - [Test] - public void GetHashCode_UnitDiffers_HashesNotEqual() - { - Font f1 = new Font("Arial", 8.25F, GraphicsUnit.Point); - Font f2 = new Font("Arial", 8.25F, GraphicsUnit.Pixel); + [Test] + public void GetHashCode_UnitDiffers_HashesNotEqual() + { + Font f1 = new Font("Arial", 8.25F, GraphicsUnit.Point); + Font f2 = new Font("Arial", 8.25F, GraphicsUnit.Pixel); - Assert.IsFalse(f1.GetHashCode() == f2.GetHashCode(), - "Hashcodes should differ if _unit member differs"); - } + Assert.IsFalse(f1.GetHashCode() == f2.GetHashCode(), + "Hashcodes should differ if _unit member differs"); + } - [Test] - public void GetHashCode_NameDiffers_HashesNotEqual() - { - Font f1 = new Font("Arial", 8.25F, GraphicsUnit.Point); - Font f2 = new Font("Courier New", 8.25F, GraphicsUnit.Point); + [Test] + public void GetHashCode_NameDiffers_HashesNotEqual() + { + Font f1 = new Font("Arial", 8.25F, GraphicsUnit.Point); + Font f2 = new Font("Courier New", 8.25F, GraphicsUnit.Point); - Assert.IsFalse(f1.GetHashCode() == f2.GetHashCode(), - "Hashcodes should differ if _name member differs"); - } + if (f1.Name != f2.Name) { + Assert.IsFalse(f1.GetHashCode() == f2.GetHashCode(), + "Hashcodes should differ if _name member differs"); + } + } - [Test] - public void GetHashCode_StyleEqualsGdiCharSet_HashesNotEqual() - { - Font f1 = new Font("Arial", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0))); - Font f2 = new Font("Arial", 8.25F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(1))); + [Test] + public void GetHashCode_StyleEqualsGdiCharSet_HashesNotEqual() + { + Font f1 = new Font("Arial", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0))); + Font f2 = new Font("Arial", 8.25F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(1))); - Assert.IsFalse(f1.GetHashCode() == f2.GetHashCode(), - "Hashcodes should differ if _style member differs"); - } + Assert.IsFalse(f1.GetHashCode() == f2.GetHashCode(), + "Hashcodes should differ if _style member differs"); + } } }