public void NamesListNotInList() { // Arrange var namesList = new NameList(Directory.GetCurrentDirectory(), "fr", false, null); // Act var exists = namesList.GetNames().Contains("JonesASDFLKJCKJXFLKJSLDKFJASDF"); // Assert Assert.IsFalse(exists); }
public void NamesListAddWord() { // Arrange var namesList = new NameList(Directory.GetCurrentDirectory(), "sv", false, null); // Act namesList.Add("Jones123"); var exists = namesList.GetNames().Contains("Jones123"); // Assert Assert.IsTrue(exists); }
public void NamesListRemove() { // Arrange var namesList = new NameList(Directory.GetCurrentDirectory(), "de", false, null); namesList.Add("Jones123"); // Act namesList.Remove("Jones123"); // Assert Assert.IsFalse(namesList.GetNames().Contains("Jones123")); }
public void NamesListAddWordReload() { // Arrange var namesList = new NameList(Directory.GetCurrentDirectory(), "it", false, null); namesList.Add("Jones123"); // Act namesList = new NameList(Directory.GetCurrentDirectory(), "it", false, null); // Assert Assert.IsTrue(namesList.GetNames().Contains("Jones123")); }
public SpellCheckWordLists(string dictionaryFolder, string languageName, IDoSpell doSpell) { _dictionaryFolder = dictionaryFolder ?? throw new NullReferenceException(nameof(dictionaryFolder)); _languageName = languageName ?? throw new NullReferenceException(nameof(languageName)); _doSpell = doSpell ?? throw new NullReferenceException(nameof(doSpell)); _nameList = new NameList(Configuration.DictionariesDirectory, languageName, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl); _names = _nameList.GetNames(); var namesMultiWordList = _nameList.GetMultiNames(); if (Configuration.Settings.Tools.RememberUseAlwaysList) { LoadUseAlwaysList(); } foreach (string namesItem in _names) { _namesListUppercase.Add(namesItem.ToUpperInvariant()); } if (languageName.StartsWith("en_", StringComparison.OrdinalIgnoreCase)) { foreach (string namesItem in _names) { if (!namesItem.EndsWith('s')) { _namesListWithApostrophe.Add(namesItem + "'s"); _namesListWithApostrophe.Add(namesItem + "’s"); } else if (!namesItem.EndsWith('\'')) { _namesListWithApostrophe.Add(namesItem + "'"); } } } if (File.Exists(dictionaryFolder + languageName + "_user.xml")) { var userWordDictionary = new XmlDocument(); userWordDictionary.Load(dictionaryFolder + languageName + "_user.xml"); var xmlNodeList = userWordDictionary.DocumentElement?.SelectNodes("word"); if (xmlNodeList != null) { foreach (XmlNode node in xmlNodeList) { string word = node.InnerText.Trim().ToLowerInvariant(); if (word.Contains(' ')) { _userPhraseList.Add(word); } else { _userWordList.Add(word); } } } } // Add names/userdic with "." or " " or "-" foreach (var word in namesMultiWordList) { if (word.Contains(PeriodAndDash)) { _wordsWithDashesOrPeriods.Add(word); } } foreach (string name in _names) { if (name.Contains(PeriodAndDash)) { _wordsWithDashesOrPeriods.Add(name); } } foreach (string word in _userWordList) { if (word.Contains(PeriodAndDash)) { _wordsWithDashesOrPeriods.Add(word); } } foreach (var phrase in _userPhraseList) { if (phrase.Contains(PeriodAndDash)) { _wordsWithDashesOrPeriods.Add(phrase); } } }