Beispiel #1
0
        public void MigrateIfNeeded_WritingSystemPrefsContainsAudioWritingSystem_IsMigratedCorrectly()
        {
            using (var e = new TestEnvironment())
            {
                const string language           = "english";
                string       writingSystemsPath = Path.Combine(e.ProjectPath, "WritingSystems");
                Directory.CreateDirectory(writingSystemsPath);
                e.WriteToPrefsFile(WritingSystemPrefsFileContent.SingleWritingSystem(language, language, "", "", "", 12, false, language, "", false, true));
                var migrator = new WritingSystemsMigrator(e.ProjectPath);
                migrator.MigrateIfNecessary();

                AssertThatXmlIn.File(e.WritingSystemFilePath("qaa-Zxxx-x-english-audio")).HasAtLeastOneMatchForXpath(
                    "/ldml/identity/language[@type='qaa']"
                    );
                AssertThatXmlIn.File(e.WritingSystemFilePath("qaa-Zxxx-x-english-audio")).HasAtLeastOneMatchForXpath(
                    "/ldml/identity/script[@type='Zxxx']"
                    );
                AssertThatXmlIn.File(e.WritingSystemFilePath("qaa-Zxxx-x-english-audio")).HasNoMatchForXpath(
                    "/ldml/identity/territory"
                    );
                AssertThatXmlIn.File(e.WritingSystemFilePath("qaa-Zxxx-x-english-audio")).HasAtLeastOneMatchForXpath(
                    "/ldml/identity/variant[@type='x-english-audio']"
                    );
            }
        }
Beispiel #2
0
        public void MigrateIfNecessary_WsPrefsFileContainsRfcTagThatChangesOnMigration_MigrationDelegateIsCalled()
        {
            using (var environment = new TestEnvironment())
            {
                const string language = "en";
                const bool   isAudio  = true;
                environment.WriteContentToWsPrefsFile(WritingSystemPrefsFileContent.SingleWritingSystem(language, language,
                                                                                                        "", "", "", 0, false, "", "", true, isAudio)
                                                      );
                bool delegateCalledCorrectly = false;
                var  migrator = new WritingSystemPrefsMigrator(
                    environment.WsPrefsFilePath,
                    delegate(IEnumerable <LdmlVersion0MigrationStrategy.MigrationInfo> oldToNewRfcTagsMap)
                {
                    if (oldToNewRfcTagsMap.
                        First(info => info.RfcTagBeforeMigration == "en").
                        RfcTagAfterMigration == "en-Zxxx-x-audio")
                    {
                        delegateCalledCorrectly = true;
                    }
                }
                    );
                migrator.MigrateIfNecassary();

                Assert.IsTrue(delegateCalledCorrectly);
            }
        }
Beispiel #3
0
 //OptionLists can have any file name it seems. So we need to make sure that we don't
 //choke on load and don't change anything.
 public void MigrateIfNeeded_FileIsNotOptionList_LeftAlone()
 {
     using (var e = new TestEnvironment())
     {
         const string optionListContent = "Just some text in a file.";
         e.WriteToPrefsFile(WritingSystemPrefsFileContent.TwoWritingSystems("bogusws1", "bogusws2"));
         var optionListPath = Path.Combine(e.ProjectPath, "options.xml");
         File.WriteAllText(optionListPath, optionListContent);
         var migrator = new WritingSystemsMigrator(e.ProjectPath);
         migrator.MigrateIfNecessary();
         Assert.AreEqual(optionListContent, File.ReadAllText(optionListPath));
     }
 }
Beispiel #4
0
        public void MigrateIfNeeded_HasPrefsFile_LdmlLastestVersion()
        {
            using (var e = new TestEnvironment())
            {
                e.WriteToPrefsFile(WritingSystemPrefsFileContent.SingleWritingSystemForLanguage("qaa-x-test"));
                var migrator = new WritingSystemsMigrator(e.ProjectPath);
                migrator.MigrateIfNecessary();

                AssertThatXmlIn.File(e.WritingSystemFilePath("qaa-x-test")).HasAtLeastOneMatchForXpath(
                    String.Format("/ldml/special/palaso:version[@value='{0}']", WritingSystemDefinition.LatestWritingSystemDefinitionVersion),
                    e.NamespaceManager);
            }
        }
