Example #1
0
        public void ConvertValueToString_FromBitmap()
        {
            //---------------Set up test pack-------------------
            var dataMapper = new ImageDataMapper();
            var img        = new System.Drawing.Bitmap(100, 100);
            //---------------Execute Test ----------------------
            string strValue = dataMapper.ConvertValueToString(img);

            //---------------Test Result -----------------------
            Assert.AreNotEqual("System.Drawing.Bitmap", strValue);
        }
Example #2
0
        public void TryParsePropValue_FailsForOtherTypes()
        {
            //---------------Set up test pack-------------------
            var    dataMapper = new ImageDataMapper();
            object parsedValue;
            //---------------Execute Test ----------------------
            var parsedSucceed = dataMapper.TryParsePropValue(3, out parsedValue);

            //---------------Test Result -----------------------
            Assert.IsFalse(parsedSucceed);
        }
Example #3
0
        public void TryParsePropValue_WorksForNull()
        {
            //---------------Set up test pack-------------------
            var    dataMapper = new ImageDataMapper();
            object parsedValue;
            //---------------Execute Test ----------------------
            var parseSucceed = dataMapper.TryParsePropValue(null, out parsedValue);

            //---------------Test Result -----------------------
            Assert.IsTrue(parseSucceed);
            Assert.IsNull(parsedValue);
        }
Example #4
0
        public void TryParsePropValue_WorksForImage()
        {
            //---------------Set up test pack-------------------
            var    dataMapper   = new ImageDataMapper();
            var    valueToParse = new System.Drawing.Bitmap(100, 100);
            object parsedValue;
            //---------------Execute Test ----------------------
            var parseSucceed = dataMapper.TryParsePropValue(valueToParse, out parsedValue);

            //---------------Test Result -----------------------
            Assert.IsTrue(parseSucceed);
            Assert.AreSame(valueToParse, parsedValue);
        }
Example #5
0
        public void TryParsePropValue_ConvertsByteArrayToImage()
        {
            //---------------Set up test pack-------------------
            var    dataMapper   = new ImageDataMapper();
            var    img          = new System.Drawing.Bitmap(100, 100);
            var    valueToParse = SerialisationUtilities.ObjectToByteArray(img);
            object parsedValue;
            //---------------Execute Test ----------------------
            var parseSucceed = dataMapper.TryParsePropValue(valueToParse, out parsedValue);

            //---------------Test Result -----------------------
            Assert.IsTrue(parseSucceed);
            Assert.IsInstanceOf(typeof(System.Drawing.Bitmap), parsedValue);
            Assert.AreEqual(img.Width, ((System.Drawing.Bitmap)parsedValue).Width);
            Assert.AreEqual(img.Height, ((System.Drawing.Bitmap)parsedValue).Height);
        }