예제 #1
0
        public void SimpleStringToInt()
        {
            var mergedConverter = new MergedElementConverter(new StringConverter());
            var value           = mergedConverter.Convert("123", typeof(int));

            Assert.IsType <int>(value);
            var intValue = (int)value;

            Assert.Equal(123, intValue);
        }
예제 #2
0
        public void NullTypeException()
        {
            var mergedConverter = new MergedElementConverter(new ParagraphConverter());

            var ex = Assert.Throws <ArgumentNullException>(() =>
            {
                mergedConverter.Convert(Paragraph.FromText("notNull"), null);
            });

            Assert.Equal("targetType", ex.ParamName);
        }
예제 #3
0
        public void NullValueException()
        {
            var mergedConverter = new MergedElementConverter(new ParagraphConverter());

            var ex = Assert.Throws <ArgumentNullException>(() =>
            {
                mergedConverter.Convert(null, typeof(string));
            });

            Assert.Equal("source", ex.ParamName);
        }
예제 #4
0
        public void ParagraphToInt()
        {
            var paragraph       = Paragraph.FromText("123");
            var mergedConverter = new MergedElementConverter(new ParagraphConverter());

            mergedConverter.Add(typeof(string), new StringConverter());

            var value = mergedConverter.Convert(paragraph, typeof(int));

            Assert.IsType <int>(value);
            var intValue = (int)value;

            Assert.Equal(123, intValue);
        }