Beispiel #5
0
 public void MigrateIfNeeded_PrefsFileContainsIdThatIsNotMigrated_WritingSystemChangeLogDoesNotExist()
 {
     using (var e = new TestEnvironment())
     {
         e.WriteToPrefsFile(WritingSystemPrefsFileContent.SingleWritingSystemForLanguage("en"));
         string writingSystemsPath  = Path.Combine(e.ProjectPath, "WritingSystems");
         string idChangeLogFilePath = Path.Combine(writingSystemsPath, "idchangelog.xml");
         Directory.CreateDirectory(writingSystemsPath);
         var migrator = new WritingSystemsMigrator(e.ProjectPath);
         migrator.MigrateIfNecessary();
         // The change log does not exist because no id needed migrating
         Assert.That(File.Exists(idChangeLogFilePath), Is.Not.True);
     }
 }
Beispiel #6
0
 public void MigrateIfNeeded_PrefsFileContainsIdThatIsMigrated_WritingSystemChangeLogIsUpdated()
 {
     using (var e = new TestEnvironment())
     {
         const string language = "en";
         e.WriteToPrefsFile(WritingSystemPrefsFileContent.SingleWritingSystem(language, language, "", "", "", 12, false, language, "", false, true));
         string writingSystemsPath  = Path.Combine(e.ProjectPath, "WritingSystems");
         string idChangeLogFilePath = Path.Combine(writingSystemsPath, "idchangelog.xml");
         Directory.CreateDirectory(writingSystemsPath);
         var migrator = new WritingSystemsMigrator(e.ProjectPath);
         migrator.MigrateIfNecessary();
         AssertThatXmlIn.File(idChangeLogFilePath).HasAtLeastOneMatchForXpath("/WritingSystemChangeLog/Changes/Change/To[text()='en-Zxxx-x-audio']");
     }
 }
Beispiel #7
0
        public void MigrateIfNecessary_SuccessfulMigration_LegacyFileIsDeleted()
        {
            using (var environment = new TestEnvironment())
            {
                environment.WriteContentToWsPrefsFile(WritingSystemPrefsFileContent.SingleWritingSystem("en", "",
                                                                                                        "", "", "", 0, false, "", "", true, false)
                                                      );
                var migrator = new WritingSystemPrefsMigrator(
                    environment.WsPrefsFilePath,
                    environment.ChangeRfcTags);
                migrator.MigrateIfNecassary();

                Assert.That(File.Exists(environment.WsPrefsFilePath), Is.False);
            }
        }
Beispiel #8
0
        public void MigrateIfNecessary_WsPrefsFileContainsMultipleWs_MultipleLdmlFilesAreCreated()
        {
            using (var environment = new TestEnvironment())
            {
                environment.WriteContentToWsPrefsFile(WritingSystemPrefsFileContent.TwoWritingSystems("bogus1", "bogus2")
                                                      );
                var migrator = new WritingSystemPrefsMigrator(
                    environment.WsPrefsFilePath,
                    environment.ChangeRfcTags);
                migrator.MigrateIfNecassary();

                Assert.That(File.Exists(environment.GetFileForOriginalRfcTag("bogus1")), Is.True);
                Assert.That(File.Exists(environment.GetFileForOriginalRfcTag("bogus2")), Is.True);
            }
        }
Beispiel #9
0
        public void MigrateIfNecessary_DateModified_IsSetToRecentTime()
        {
            using (var environment = new TestEnvironment())
            {
                environment.WriteContentToWsPrefsFile(WritingSystemPrefsFileContent.SingleWritingSystem("en", "",
                                                                                                        "", "", "", 0, false, "", "", true, false)
                                                      );
                var migrator = new WritingSystemPrefsMigrator(
                    environment.WsPrefsFilePath,
                    environment.ChangeRfcTags);
                migrator.MigrateIfNecassary();
                string pathToEnFile = environment.GetFileForOriginalRfcTag("en");

                AssertThatXmlIn.File(pathToEnFile).HasNoMatchForXpath("/ldml/identity/generation[@date = '0001-01-01T00:00:00']");
            }
        }
