private Configurations.NameRules GetNameRules(UseNameRulesFor useNameRulesFor) { switch (useNameRulesFor) { case UseNameRulesFor.Field: return(applicationPatcherWpfConfiguration.FieldNameRules); case UseNameRulesFor.Property: return(applicationPatcherWpfConfiguration.PropertyNameRules); case UseNameRulesFor.CommandField: return(applicationPatcherWpfConfiguration.CommandFieldNameRules); case UseNameRulesFor.CommandProperty: return(applicationPatcherWpfConfiguration.CommandPropertyNameRules); case UseNameRulesFor.DependencyField: return(applicationPatcherWpfConfiguration.DependencyFieldNameRules); case UseNameRulesFor.DependencyProperty: return(applicationPatcherWpfConfiguration.DependencyPropertyNameRules); case UseNameRulesFor.CommandExecuteMethod: return(applicationPatcherWpfConfiguration.CommandExecuteMethodNameRules); case UseNameRulesFor.CommandCanExecuteMethod: return(applicationPatcherWpfConfiguration.CommandCanExecuteMethodNameRules); default: throw new ArgumentOutOfRangeException(nameof(useNameRulesFor), useNameRulesFor, null); } }
public string ConvertName(string name, UseNameRulesFor from, UseNameRulesFor to) { var fromNameRules = GetNameRules(from); var toNameRules = GetNameRules(to); var fromSpecificNameRulesService = GetSpecificNameRulesService(fromNameRules.Type); var toSpecificNameRulesService = GetSpecificNameRulesService(toNameRules.Type); var nameWords = fromSpecificNameRulesService.GetNameWords(name, fromNameRules.Prefix, fromNameRules.Suffix); return(toSpecificNameRulesService.CompileName(nameWords, toNameRules.Prefix, toNameRules.Suffix)); }
private void CheckConvertNames(IEnumerable <string> names, UseNameRulesFor from, UseNameRulesFor to, IEnumerable <string> expectedNames) { names.Select(name => nameRulesService.ConvertName(name, from, to)).SequenceEqual(expectedNames).Should().Be(true); }
private void CheckInvalidNames(IEnumerable <string> invalidNames, UseNameRulesFor useNameRulesFor) { invalidNames.ForEach(validName => nameRulesService.IsNameValid(validName, useNameRulesFor).Should().Be(false, $"Name '{validName}' is invalid")); }
public bool IsNameValid(string name, UseNameRulesFor useNameRulesFor) { var nameRules = GetNameRules(useNameRulesFor); return(GetSpecificNameRulesService(nameRules.Type).IsNameValid(name, nameRules.Prefix, nameRules.Suffix)); }