Assert.AreEqual (Status.InvalidParameter, GDIPlus.GdipDrawRectangles (graphics, IntPtr.Zero, rf, 2), "GdipDrawRectanglesI-PenNull");
IntPtr pen;
- Assert.AreEqual (Status.Ok, GDIPlus.GdipCreatePen1 (0, 0f, Unit.UnitWorld, out pen), "GdipCreatePen1");
+ Assert.AreEqual (Status.Ok, GDIPlus.GdipCreatePen1 (0, 0f, GraphicsUnit.World, out pen), "GdipCreatePen1");
Assert.IsTrue (pen != IntPtr.Zero, "pen");
Assert.AreEqual (Status.InvalidParameter, GDIPlus.GdipDrawRectanglesI (IntPtr.Zero, pen, r, 1), "GdipDrawRectanglesI-GraphicsNull");
public void Widen ()
{
IntPtr pen;
- Assert.AreEqual (Status.Ok, GDIPlus.GdipCreatePen1 (0, 0f, Unit.UnitWorld, out pen), "GdipCreatePen1");
+ Assert.AreEqual (Status.Ok, GDIPlus.GdipCreatePen1 (0, 0f, GraphicsUnit.World, out pen), "GdipCreatePen1");
IntPtr path;
Assert.AreEqual (Status.Ok, GDIPlus.GdipCreatePath (FillMode.Alternate, out path), "GdipCreatePath");
Assert.AreEqual (Status.InvalidParameter, GDIPlus.GdipSetImagePalette (IntPtr.Zero, palette), "GdipSetImagePalette(null,palette)");
Assert.AreEqual (Status.InvalidParameter, GDIPlus.GdipSetImagePalette (bitmap, IntPtr.Zero), "GdipSetImagePalette(bitmap,null)");
Assert.AreEqual (Status.Ok, GDIPlus.GdipSetImagePalette (bitmap, palette), "GdipSetImagePalette");
-
- // change palette to 0 entries
- int flags = Marshal.ReadInt32 (palette);
- Marshal.WriteInt64 (palette, flags << 32);
- Assert.AreEqual (Status.Ok, GDIPlus.GdipSetImagePalette (bitmap, palette), "GdipSetImagePalette/Empty");
-
- Assert.AreEqual (Status.Ok, GDIPlus.GdipGetImagePaletteSize (bitmap, out size), "GdipGetImagePaletteSize/Empty");
- Assert.AreEqual (8, size, "size");
}
finally {
Marshal.FreeHGlobal (palette);
}
[Test]
- [ExpectedException (typeof (FileNotFoundException))]
public void GdipLoadImageFromFile_FileNotFound ()
{
string filename = "filenotfound";
Assert.AreEqual (IntPtr.Zero, image, "image handle");
// this doesn't throw a OutOfMemoryException
- Image.FromFile (filename);
+ Assert.Throws<FileNotFoundException> (() => Image.FromFile (filename));
}
[Test]
- [ExpectedException (typeof (ArgumentException))]
public void GdipCreateBitmapFromFile_FileNotFound ()
{
string filename = "filenotfound";
Assert.AreEqual (Status.InvalidParameter, GDIPlus.GdipCreateBitmapFromFile (filename, out bitmap), "GdipCreateBitmapFromFile");
Assert.AreEqual (IntPtr.Zero, bitmap, "bitmap handle");
- new Bitmap (filename);
+ Assert.Throws<ArgumentException> (() => new Bitmap (filename));
}
[Test]
public void CreatePen ()
{
IntPtr pen;
- Assert.AreEqual (Status.Ok, GDIPlus.GdipCreatePen1 (0, 0f, Unit.UnitWorld, out pen), "GdipCreatePen1");
+ Assert.AreEqual (Status.Ok, GDIPlus.GdipCreatePen1 (0, 0f, GraphicsUnit.World, out pen), "GdipCreatePen1");
Assert.IsTrue (pen != IntPtr.Zero, "pen");
DashStyle ds;
public void PenColor_81266 ()
{
IntPtr pen;
- Assert.AreEqual (Status.Ok, GDIPlus.GdipCreatePen1 (0x7f0000ff, 1f, Unit.UnitPixel, out pen), "GdipCreatePen1");
+ Assert.AreEqual (Status.Ok, GDIPlus.GdipCreatePen1 (0x7f0000ff, 1f, GraphicsUnit.Pixel, out pen), "GdipCreatePen1");
try {
int color = 0;
IntPtr brush;
out image);
GDIPlus.GdipGetImageGraphicsContext (image, out graphics);
- GDIPlus.GdipCreatePen1 (0, 0f, Unit.UnitWorld, out pen);
+ GDIPlus.GdipCreatePen1 (0, 0f, GraphicsUnit.World, out pen);
// DrawCurve
"DrawCurve with 1 pt");
Assert.AreEqual (Status.Ok,
GDIPlus.GdipDrawCurveI (graphics, pen,
- new Point [] { new Point (1, 1),
- new Point (2, 2) }, 2),
+ new Point [] { new Point (1, 1),
+ new Point (2, 2) }, 2),
"DrawCurve with 2 pts");
// DrawClosedCurve
"DrawClosedCurve with no pts");
Assert.AreEqual (Status.InvalidParameter,
GDIPlus.GdipDrawClosedCurveI (graphics, pen,
- new Point [] { new Point (1, 1) }, 1),
+ new Point [] { new Point (1, 1) }, 1),
"DrawClosedCurve with 1 pt");
Assert.AreEqual (Status.InvalidParameter,
GDIPlus.GdipDrawClosedCurveI (graphics, pen,
- new Point [] { new Point (1, 1),
- new Point (2, 2) }, 2),
+ new Point [] { new Point (1, 1),
+ new Point (2, 2) }, 2),
"DrawClosedCurve with 2 pt2");
// DrawPolygon
"DrawPolygon with no pts");
Assert.AreEqual (Status.InvalidParameter,
GDIPlus.GdipDrawPolygonI (graphics, pen,
- new Point [] { new Point (1, 1) }, 1),
+ new Point [] { new Point (1, 1) }, 1),
"DrawPolygon with only one pt");
GDIPlus.GdipDeletePen (pen);
"FillClosedCurve with no pts");
Assert.AreEqual (Status.Ok,
GDIPlus.GdipFillClosedCurveI (graphics, brush,
- new Point [] { new Point (1, 1) }, 1),
+ new Point [] { new Point (1, 1) }, 1),
"FillClosedCurve with 1 pt");
Assert.AreEqual (Status.Ok,
GDIPlus.GdipFillClosedCurveI (graphics, brush,
- new Point [] { new Point (1, 1),
- new Point (2, 2) }, 2),
+ new Point [] { new Point (1, 1),
+ new Point (2, 2) }, 2),
"FillClosedCurve with 2 pts");
GDIPlus.GdipDeleteBrush (brush);
float width, height;
Assert.AreEqual (Status.Ok, GDIPlus.GdipGetImageDimension (image, out width, out height), "GdipGetImageDimension");
- Assert.AreEqual (12976.63, width, "GdipGetImageDimension/Width");
- Assert.AreEqual (17297.99, height, "GdipGetImageDimension/Height");
+ Assert.AreEqual (12976.6328f, width, 0.001f, "GdipGetImageDimension/Width");
+ Assert.AreEqual (17297.9863f, height, 0.001f, "GdipGetImageDimension/Height");
ImageType type;
Assert.AreEqual (Status.Ok, GDIPlus.GdipGetImageType (image, out type), "GdipGetImageType");