public void Int32ConverterActivation() { // Arrange var expected = typeof (Int32Converter); var valueConverterType = typeof (GuidConverter); var converterAttribute = new ConverterKeyValueAttribute(valueConverterType, expected); // Act var actual = converterAttribute.BuildKeyConverter(); // Assert Assert.NotNull(actual); Assert.IsType<Int32Converter>(actual); }
public void DefaultStringConverterActivation() { // Arrange var expected = typeof (StringConverter); var ValueConverterType = typeof (Int32Converter); var converterAttribute = new ConverterKeyValueAttribute(ValueConverterType); // Act var actual = converterAttribute.BuildKeyConverter(); // Assert Assert.NotNull(actual); Assert.IsType<StringConverter>(actual); }
private static IConverter GetKeyConverter(PropertyInfo propertyInfo, string optionName, string commandName, ConverterKeyValueAttribute converterKeyValuePairAttribute) { var keyType = propertyInfo.PropertyType.GetUnderlyingDictionaryType(true); var keyConverter = converterKeyValuePairAttribute.BuildKeyConverter(); if (!keyType.IsAssignableFrom(keyConverter.TargetType)) { throw new CommandLineParserException(Constants.ExceptionMessages.ParserExtractKeyConverterIsNotValid(optionName, commandName, keyType, keyConverter.TargetType)); } return keyConverter; }