Beispiel #10
0
 public void MigrateIfNecessary_WsPrefsFileContainsWsWithNoSortInfoSpecified_LdmlContainsNoSortInfo()
 {
     using (var environment = new TestEnvironment())
     {
         const string id = "en";
         environment.WriteContentToWsPrefsFile(WritingSystemPrefsFileContent.SingleWritingSystem(id, "",
                                                                                                 "", "", "", 0, false, "", "", true, false)
                                               );
         var migrator = new WritingSystemPrefsMigrator(
             environment.WsPrefsFilePath,
             environment.ChangeRfcTags);
         migrator.MigrateIfNecassary();
         string pathToEnFile = environment.GetFileForOriginalRfcTag("en");
         AssertThatXmlIn.File(pathToEnFile).HasNoMatchForXpath("/ldml/collations/collation");
     }
 }
Beispiel #11
0
 public void MigrateIfNecessary_WsPrefsFileContainsWsContainingRightToLeftIsFalse_CharacterOrientationIsnotContainedInLdml()
 {
     using (var environment = new TestEnvironment())
     {
         const bool rightToleft = false;
         environment.WriteContentToWsPrefsFile(WritingSystemPrefsFileContent.SingleWritingSystem("en", "",
                                                                                                 "", "", "", 0, rightToleft, "", "", true, false)
                                               );
         var migrator = new WritingSystemPrefsMigrator(
             environment.WsPrefsFilePath,
             environment.ChangeRfcTags);
         migrator.MigrateIfNecassary();
         string pathToEnFile = environment.GetFileForOriginalRfcTag("en");
         AssertThatXmlIn.File(pathToEnFile).
         HasNoMatchForXpath("/ldml/layout/orientation/@characters");
     }
 }
Beispiel #12
0
        public void MigrateIfNeeded_LiftFileIsVersionOtherThanWhatWeKnowTheWritingSystemMigratorCanChange_LeavesLiftAlone()
        {
            using (var e = new TestEnvironment())
            {
                WriteStringToFileAtXpath(e.PathToLiftFile, "/lift[@version]", "0.12");

                e.WriteToPrefsFile(WritingSystemPrefsFileContent.TwoWritingSystems("bogusws1", "bogusws2"));
                var migrator = new WritingSystemsMigrator(e.ProjectPath);
                migrator.MigrateIfNecessary();
                var doc = new XmlDocument();
                doc.Load(e.PathToLiftFile);
                XmlNodeList nodes = doc.SelectNodes("//@lang");

                Assert.AreEqual("bogusws1", nodes.Item(0).InnerText);
                Assert.AreEqual("bogusws2", nodes.Item(1).InnerText);
            }
        }
Beispiel #13
0
 public void MigrateIfNeeded_WSPrefsAndLdmlV0ContainsIdsThatNeedMigrating_WritingSystemChangeLogUpdated()
 {
     using (var e = new TestEnvironment())
     {
         const string language = "zzas";
         e.WriteToPrefsFile(WritingSystemPrefsFileContent.SingleWritingSystem(language, language, "", "", "", 12, false, language, "", false, true));
         string writingSystemsPath  = Path.Combine(e.ProjectPath, "WritingSystems");
         string ldmlFilePath        = Path.Combine(writingSystemsPath, "en-bogus.ldml");
         string idChangeLogFilePath = Path.Combine(writingSystemsPath, "idchangelog.xml");
         Directory.CreateDirectory(writingSystemsPath);
         File.WriteAllText(ldmlFilePath, LdmlContentForTests.Version0("en-bogus", "", "", ""));
         var migrator = new WritingSystemsMigrator(e.ProjectPath);
         migrator.MigrateIfNecessary();
         AssertThatXmlIn.File(idChangeLogFilePath).HasAtLeastOneMatchForXpath("/WritingSystemChangeLog/Changes/Change/To[text()='en-x-bogus']");
         AssertThatXmlIn.File(idChangeLogFilePath).HasAtLeastOneMatchForXpath("/WritingSystemChangeLog/Changes/Change/To[text()='qaa-Zxxx-x-zzas-audio']");
     }
 }
