public void NullConverterAttributeException() { // Arrange ConverterKeyValueAttribute converterAttribute = null; var expectedExceptionMessage = SourceParameterName; // Act var actualException = Assert.Throws <ArgumentNullException>(() => converterAttribute.BuildKeyConverter()); // Assert Assert.Equal(expectedExceptionMessage, actualException.ParamName); }
private static IConverter GetKeyConverter(PropertyInfo propertyInfo, string optionName, string commandName, ConverterKeyValueAttribute converterKeyValuePairAttribute) { var keyType = propertyInfo.PropertyType.GetUnderlyingDictionaryType(true); var keyConverter = converterKeyValuePairAttribute.BuildKeyConverter(); if (!keyType.IsType(keyConverter.TargetType)) { throw new CommandLineParserException(Constants.ExceptionMessages.ParserExtractKeyConverterIsNotValid(optionName, commandName, keyType, keyConverter.TargetType)); } return(keyConverter); }
public void DefaultStringConverterActivation() { // Arrange var valueConverterType = typeof(Int32Converter); var converterAttribute = new ConverterKeyValueAttribute(valueConverterType); // Act var actual = converterAttribute.BuildKeyConverter(); // Assert Assert.NotNull(actual); Assert.IsType <StringConverter>(actual); }
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); }