Permalink
Browse files

CSHARP-389 - More specific test showing an example of a Bitmap that c…

…an be roundtripped in Mono.
  • Loading branch information...
1 parent fad9b8b commit 5f1e09955a7a6b5b60ff0293903ffd49f255dd4e Sridhar Nanjundeswaran committed Mar 25, 2013
Showing with 38 additions and 6 deletions.
  1. +38 −6 MongoDB.DriverUnitTests/Jira/CSharp355Tests.cs
@@ -48,12 +48,12 @@ public void TestFixtureSetup()
}
[Test]
- public void TestBitmap()
+ public void TestDefaultBitmap()
{
if (TestEnvironment.IsMono)
{
- // this test does not work in Mono. Skipping for the time being
- // CSHARP-389
+ // This test does not work in Mono. Bits 57 and 61 are 255 when
+ // the Bitmap is recreated upon retrieval from the database
return;
}
var bitmap = new Bitmap(1, 2);
@@ -63,8 +63,23 @@ public void TestBitmap()
var r = _collection.FindOne();
Assert.IsInstanceOf<C>(r);
Assert.IsInstanceOf<Bitmap>(r.I);
- Assert.AreEqual(1, r.B.Width);
- Assert.AreEqual(2, r.B.Height);
+ Assert.AreEqual(bitmap.Width, r.B.Width);
+ Assert.AreEqual(bitmap.Height, r.B.Height);
+ Assert.IsTrue(GetBytes(bitmap).SequenceEqual(GetBytes(r.B)));
+ }
+
+ [Test]
+ public void TestBitmap()
+ {
+ var bitmap = GetTestBitmap();
+ var c = new C { I = bitmap, B = bitmap };
+ _collection.RemoveAll();
+ _collection.Insert(c);
+ var r = _collection.FindOne();
+ Assert.IsInstanceOf<C>(r);
+ Assert.IsInstanceOf<Bitmap>(r.I);
+ Assert.AreEqual(bitmap.Width, r.B.Width);
+ Assert.AreEqual(bitmap.Height, r.B.Height);
Assert.IsTrue(GetBytes(bitmap).SequenceEqual(GetBytes(r.B)));
}
@@ -88,5 +103,22 @@ private byte[] GetBytes(Bitmap bitmap)
return stream.ToArray();
}
}
- }
+
+ private Bitmap GetTestBitmap ()
+ {
+ var bitmap = new Bitmap (2, 2, PixelFormat.Format32bppRgb);
+ for (int x = 0; x < bitmap.Height; ++x)
+ {
+ for (int y = 0; y < bitmap.Width; ++y)
+ {
+ bitmap.SetPixel (x, y, Color.White);
+ }
+ }
+ for (int x = 0; x < bitmap.Height; ++x)
+ {
+ bitmap.SetPixel (x, x, Color.Red);
+ }
+ return bitmap;
+ }
+ }
}

0 comments on commit 5f1e099

Please sign in to comment.