Beispiel #1
0
        public void TestCanConvertTo()
        {
            Assert.True(_imgConv.CanConvertTo(typeof(string)), "stirng (no context)");
            Assert.True(_imgConv.CanConvertTo(null, typeof(string)), "string");
            Assert.True(_imgConv.CanConvertTo(null, _imageStr.GetType()), "_imageStr.GetType()");
            Assert.True(_imgConv.CanConvertTo(typeof(byte[])), "byte[] (no context)");
            Assert.True(_imgConv.CanConvertTo(null, typeof(byte[])), "byte[]");
            Assert.True(_imgConv.CanConvertTo(null, _imageBytes.GetType()), "_imageBytes.GetType()");
            Assert.False(_imgConv.CanConvertTo(null, typeof(Rectangle)), "Rectangle");
            Assert.False(_imgConv.CanConvertTo(null, typeof(Point)), "Point");
            Assert.False(_imgConv.CanConvertTo(null, typeof(PointF)), "PointF");
            Assert.False(_imgConv.CanConvertTo(null, typeof(Size)), "Size");
            Assert.False(_imgConv.CanConvertTo(null, typeof(SizeF)), "SizeF");
            Assert.False(_imgConv.CanConvertTo(null, typeof(object)), "object");
            Assert.False(_imgConv.CanConvertTo(null, typeof(int)), "int");

            Assert.True(_imgConvFrmTD.CanConvertTo(typeof(string)), "TD string (no context)");
            Assert.True(_imgConvFrmTD.CanConvertTo(null, typeof(string)), "TD string");
            Assert.True(_imgConvFrmTD.CanConvertTo(null, _imageStr.GetType()), "TD _imageStr.GetType()");
            Assert.True(_imgConvFrmTD.CanConvertTo(typeof(byte[])), "TD byte[] (no context)");
            Assert.True(_imgConvFrmTD.CanConvertTo(null, typeof(byte[])), "TD byte[]");
            Assert.True(_imgConvFrmTD.CanConvertTo(null, _imageBytes.GetType()), "TD _imageBytes.GetType()");
            Assert.False(_imgConvFrmTD.CanConvertTo(null, typeof(Rectangle)), "TD Rectangle");
            Assert.False(_imgConvFrmTD.CanConvertTo(null, typeof(Point)), "TD Point");
            Assert.False(_imgConvFrmTD.CanConvertTo(null, typeof(PointF)), "TD PointF");
            Assert.False(_imgConvFrmTD.CanConvertTo(null, typeof(Size)), "TD Size");
            Assert.False(_imgConvFrmTD.CanConvertTo(null, typeof(SizeF)), "TD SizeF");
            Assert.False(_imgConvFrmTD.CanConvertTo(null, typeof(object)), "TD object");
            Assert.False(_imgConvFrmTD.CanConvertTo(null, typeof(int)), "TD int");
        }
        public void TestCanConvertTo()
        {
            Assert.IsTrue(imgConv.CanConvertTo(typeof(String)), "CCT#1");
            Assert.IsTrue(imgConv.CanConvertTo(null, typeof(String)), "CCT#1a");
            Assert.IsTrue(imgConv.CanConvertTo(null, imageStr.GetType()), "CCT#1b");
            Assert.IsTrue(imgConv.CanConvertTo(typeof(byte [])), "CCT#2");
            Assert.IsTrue(imgConv.CanConvertTo(null, typeof(byte [])), "CCT#2a");
            Assert.IsTrue(imgConv.CanConvertTo(null, imageBytes.GetType()), "CCT#2b");
            Assert.IsTrue(!imgConv.CanConvertTo(null, typeof(Rectangle)), "CCT#3");
            Assert.IsTrue(!imgConv.CanConvertTo(null, typeof(Point)), "CCT#4");
            Assert.IsTrue(!imgConv.CanConvertTo(null, typeof(PointF)), "CCT#5");
            Assert.IsTrue(!imgConv.CanConvertTo(null, typeof(Size)), "CCT#6");
            Assert.IsTrue(!imgConv.CanConvertTo(null, typeof(SizeF)), "CCT#7");
            Assert.IsTrue(!imgConv.CanConvertTo(null, typeof(Object)), "CCT#8");
            Assert.IsTrue(!imgConv.CanConvertTo(null, typeof(int)), "CCT#9");

            Assert.IsTrue(imgConvFrmTD.CanConvertTo(typeof(String)), "CCT#1A");
            Assert.IsTrue(imgConvFrmTD.CanConvertTo(null, typeof(String)), "CCT#1aA");
            Assert.IsTrue(imgConvFrmTD.CanConvertTo(null, imageStr.GetType()), "CCT#1bA");
            Assert.IsTrue(imgConvFrmTD.CanConvertTo(typeof(byte [])), "CCT#2A");
            Assert.IsTrue(imgConvFrmTD.CanConvertTo(null, typeof(byte [])), "CCT#2aA");
            Assert.IsTrue(imgConvFrmTD.CanConvertTo(null, imageBytes.GetType()), "CCT#2bA");
            Assert.IsTrue(!imgConvFrmTD.CanConvertTo(null, typeof(Rectangle)), "CCT#3A");
            Assert.IsTrue(!imgConvFrmTD.CanConvertTo(null, typeof(Point)), "CCT#4A");
            Assert.IsTrue(!imgConvFrmTD.CanConvertTo(null, typeof(PointF)), "CCT#5A");
            Assert.IsTrue(!imgConvFrmTD.CanConvertTo(null, typeof(Size)), "CCT#6A");
            Assert.IsTrue(!imgConvFrmTD.CanConvertTo(null, typeof(SizeF)), "CCT#7A");
            Assert.IsTrue(!imgConvFrmTD.CanConvertTo(null, typeof(Object)), "CCT#8A");
            Assert.IsTrue(!imgConvFrmTD.CanConvertTo(null, typeof(int)), "CCT#9A");
        }