Ejemplo 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));
        }
Ejemplo n.º 2
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);
        }