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); }
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); }
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); }
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); }
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); }