Beispiel #14
0
 public void MigrateIfNeeded_OptionListContainsWritingSystemIdThatIsMigrated_WritingSystemIdIsChanged()
 {
     using (var e = new TestEnvironment())
     {
         e.WriteToPrefsFile(WritingSystemPrefsFileContent.TwoWritingSystems("bogusws1", "bogusws2"));
         var optionListPath = Path.Combine(e.ProjectPath, "options.xml");
         File.WriteAllText(optionListPath, OptionListFileContent.GetOptionListWithWritingSystems("bogusws1", "bogusws2"));
         var migrator = new WritingSystemsMigrator(e.ProjectPath);
         migrator.MigrateIfNecessary();
         var doc = new XmlDocument();
         doc.Load(optionListPath);
         XmlNodeList nameNodes = doc.SelectNodes("//name/form/@lang");
         Assert.AreEqual("qaa-x-bogusws1", nameNodes.Item(0).InnerText);
         Assert.AreEqual("qaa-x-bogusws2", nameNodes.Item(1).InnerText);
         nameNodes = doc.SelectNodes("//abbreviation/form/@lang");
         Assert.AreEqual("qaa-x-bogusws1", nameNodes.Item(0).InnerText);
         Assert.AreEqual("qaa-x-bogusws2", nameNodes.Item(1).InnerText);
     }
 }
Beispiel #15
0
 public void MigrateIfNecessary_WsPrefsFileContainsWsContainingCustomIcuSortRules_CustomSortRulesAreInLdml()
 {
     using (var environment = new TestEnvironment())
     {
         const string sortUsing = "CustomICU";
         const string sortRules = "&amp; C &lt; č";
         environment.WriteContentToWsPrefsFile(WritingSystemPrefsFileContent.SingleWritingSystem("en", "", sortUsing, sortRules, "", 0, false, "", "", true, false)
                                               );
         var migrator = new WritingSystemPrefsMigrator(
             environment.WsPrefsFilePath,
             environment.ChangeRfcTags);
         migrator.MigrateIfNecassary();
         string pathToEnFile = environment.GetFileForOriginalRfcTag("en");
         AssertThatXmlIn.File(pathToEnFile).HasAtLeastOneMatchForXpath(
             String.Format("/ldml/collations/collation/special/palaso:sortRulesType[@value='{0}']", sortUsing), environment.NamespaceManager
             );
         AssertThatXmlIn.File(pathToEnFile).HasAtLeastOneMatchForXpath("/ldml/collations/collation/rules/p");                 //Only checking one character. Hopefully this means the rest are there too.
     }
 }
Beispiel #16
0
        public void MigrateIfNecessary_LdmlForWritingSystemInWsPrefsFileAlreadyExists_LdmlIsCreatedForOtherWritingSystemsInWsPrefsFile()
        {
            using (var environment = new TestEnvironment())
            {
                environment.WriteContentToWsPrefsFile(WritingSystemPrefsFileContent.TwoWritingSystems("en", "de")
                                                      );
                var ws = WritingSystemDefinition.Parse("en");
                ws.Abbreviation = "untouched";
                var wsRepo = environment.WritingSystems;
                wsRepo.Set(ws);
                wsRepo.Save();

                var migrator = new WritingSystemPrefsMigrator(
                    environment.WsPrefsFilePath,
                    environment.ChangeRfcTags);
                migrator.MigrateIfNecassary();

                Assert.That(File.Exists(environment.GetFileForOriginalRfcTag("de")), Is.True);
            }
        }
