public void When_ToImage() { Bitmap expected = DrawFilledRectangle(Brushes.Blue, 100, 100); byte[] source = expected.ImageToByteArray(); Bitmap actual; actual = (Bitmap)ByteExtensions.ToImage(source); for (int i = 0; i < 100; i++) { for (int j = 0; j < 100; j++) { Assert.AreEqual(expected.GetPixel(i, j), actual.GetPixel(i, j)); } } }