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); }
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); }
public void NullValueException() { var mergedConverter = new MergedElementConverter(new ParagraphConverter()); var ex = Assert.Throws <ArgumentNullException>(() => { mergedConverter.Convert(null, typeof(string)); }); Assert.Equal("source", ex.ParamName); }
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); }