Beispiel #17
0
 public void MigrateIfNecessary_WsPrefsFileContainsWsContainingFontSize_FontSizeIsInLdml()
 {
     using (var environment = new TestEnvironment())
     {
         const int fontSize = 12;
         environment.WriteContentToWsPrefsFile(WritingSystemPrefsFileContent.SingleWritingSystem("en", "",
                                                                                                 "", "", "", fontSize, false, "", "", true, false)
                                               );
         var migrator = new WritingSystemPrefsMigrator(
             environment.WsPrefsFilePath,
             environment.ChangeRfcTags);
         migrator.MigrateIfNecassary();
         string pathToEnFile = environment.GetFileForOriginalRfcTag("en");
         AssertThatXmlIn.File(pathToEnFile).
         HasAtLeastOneMatchForXpath(String.Format(
                                        "/ldml/special/palaso:defaultFontSize[@value='{0}']", fontSize),
                                    environment.NamespaceManager
                                    );
     }
 }
Beispiel #18
0
 public void MigrateIfNecessary_WsPrefsFileContainsWsContainingId_IdIsInLdml()
 {
     using (var environment = new TestEnvironment())
     {
         const string id = "en-US-fonipa-x-etic";
         environment.WriteContentToWsPrefsFile(WritingSystemPrefsFileContent.SingleWritingSystem(id, "",
                                                                                                 "", "", "", 0, false, "", "", true, false)
                                               );
         var migrator = new WritingSystemPrefsMigrator(
             environment.WsPrefsFilePath,
             environment.ChangeRfcTags);
         migrator.MigrateIfNecassary();
         string pathToEnFile = environment.GetFileForOriginalRfcTag(id);
         AssertThatXmlIn.File(pathToEnFile).
         HasAtLeastOneMatchForXpath(String.Format(
                                        "/ldml/identity/language[@type='{0}']", id),
                                    environment.NamespaceManager
                                    );
     }
 }
Beispiel #19
0
 public void MigrateIfNecessary_WsPrefsFileContainsWsContainingKeyboardName_KeyboardNameIsInLdml()
 {
     using (var environment = new TestEnvironment())
     {
         const string keyboardName = "IPA Unicode 5.1(ver 1.2 US) MSK";
         environment.WriteContentToWsPrefsFile(WritingSystemPrefsFileContent.SingleWritingSystem("en", "",
                                                                                                 "", "", "", 0, false, "", keyboardName, true, false)
                                               );
         var migrator = new WritingSystemPrefsMigrator(
             environment.WsPrefsFilePath,
             environment.ChangeRfcTags);
         migrator.MigrateIfNecassary();
         string pathToEnFile = environment.GetFileForOriginalRfcTag("en");
         AssertThatXmlIn.File(pathToEnFile).
         HasAtLeastOneMatchForXpath(String.Format(
                                        "/ldml/special/palaso:defaultKeyboard[@value='{0}']", keyboardName),
                                    environment.NamespaceManager
                                    );
     }
 }
Beispiel #20
0
        public void MigrateIfNecessary_WsPrefsFileContainsWsContainingIsAudioIsFalse_AudioIsRemovedFromRfcTag()
        {
            using (var environment = new TestEnvironment())
            {
                const string id = "en-Audio";
                environment.WriteContentToWsPrefsFile(WritingSystemPrefsFileContent.SingleWritingSystem(id, "",
                                                                                                        "", "", "", 0, false, "", "", true, false)
                                                      );
                var migrator = new WritingSystemPrefsMigrator(
                    environment.WsPrefsFilePath,
                    environment.ChangeRfcTags);
                migrator.MigrateIfNecassary();
                string pathToEnFile = environment.GetFileForOriginalRfcTag(id);

                AssertThatXmlIn.File(pathToEnFile).HasAtLeastOneMatchForXpath("/ldml/identity/language[@type = 'en']");
                AssertThatXmlIn.File(pathToEnFile).HasNoMatchForXpath("/ldml/identity/script");
                AssertThatXmlIn.File(pathToEnFile).HasNoMatchForXpath("/ldml/identity/region");
                AssertThatXmlIn.File(pathToEnFile).HasNoMatchForXpath("/ldml/identity/variant");
            }
        }
