예제 #1
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));
     }
 }
예제 #2
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);
            }
        }
예제 #3
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);
            }
        }
예제 #4
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);
     }
 }
예제 #5
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);
            }
        }
예제 #6
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']"
             );
     }
 }
예제 #7
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']"
                //    );
            }
        }