Exemplo n.º 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']"
                    );
            }
        }
Exemplo n.º 2
0
 public void MigrateIfNeeded_NoWritingSystemsExist_DoesNotThrow()
 {
     using (var e = new TestEnvironment())
     {
         var migrator = new WritingSystemsMigrator(e.ProjectPath);
         migrator.MigrateIfNecessary();
     }
 }
Exemplo n.º 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));
     }
 }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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']");
     }
 }
Exemplo n.º 7
0
        public void MigrateIfNeeded_LdmlV0ContainsIdThatNeedsMigrating_WritingSystemChangeLogUpdated()
        {
            using (var e = new TestEnvironment())
            {
                string writingSystemsPath  = Path.Combine(e.ProjectPath, "WritingSystems");
                string ldmlFilePath        = Path.Combine(writingSystemsPath, "blah.ldml");
                string idChangeLogFilePath = Path.Combine(writingSystemsPath, "idchangelog.xml");
                Directory.CreateDirectory(writingSystemsPath);
                File.WriteAllText(ldmlFilePath, LdmlContentForTests.Version0("blah", "", "", ""));
                var migrator = new WritingSystemsMigrator(e.ProjectPath);
                migrator.MigrateIfNecessary();

                AssertThatXmlIn.File(idChangeLogFilePath).HasAtLeastOneMatchForXpath("/WritingSystemChangeLog/Changes/Change/To[text()='qaa-x-blah']");
            }
        }
Exemplo n.º 8
0
 public void MigrateIfNeeded_LdmlV0ContainsIdThatIsNotMigrated_WritingSystemChangeLogDoesNotExist()
 {
     using (var e = new TestEnvironment())
     {
         string writingSystemsPath  = Path.Combine(e.ProjectPath, "WritingSystems");
         string ldmlFilePath        = Path.Combine(writingSystemsPath, "en.ldml");
         string idChangeLogFilePath = Path.Combine(writingSystemsPath, "idchangelog.xml");
         Directory.CreateDirectory(writingSystemsPath);
         File.WriteAllText(ldmlFilePath, LdmlContentForTests.Version0English());
         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);
     }
 }
Exemplo n.º 9
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);
            }
        }
Exemplo n.º 10
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']");
     }
 }
Exemplo n.º 11
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);
     }
 }
Exemplo n.º 12
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']"
             );
     }
 }
Exemplo n.º 13
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']"
                //    );
            }
        }