public void Convert_PascalCaseToCamelCase() { var input = "PascalCase"; var converter = new NamingConventionConverter(NamingConventionEnum.PascalCase, NamingConventionEnum.CamelCase); var expected = "pascalCase"; var actual = converter.Convert(input); Assert.Equal(expected, actual); }
private PropertyInfo GetPropertyInfo(Type typeTarget, string propertyName) { PropertyInfo propertyInfo = typeTarget.GetProperty(propertyName); if (propertyInfo != null) { return(propertyInfo); } INamingConvention namingConvention = NamingConventionConverter.GetNamingConvention(propertyName); string normalText = namingConvention.ThisToString(propertyName); if (namingConvention.GetType() == typeof(CamelCase) && CopierSettings.Instance.CamelCaseToSnakeCaseConvertionEnabled) { propertyInfo = typeTarget.GetProperty(normalText.ToSnakeCase()); if (propertyInfo != null) { return(propertyInfo); } } if (namingConvention.GetType() == typeof(CamelCase) && CopierSettings.Instance.CamelCaseToKebabCaseConvertionEnabled) { propertyInfo = typeTarget.GetProperty(normalText.ToKebabCase()); if (propertyInfo != null) { return(propertyInfo); } } if (namingConvention.GetType() == typeof(SnakeCase) && CopierSettings.Instance.SnakeCaseToCamelCaseConvertionEnabled) { propertyInfo = typeTarget.GetProperty(normalText.ToCamelCase()); if (propertyInfo != null) { return(propertyInfo); } } if (namingConvention.GetType() == typeof(SnakeCase) && CopierSettings.Instance.SnakeCaseToKebabCaseConvertionEnabled) { propertyInfo = typeTarget.GetProperty(normalText.ToKebabCase()); if (propertyInfo != null) { return(propertyInfo); } } if (namingConvention.GetType() == typeof(KebabCase) && CopierSettings.Instance.KebabCaseToCamelCaseConvertionEnabled) { propertyInfo = typeTarget.GetProperty(normalText.ToCamelCase()); if (propertyInfo != null) { return(propertyInfo); } } if (namingConvention.GetType() == typeof(KebabCase) && CopierSettings.Instance.KebabCaseToSnakeCaseConvertionEnabled) { propertyInfo = typeTarget.GetProperty(normalText.ToSnakeCase()); if (propertyInfo != null) { return(propertyInfo); } } return(null); }
public NamingConventionConverterTests() { _converter = new NamingConventionConverter(); }