Beispiel #21
0
 public void MigrateIfNecessary_WsPrefsFileContainsSpellCheckingId_SpellCheckingIdIsInLdml()
 {
     using (var environment = new TestEnvironment())
     {
         const string spellCheckingId = "spell";
         environment.WriteContentToWsPrefsFile(WritingSystemPrefsFileContent.SingleWritingSystem("en", "",
                                                                                                 "", "", "", 0, false, spellCheckingId, "", true, false)
                                               );
         var migrator = new WritingSystemPrefsMigrator(
             environment.WsPrefsFilePath,
             environment.ChangeRfcTags);
         migrator.MigrateIfNecassary();
         string pathToEnFile = environment.GetFileForOriginalRfcTag("en");
         AssertThatXmlIn.File(pathToEnFile).
         HasAtLeastOneMatchForXpath(String.Format(
                                        "/ldml/special/palaso:spellCheckingId[@value='{0}']", spellCheckingId),
                                    environment.NamespaceManager
                                    );
     }
 }
Beispiel #22
0
 public void MigrateIfNecessary_WsPrefsFileContainsWsContainingIsUnicodeEncodedIsTrue_IsLegacyDoesNotAppearInLdml()
 {
     using (var environment = new TestEnvironment())
     {
         const bool isUnicodeEncoded = true;
         environment.WriteContentToWsPrefsFile(WritingSystemPrefsFileContent.SingleWritingSystem("en", "",
                                                                                                 "", "", "", 0, false, "", "", isUnicodeEncoded, false)
                                               );
         var migrator = new WritingSystemPrefsMigrator(
             environment.WsPrefsFilePath,
             environment.ChangeRfcTags);
         migrator.MigrateIfNecassary();
         string pathToEnFile = environment.GetFileForOriginalRfcTag("en");
         AssertThatXmlIn.File(pathToEnFile).
         HasNoMatchForXpath(
             "/ldml/special/palaso:isLegacyEncoded",
             environment.NamespaceManager
             );
     }
 }
Beispiel #23
0
 public void MigrateIfNecessary_WsPrefsFileContainsWsContainingSortRulesFromOtherLanguage_OtherLanguageIsInLdml()
 {
     using (var environment = new TestEnvironment())
     {
         const string otherLanguage = "de";
         environment.WriteContentToWsPrefsFile(WritingSystemPrefsFileContent.SingleWritingSystem("en", "",
                                                                                                 otherLanguage, "", "", 0, false, "", "", true, false)
                                               );
         var migrator = new WritingSystemPrefsMigrator(
             environment.WsPrefsFilePath,
             environment.ChangeRfcTags);
         migrator.MigrateIfNecassary();
         string pathToEnFile = environment.GetFileForOriginalRfcTag("en");
         AssertThatXmlIn.File(pathToEnFile).
         HasAtLeastOneMatchForXpath(String.Format(
                                        "/ldml/collations/collation/base/alias[@source='{0}']", otherLanguage),
                                    environment.NamespaceManager
                                    );
     }
 }
Beispiel #24
0
        public void MigrateIfNecessary_WsPrefsFileContainsWsContainingIsAudioIsTrueAndrfcTagAlreadyHasScript_ScriptContainsZxxxAndVariantContainsXDashAudioDashScript()
        {
            using (var environment = new TestEnvironment())
            {
                const string language = "en-Latn";
                const bool   isAudio  = true;
                environment.WriteContentToWsPrefsFile(WritingSystemPrefsFileContent.SingleWritingSystem(language, "",
                                                                                                        "", "", "", 0, false, "", "", true, isAudio)
                                                      );
                var migrator = new WritingSystemPrefsMigrator(
                    environment.WsPrefsFilePath,
                    environment.ChangeRfcTags);
                migrator.MigrateIfNecassary();
                string pathToEnFile = environment.GetFileForOriginalRfcTag(language);

                AssertThatXmlIn.File(pathToEnFile).HasAtLeastOneMatchForXpath("/ldml/identity/language[@type = 'en-Latn']");
                AssertThatXmlIn.File(pathToEnFile).HasAtLeastOneMatchForXpath("/ldml/identity/script[@type = 'Zxxx']");
                AssertThatXmlIn.File(pathToEnFile).HasNoMatchForXpath("/ldml/identity/region");
                AssertThatXmlIn.File(pathToEnFile).HasAtLeastOneMatchForXpath("/ldml/identity/variant[@type = 'x-audio']");
            }
        }
