Mapper to map image types between bytes, base64 string and Image
Наследование: Habanero.Base.DataMappers.DataMapper
Пример #1
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);
        }
Пример #2
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);
        }
Пример #3
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);
 }
Пример #4
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);
 }
Пример #5
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);
 }