public void Given__EMPTY_STRING__should_return_an_empty_NameParts_object() { const string input = ""; var result = input.ParseName(); var expect = new NameParts(); Verify(result, expect); }
static void ProcessName(NameParts parts, PooledDictionary <string, TValue> namesBuilder) { if (!namesBuilder.ContainsKey(parts.SymbolName)) { namesBuilder.Add(parts.SymbolName, parts.AssociatedValue); } }
// Local functions static void ProcessWildcardName(NameParts parts, PooledDictionary <SymbolKind, PooledDictionary <string, TValue> > wildcardNamesBuilder) { Debug.Assert(parts.SymbolName[parts.SymbolName.Length - 1] == WildcardChar); Debug.Assert(parts.SymbolName.Length >= 2); if (parts.SymbolName[1] != ':') { if (!wildcardNamesBuilder.ContainsKey(AllKinds)) { wildcardNamesBuilder.Add(AllKinds, PooledDictionary <string, TValue> .GetInstance()); } wildcardNamesBuilder[AllKinds].Add(parts.SymbolName.Substring(0, parts.SymbolName.Length - 1), parts.AssociatedValue); return; } var symbolKind = parts.SymbolName[0] switch { 'E' => (SymbolKind?)SymbolKind.Event, 'F' => SymbolKind.Field, 'M' => SymbolKind.Method, 'N' => SymbolKind.Namespace, 'P' => SymbolKind.Property, 'T' => SymbolKind.NamedType, _ => null, }; if (symbolKind != null) { if (!wildcardNamesBuilder.ContainsKey(symbolKind.Value)) { wildcardNamesBuilder.Add(symbolKind.Value, PooledDictionary <string, TValue> .GetInstance()); } wildcardNamesBuilder[symbolKind.Value].Add(parts.SymbolName.Substring(2, parts.SymbolName.Length - 3), parts.AssociatedValue); } }
private static NameStructured FillNameStructured(NameParts namePartsDivided) { var nameStructured = new NameStructured(); nameStructured.FillNameStructured(namePartsDivided); return(nameStructured); }
public void Given__WHITESPACE__should_return_an_empty_NameParts_object() { const string input = " \t\f\r\n"; var result = input.ParseName(); var expect = new NameParts(); Verify(result, expect); }
private static void Verify(NameParts result, NameParts expected) { result.Prefix.ShouldBeEqualTo(expected.Prefix); result.GivenName.ShouldBeEqualTo(expected.GivenName); result.MiddleName.ShouldBeEqualTo(expected.MiddleName); result.Surname.ShouldBeEqualTo(expected.Surname); result.Suffix.ShouldBeEqualTo(expected.Suffix); }
public void Given__EMPTY_STRING__should_return_an_empty_NameParts_object() { const string input = ""; var result = input.ParseName(); var expect = new NameParts(); Verify(result, expect); }
public bool CompareTo(NameParts np2, bool excludePrefix) { if (excludePrefix) { return(Prefix == np2.Prefix && Number.CompareTo(np2.Number) > 0); } return(Full.CompareTo(np2.Full) > 0); }
private static void SetPartBySlice(NameParts nameParts, NameSlice nameSlice) { if (nameSlice.IsParticle) { nameParts.SetParticle(nameSlice.Value); } else { nameParts.Add(nameSlice.Value); } }
public void Given__JOHN_KAIDII__should_return_GivenName_JOHN_Surname_KAIDII() { const string input = "JOHN KAIDII"; var result = input.ParseName(); var expect = new NameParts { GivenName = "JOHN", Surname = "KAIDII" }; Verify(result, expect); }
public void Given__JOHN_SLODOV__should_return_GivenName_JOHN_Surname_SLODOV() { const string input = "JOHN SLODOV"; var result = input.ParseName(); var expect = new NameParts { GivenName = "JOHN", Surname = "SLODOV" }; Verify(result, expect); }
public void Given__San_Juan_Smith__should_return_GivenName_San_Juan_Surname_Smith() { const string input = "San Juan Smith"; var result = input.ParseName(); var expect = new NameParts { GivenName = "San Juan", Surname = "Smith" }; Verify(result, expect); }
public void Given__De_la_Rosa_Henry_Smith__should_return_GivenName_De_la_Rosa_MiddleName_Henry_Surname_Smith() { const string input = "De la Rosa Henry Smith"; var result = input.ParseName(); var expect = new NameParts { GivenName = "De la Rosa", MiddleName = "Henry", Surname = "Smith" }; Verify(result, expect); }
public void Given__JOHN_SULLIV__should_return_GivenName_JOHN_Surname_SULLIV() { const string input = "JOHN SULLIV"; var result = input.ParseName(); var expect = new NameParts { GivenName = "JOHN", Surname = "SULLIV" }; Verify(result, expect); }
public void Given__John_von_Smith__should_return_GivenName_John_Surname_von_Smith() { const string input = "John von Smith"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "von Smith" }; Verify(result, expect); }
public void Given__John_le_Toro__should_return_GivenName_John_Surname_Le_Toro() { const string input = "John Le Toro"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "Le Toro" }; Verify(result, expect); }
public void Given__John_de_San_Angelo__should_return_GivenName_John_Surname_de_San_Angelo() { const string input = "John de San Angelo"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "de San Angelo" }; Verify(result, expect); }
public void Given__John_de_St_DOT_Felix__should_return_GivenName_John_Surname_de_St_DOT_Felix() { const string input = "John de St. Felix"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "de St. Felix" }; Verify(result, expect); }
public void Given__John_Van_Der_Sharp__should_return_GivenName_John_Surname_Van_Der_Sharp() { const string input = "John Van Der Sharp"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "Van Der Sharp" }; Verify(result, expect); }
public void Given__John_da_Silva__should_return_GivenName_John_Surname_da_Silva() { const string input = "John da Silva"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "da Silva" }; Verify(result, expect); }
private NameParts SeparateNameInParts(string nameToDivide) { var nameParts = new NameParts(); var nameSlices = SeparateNameInSlices(nameToDivide); foreach (var nameSlice in nameSlices.Slices.OrderBy(x => x.Order)) { SetPartBySlice(nameParts, nameSlice); } return(nameParts); }
public void Given__JOHN_SMITH_JR__should_return_GivenName_JOHN_Surname_SMITH_Suffix_JR() { const string input = "JOHN SMITH JR"; var result = input.ParseName(); var expect = new NameParts { GivenName = "JOHN", Surname = "SMITH", Suffix = "JR" }; Verify(result, expect); }
public void Given__John_Smith_nka_John_Schmidt__should_return_GivenName_John_Surname_Smith() { const string input = "John Smith nka John Schmidt"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "Smith" }; Verify(result, expect); }
public void Given__JOHN_KAIDII__should_return_GivenName_JOHN_Surname_KAIDII() { const string input = "JOHN KAIDII"; var result = input.ParseName(); var expect = new NameParts { GivenName = "JOHN", Surname = "KAIDII" }; Verify(result, expect); }
public void Given__John_Smith_DASH_White__should_return_GivenName_John_Surname_Smith_DASH_White() { const string input = "John Smith-White"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "Smith-White" }; Verify(result, expect); }
public void Given__John_O_QUOTE_Connell__should_return_GivenName_John_Surname_O_QUOTE_Connell() { const string input = "John O'Connell"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "O'Connell" }; Verify(result, expect); }
public void Given__John_De_Le_Cerda__should_return_GivenName_John_Surname_De_Le_Cerda() { const string input = "John De Le Cerda"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "De Le Cerda" }; Verify(result, expect); }
public void Given__Mr_DOT_Smith__should_return_Prefix_Mr_DOT_Surname_Smith() { const string input = "Mr. Smith"; var result = input.ParseName(); var expect = new NameParts { Prefix = "Mr.", Surname = "Smith" }; Verify(result, expect); }
public void Given__John_Du_Puis__should_return_GivenName_John_Surname_Du_Puis() { const string input = "John Du Puis"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "Du Puis" }; Verify(result, expect); }
public void Given__John_Di_Marco__should_return_GivenName_John_Surname_Di_Marco() { const string input = "John Di Marco"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "Di Marco" }; Verify(result, expect); }
public void Given__John_El_Cid__should_return_GivenName_John_Surname_El_Cid() { const string input = "John El Cid"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "El Cid" }; Verify(result, expect); }
public void Given__John_La_Grange__should_return_GivenName_John_Surname_La_Grange() { const string input = "John La Grange"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "La Grange" }; Verify(result, expect); }
public void Given__John_Mac_Hugh__should_return_GivenName_John_Surname_Mac_Hugh() { const string input = "John Mac Hugh"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "Mac Hugh" }; Verify(result, expect); }
public void Given__John_Al_Sharif__should_return_GivenName_John_Surname_Al_Sharif() { const string input = "John Al Sharif"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "Al Sharif" }; Verify(result, expect); }
public void Given__Al_H_Smith__should_return_GivenName_Al_MiddleName_H_Surname_Smith() { const string input = "Al H Smith"; var result = input.ParseName(); var expect = new NameParts { GivenName = "Al", MiddleName = "H", Surname = "Smith" }; Verify(result, expect); }
public void Given__JOHN_SMITH_JR__should_return_GivenName_JOHN_Surname_SMITH_Suffix_JR() { const string input = "JOHN SMITH JR"; var result = input.ParseName(); var expect = new NameParts { GivenName = "JOHN", Surname = "SMITH", Suffix = "JR" }; Verify(result, expect); }
public void Given__John_H_O_Donnell__should_return_GivenName_John_MiddleName_H_Surname_O_Donnell() { const string input = "John H O Donnell"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", MiddleName = "H", Surname = "O Donnell" }; Verify(result, expect); }
public void Given__John_de_San_Angelo__should_return_GivenName_John_Surname_de_San_Angelo() { const string input = "John de San Angelo"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "de San Angelo" }; Verify(result, expect); }
public void Given__John_da_Silva__should_return_GivenName_John_Surname_da_Silva() { const string input = "John da Silva"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "da Silva" }; Verify(result, expect); }
public void Given__John_de_St_DOT_Felix__should_return_GivenName_John_Surname_de_St_DOT_Felix() { const string input = "John de St. Felix"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "de St. Felix" }; Verify(result, expect); }
public void Given__John_Du_Puis__should_return_GivenName_John_Surname_Du_Puis() { const string input = "John Du Puis"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "Du Puis" }; Verify(result, expect); }
public void Given__John_Di_Marco__should_return_GivenName_John_Surname_Di_Marco() { const string input = "John Di Marco"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "Di Marco" }; Verify(result, expect); }
public void Given__Mr_DOT_Smith__should_return_Prefix_Mr_DOT_Surname_Smith() { const string input = "Mr. Smith"; var result = input.ParseName(); var expect = new NameParts { Prefix = "Mr.", Surname = "Smith" }; Verify(result, expect); }
public void Given__John_Van_Der_Sharp__should_return_GivenName_John_Surname_Van_Der_Sharp() { const string input = "John Van Der Sharp"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "Van Der Sharp" }; Verify(result, expect); }
public void Given__John_La_Grange__should_return_GivenName_John_Surname_La_Grange() { const string input = "John La Grange"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "La Grange" }; Verify(result, expect); }
public void Given__John_Smith_nka_John_Schmidt__should_return_GivenName_John_Surname_Smith() { const string input = "John Smith nka John Schmidt"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "Smith" }; Verify(result, expect); }
public void Given__John_Smith_DASH_White__should_return_GivenName_John_Surname_Smith_DASH_White() { const string input = "John Smith-White"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "Smith-White" }; Verify(result, expect); }
public void Given__John_Smith_V__should_return_GivenName_John_Surname_Smith_Suffix_V() { const string input = "John Smith V"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "Smith", Suffix = "V" }; Verify(result, expect); }
public void Given__John_H_O_Oxford__should_return_GivenName_John_MiddleName_H_O_Surname_Oxford() { const string input = "John H O Oxford"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", MiddleName = "H O", Surname = "Oxford" }; Verify(result, expect); }
public void Given__John_Smith_COMMA_MD_COMMA_PA__should_return_GivenName_John_Surname_Smith_Suffix_MD_COMMA_PA() { const string input = "John Smith, MD, PA"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "Smith", Suffix = "MD, PA" }; Verify(result, expect); }
public void Given__John_El_Cid__should_return_GivenName_John_Surname_El_Cid() { const string input = "John El Cid"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "El Cid" }; Verify(result, expect); }
public void Given__John_O_QUOTE_Connell__should_return_GivenName_John_Surname_O_QUOTE_Connell() { const string input = "John O'Connell"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "O'Connell" }; Verify(result, expect); }
public void Given__John_H_DOT_Smith__should_return_GivenName_John_MiddleName_H_DOT_Surname_Smith() { const string input = "John H.Smith"; // no space var result = input.ParseName(); var expect = new NameParts { GivenName = "John", MiddleName = "H.", Surname = "Smith" }; Verify(result, expect); }
public void Given__John_Mac_Hugh__should_return_GivenName_John_Surname_Mac_Hugh() { const string input = "John Mac Hugh"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "Mac Hugh" }; Verify(result, expect); }
public void Given__John_De_Le_Cerda__should_return_GivenName_John_Surname_De_Le_Cerda() { const string input = "John De Le Cerda"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "De Le Cerda" }; Verify(result, expect); }
public void Given__John_De_Jesus_Reyes__should_return_GivenName_John_MiddleName_De_Jesus_Surname_Reyes() { const string input = "John De Jesus Reyes"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", MiddleName = "De Jesus", Surname = "Reyes" }; Verify(result, expect); }
public void Given__John_le_Toro__should_return_GivenName_John_Surname_Le_Toro() { const string input = "John Le Toro"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "Le Toro" }; Verify(result, expect); }
public void Given__John_Henry_De_La_Rosa__should_return_GivenName_John_Surname_MiddleName_Henry_De_La_Rosa() { const string input = "John Henry De La Rosa"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", MiddleName = "Henry", Surname = "De La Rosa" }; Verify(result, expect); }
public static String separateVolumeAndFolder(string stringToSeparate, NameParts partToSeparate) { var separatorIndex = stringToSeparate.IndexOf(':'); switch (partToSeparate) { case NameParts.volume: return stringToSeparate.Remove(separatorIndex); case NameParts.folder: return stringToSeparate.Remove(0, separatorIndex + 1); default: return null; } }
public void Given__John_von_Smith__should_return_GivenName_John_Surname_von_Smith() { const string input = "John von Smith"; var result = input.ParseName(); var expect = new NameParts { GivenName = "John", Surname = "von Smith" }; Verify(result, expect); }