Exemple #1
0
        public void ConvertSourceShouldReturnTypeConverterConvertFromResult()
        {
            SetupTypeConverterToConversion(true);
            SetupTypeConverterFromConversion(true, 10);
            var converter = new TypeConverterAdapter(_typeConverter.Object, typeof(int));

            var target = converter.ConvertSource(5);

            Assert.AreEqual(10, target);
        }
Exemple #2
0
        public void ConvertSourceShouldUseTypeConverterConvertFromForSourceConversion()
        {
            SetupTypeConverterToConversion(true);
            SetupTypeConverterFromConversion(true);
            var sourceType = typeof(int);
            var converter  = new TypeConverterAdapter(_typeConverter.Object, sourceType);

            converter.ConvertSource(5);

            _typeConverter.Verify(
                c => c.ConvertFrom(
                    It.IsAny <ITypeDescriptorContext>(),
                    It.IsAny <CultureInfo>(),
                    It.IsAny <object>()));
        }