[Test]
[Category ("CAS")]
- [ExpectedException (typeof (SecurityException))]
[SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
public void ToLogFont_DenyUnmanagedCode ()
{
lf = new LOGFONT();
f = new Font("Arial", 10);
- f.ToLogFont(lf);
+ Assert.Throws<SecurityException> (() => f.ToLogFont(lf));
}
[Test]
[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<ArgumentException> (() => f.ToLogFont (o));
// no PInvoke conversion exists !?!?
}
[Test]
[SecurityPermission (SecurityAction.Assert, UnmanagedCode = true)]
- [ExpectedException (typeof (AccessViolationException))]
public void ToLogFont_Null ()
{
Font f = new Font ("Arial", 10);
- f.ToLogFont (null);
+ Assert.Throws<AccessViolationException> (() => f.ToLogFont (null));
}
[Test]
public void Font_StringNull_Float ()
}
[Test]
- [ExpectedException (typeof (ArgumentException))]
public void Font_String_Float_FontStyle_GraphicsUnit_Display ()
{
- new Font (name, 12.5f, FontStyle.Italic, GraphicsUnit.Display);
+ Assert.Throws<ArgumentException> (() => new Font (name, 12.5f, FontStyle.Italic, GraphicsUnit.Display));
}
[Test]
}
[Test]
- [ExpectedException (typeof (ArgumentNullException))]
public void Font_FontFamilyNull_Float ()
{
FontFamily ff = null;
- new Font (ff, 12.5f);
+ Assert.Throws<ArgumentNullException> (() => new Font (ff, 12.5f));
}
[Test]
- [ExpectedException (typeof (NullReferenceException))]
public void Font_FontNull_FontStyle ()
{
Font f = null;
- new Font (f, FontStyle.Bold);
+ Assert.Throws<NullReferenceException> (() => new Font (f, FontStyle.Bold));
}
[Test]
}
[Test]
- [ExpectedException (typeof (ArgumentException))]
public void Font_FontFamily_Float_FontStyle_GraphicsUnit_Display ()
{
- new Font (FontFamily.GenericMonospace, 12.5f, FontStyle.Italic, GraphicsUnit.Display);
+ Assert.Throws<ArgumentException> (() => new Font (FontFamily.GenericMonospace, 12.5f, FontStyle.Italic, GraphicsUnit.Display));
}
[Test]
}
[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<ArgumentException> (() => { 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<ArgumentException> (() => f.ToLogFont (lf));
}
[Test]
}
[Test]
- [ExpectedException (typeof (ArgumentException))]
public void Dispose_ToHFont ()
{
Font f = new Font (name, 12.5f);
f.Dispose ();
- f.ToHfont ();
+ Assert.Throws<ArgumentException> (() => 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<ArgumentException> (() => new Font ("Monotype Corsiva", 8, FontStyle.Regular));
}
[Test]
}
[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<ArgumentNullException> (() => f.GetHeight (null));
}
}
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);
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");
+ }
}
}