Пример #1
0
        public void ConvertTargetShouldReturnTypeConverterConvertToResult()
        {
            SetupTypeConverterToConversion(true, 10);
            var converter = new TypeConverterAdapter(_typeConverter.Object, typeof(int));

            var source = converter.ConvertTarget(5);

            Assert.AreEqual(10, source);
        }
Пример #2
0
        public void ConvertTargetShouldReturnNoValueWhenTypeConverterConvertToThrows()
        {
            SetupTypeConverterToConversion(true);
            var converter = new TypeConverterAdapter(_typeConverter.Object, typeof(int));

            _typeConverter.Setup(c => c.ConvertTo(It.IsAny <ITypeDescriptorContext>(), It.IsAny <CultureInfo>(), It.IsAny <object>(), It.IsAny <Type>()))
            .Throws <Exception>();

            var source = converter.ConvertTarget(5);

            Assert.AreEqual(SettingsConstants.NoValue, source);
        }