public void DefaultStringConverterActivation() { // Arrange var expected = typeof (Int32Converter); var converterAttribute = new ConverterKeyValueAttribute(expected); // Act var actual = converterAttribute.BuildValueConverter(); // Assert Assert.NotNull(actual); Assert.IsType<Int32Converter>(actual); }
private static IConverter GetValueConverter(PropertyInfo propertyInfo, string optionName, string commandName, ConverterKeyValueAttribute converterKeyValuePairAttribute) { var valueType = propertyInfo.PropertyType.GetUnderlyingDictionaryType(false); var valueConverter = converterKeyValuePairAttribute.BuildValueConverter(); if (!valueType.IsAssignableFrom(valueConverter.TargetType)) { throw new CommandLineParserException(Constants.ExceptionMessages.ParserExtractValueConverterIsNotValid(optionName, commandName, valueType, valueConverter.TargetType)); } return valueConverter; }