Beispiel #25
0
 public void MigrateIfNeeded_ConfigFileContainsWritingSystemIdThatIsMigrated_WritingSystemIdIsChanged()
 {
     using (var e = new TestEnvironment())
     {
         e.WriteToPrefsFile(WritingSystemPrefsFileContent.TwoWritingSystems("bogusws1", "bogusws2"));
         var migrator = new WritingSystemsMigrator(e.ProjectPath);
         migrator.MigrateIfNecessary();
         AssertThatXmlIn.File(e.PathToConfigFile).HasAtLeastOneMatchForXpath(
             "/configuration/components/viewTemplate/fields/field/writingSystems/id[1][text()='qaa-x-bogusws1']"
             );
         AssertThatXmlIn.File(e.PathToConfigFile).HasAtLeastOneMatchForXpath(
             "/configuration/components/viewTemplate/fields/field/writingSystems/id[2][text()='qaa-x-bogusws2']"
             );
         AssertThatXmlIn.File(e.PathToConfigFile).HasAtLeastOneMatchForXpath(
             "/configuration/tasks/task/writingSystemsToMatch[text()='qaa-x-bogusws1, qaa-x-bogusws2']"
             );
         AssertThatXmlIn.File(e.PathToConfigFile).HasAtLeastOneMatchForXpath(
             "/configuration/tasks/task/writingSystemsWhichAreRequired[text()='qaa-x-bogusws1, qaa-x-bogusws2']"
             );
     }
 }
Beispiel #26
0
        public void MigrateIfNecessary_LdmlForWritingSystemInWsPrefsFileAlreadyExists_LdmlIsUntouched()
        {
            using (var environment = new TestEnvironment())
            {
                environment.WriteContentToWsPrefsFile(WritingSystemPrefsFileContent.SingleWritingSystemForLanguage("en"));

                var ws = WritingSystemDefinition.Parse("en");
                ws.Abbreviation = "untouched";
                var wsRepo = environment.WritingSystems;
                wsRepo.Set(ws);
                wsRepo.Save();

                var migrator = new WritingSystemPrefsMigrator(
                    environment.WsPrefsFilePath,
                    environment.ChangeRfcTags);
                migrator.MigrateIfNecassary();

                AssertThatXmlIn.File(environment.GetFileForOriginalRfcTag("en")).HasAtLeastOneMatchForXpath(
                    "/ldml/special/palaso:abbreviation[@value='untouched']",
                    environment.NamespaceManager);
            }
        }
Beispiel #27
0
        public void MigrateIfNeeded_LiftFileContainsWritingSystemIdThatIsMigrated_WritingSystemIdIsChanged()
        {
            using (var e = new TestEnvironment())
            {
                e.WriteToPrefsFile(WritingSystemPrefsFileContent.TwoWritingSystems("bogusws1", "bogusws2"));
                var migrator = new WritingSystemsMigrator(e.ProjectPath);
                migrator.MigrateIfNecessary();
                var doc = new XmlDocument();
                doc.Load(e.PathToLiftFile);
                XmlNodeList nodes = doc.SelectNodes("//@lang");

                Assert.AreEqual("qaa-x-bogusws1", nodes.Item(0).InnerText);
                Assert.AreEqual("qaa-x-bogusws2", nodes.Item(1).InnerText);

                //The below doesn't work correctly unfortunately
                //AssertThatXmlIn.File(e.PathToLiftFile).HasAtLeastOneMatchForXpath(
                //        "//[@lang[1]='x-bogusws1']"
                //    );
                //AssertThatXmlIn.File(e.PathToLiftFile).HasAtLeastOneMatchForXpath(
                //        "//[@lang[2]='x-bogusws2']"
                //    );
            }
        }