public void ByteArrayImageConversionStrategyTest()
        {
            var strategy = new ByteArrayImageConversionStrategy();

            Assert.IsFalse(strategy.CanConvert(typeof(string), typeof(string)));
            Assert.IsTrue(strategy.CanConvert(typeof(byte[]), typeof(Image)));
            Assert.IsTrue(strategy.CanConvert(typeof(Image), typeof(byte[])));

            var bytes =
                strategy.Convert(typeof(Image), typeof(byte[]), Resources.TestImg, Thread.CurrentThread.CurrentCulture)
                as byte[];

            Assert.IsNotNull(bytes);
            Assert.IsTrue(bytes.Length > 0);

            var img =
                strategy.Convert(typeof(byte[]), typeof(Image), bytes, Thread.CurrentThread.CurrentCulture) as Image;

            Assert.IsNotNull(img);
            Assert.AreEqual(Resources.TestImg.Width, img.Width);
            Assert.AreEqual(Resources.TestImg.Height, img.Height);
        }
        public void ByteArrayImageConversionStrategyTest()
        {
            var    strategy = new ByteArrayImageConversionStrategy();
            object newValue;

            var ms = new MemoryStream(My.Resources.TestImg);

            ms.Position = 0;
            var img = Image.FromStream(ms);

            Assert.IsTrue(strategy.TryConvert(img, typeof(byte[]), out newValue));
            var bytes = newValue as byte[];

            Assert.IsNotNull(bytes);
            Assert.IsTrue(bytes.Length > 0);

            Assert.IsTrue(strategy.TryConvert(bytes, typeof(Image), out newValue));
            var newImg = newValue as Image;

            Assert.IsNotNull(newImg);
            Assert.AreEqual(img.Width, newImg.Width);
            Assert.AreEqual(img.Height, newImg.Height);
        }