GetDicPath() static private method

Get the path for the dictionary for a particular locale, if it is one of our private ones, given the path to the directory where we make them and the icuLocale.
static private GetDicPath ( string dirPath, string icuLocale ) : string
dirPath string
icuLocale string
return string
Esempio n. 1
0
        public void EnsureDictionaryDoesNotOverwriteNonVernacularDictionary()
        {
            const string dictId   = "nonvern";
            const string testWord = "testWord";

            Directory.CreateDirectory(SpellingHelper.GetSpellingDirectoryPath());
            var filePath = SpellingHelper.GetDicPath(SpellingHelper.GetSpellingDirectoryPath(), dictId);

            // Wipe out any files related to our fake test dictionary
            File.Delete(SpellingHelper.GetExceptionFileName(filePath));
            File.Delete(filePath);
            File.Delete(Path.ChangeExtension(filePath, ".aff"));

            //build new fake test dictionary that is not vernacular
            var nonverndict = @"10" + Environment.NewLine + testWord + Environment.NewLine;
            var nonvernaff  = @"SET UTF-8" + Environment.NewLine + "KEEPCASE C" + Environment.NewLine;

            File.WriteAllText(filePath, nonverndict);
            File.WriteAllText(Path.ChangeExtension(filePath, ".aff"), nonvernaff);
            //SUT
            SpellingHelper.EnsureDictionary(dictId);
            //read back the hopefully unaffected dictionary
            var contents = File.ReadAllText(filePath);

            Assert.That(contents, Is.Not.StringContaining(SpellingHelper.PrototypeWord));
            Assert.That(contents, Contains.Substring(testWord));
        }
Esempio n. 2
0
        public void ResetDictionary_AddsNoWordsToNonPrivate()
        {
            MakeNonPrivateBlahDictionary();
            SpellingHelper.ResetDictionary("blah", new[] { "hello", "world" });
            var filePath = SpellingHelper.GetDicPath(SpellingHelper.GetSpellingDirectoryPath(), "blah");
            var contents = File.ReadAllText(filePath);

            Assert.That(contents, Is.Not.StringContaining(SpellingHelper.PrototypeWord));
            Assert.That(contents, Is.Not.StringContaining("hello"));
            Assert.That(contents, Is.Not.StringContaining("world"));
            Assert.That(contents, Contains.Substring("blah"));
        }
Esempio n. 3
0
        private static string MakeEmptyDictionary(string dictId)
        {
            Directory.CreateDirectory(SpellingHelper.GetSpellingDirectoryPath());
            var filePath = SpellingHelper.GetDicPath(SpellingHelper.GetSpellingDirectoryPath(), dictId);

            // We must delete this FIRST, because we can't get the correct name for the affix file once we delete the main dictionary one.
            File.Delete(SpellingHelper.GetExceptionFileName(filePath));
            File.Delete(filePath);
            File.Delete(Path.ChangeExtension(filePath, ".aff"));
            SpellingHelper.EnsureDictionary(dictId);
            return(dictId);
        }
Esempio n. 4
0
        public void ExceptionListIsLoadedForNonVernacularDictionary()
        {
            MakeNonPrivateBlahDictionary();
            var filePath = SpellingHelper.GetDicPath(SpellingHelper.GetSpellingDirectoryPath(), "blah");

            using (var writer = FileUtils.OpenFileForWrite(Path.ChangeExtension(filePath, ".exc"), Encoding.UTF8))
            {
                writer.WriteLine("good");
            }
            var dict = SpellingHelper.GetSpellChecker("blah");

            Assert.That(dict.Check("good"), Is.True);
        }
Esempio n. 5
0
        private static void MakeNonPrivateBlahDictionary()
        {
            string dirPath = SpellingHelper.GetSpellingDirectoryPath();

            if (!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath);
            }
            string filePath = SpellingHelper.GetDicPath(dirPath, "blah");

            File.Delete(filePath);
            File.Delete(Path.ChangeExtension(filePath, ".aff"));
            File.Delete(Path.ChangeExtension(filePath, ".exc"));
            using (var writer = FileUtils.OpenFileForWrite(Path.ChangeExtension(filePath, ".aff"), Encoding.UTF8))
            {
                writer.WriteLine("SET UTF-8");
            }
            using (var writer = FileUtils.OpenFileForWrite(filePath, Encoding.UTF8))
            {
                writer.WriteLine("10");
                writer.WriteLine("blah");
            }
        }