Пример #1
0
        public void NewStringsAdded()
        {
            using (var testDir = new TemporaryFolder(GetType().Name))
            {
                var poFile = testDir.Combine("mesages.de.po");
                File.WriteAllText(poFile, DePoData);
                var stringsFile = testDir.Combine("strings-de.xml");
                File.WriteAllText(stringsFile, DeStringsData);

                // SUT
                PoToXml.StoreLocalizedStrings(poFile, stringsFile, null);

                var result = File.ReadAllText(stringsFile);
                // The resulting file should contain the 5 original groups plus 3 new (attributes, literals, context help)
                AssertThatXmlIn.String(result).HasSpecifiedNumberOfMatchesForXpath("/strings/group", 8);
                const string attGroupXpath = "/strings/group[@id='LocalizedAttributes']";
                AssertThatXmlIn.String(result).HasSpecifiedNumberOfMatchesForXpath(attGroupXpath, 1);
                const string attStringXpath = attGroupXpath + "/string";
                AssertThatXmlIn.String(result).HasSpecifiedNumberOfMatchesForXpath(attStringXpath, 6);
                AssertThatXmlIn.String(result).HasSpecifiedNumberOfMatchesForXpath(
                    attStringXpath + "[@id='Abbreviation (Best Analysis)' and @txt='Abkürzung (Bestes Analyse)']", 1);
                AssertThatXmlIn.String(result).HasSpecifiedNumberOfMatchesForXpath(
                    attStringXpath + "[@id='Allomorph' and @txt='Allomorph']", 1);
                AssertThatXmlIn.String(result).HasSpecifiedNumberOfMatchesForXpath(
                    attStringXpath + "[@id='Choose {0}' and @txt='{0} wählen']", 1);
                AssertThatXmlIn.String(result).HasSpecifiedNumberOfMatchesForXpath(
                    attStringXpath + "[@id='Comment' and @txt='Kommentar']", 1);
                const string litGroupXpath = "/strings/group[@id='LocalizedLiterals']";
                AssertThatXmlIn.String(result).HasSpecifiedNumberOfMatchesForXpath(litGroupXpath, 1);
                const string litStringXpath = litGroupXpath + "/string";
                AssertThatXmlIn.String(result).HasSpecifiedNumberOfMatchesForXpath(litStringXpath, 2);
                AssertThatXmlIn.String(result).HasSpecifiedNumberOfMatchesForXpath(
                    litStringXpath + "[@id='Allomorph' and @txt='Allomorph']", 1);
                AssertThatXmlIn.String(result).HasSpecifiedNumberOfMatchesForXpath(
                    litStringXpath + "[@id='Analysis ' and @txt='Analyse ']", 1);
                const string helpGroupXpath = "/strings/group[@id='LocalizedContextHelp']";
                AssertThatXmlIn.String(result).HasSpecifiedNumberOfMatchesForXpath(helpGroupXpath, 1);
                const string helpStringXpath = helpGroupXpath + "/string";
                AssertThatXmlIn.String(result).HasSpecifiedNumberOfMatchesForXpath(helpStringXpath, 5);
                AssertThatXmlIn.String(result).HasSpecifiedNumberOfMatchesForXpath(
                    helpStringXpath + "[@id='AllomorphAdjacency']", 1);
                AssertThatXmlIn.String(result).HasSpecifiedNumberOfMatchesForXpath(
                    helpStringXpath + "[@id='AllomorphAdjacency' and @txt='Klicken Sie auf die Taste.']", 1);
                AssertThatXmlIn.String(result).HasSpecifiedNumberOfMatchesForXpath(
                    helpStringXpath + "[@id='CmdInsertCustomItem' and @txt='Ein neues {0} erstellen.']", 1);
                AssertThatXmlIn.String(result).HasSpecifiedNumberOfMatchesForXpath(
                    helpStringXpath + "[@id='CmdInsertLexEntryType' and @txt='Ein neues {0} erstellen.']", 1);
                AssertThatXmlIn.String(result).HasSpecifiedNumberOfMatchesForXpath(
                    helpStringXpath + "[@id='CmdInsertPossibility' and @txt='Ein neues {0} erstellen.']", 1);
                AssertThatXmlIn.String(result).HasSpecifiedNumberOfMatchesForXpath(
                    helpStringXpath + "[@id='CmdCreateProjectShortcut' and @txt='Eine Desktop-Verknüpfung zu diesem Projekt erstellen.']", 1);
            }
        }
Пример #2
0
        public void StringsPreserved()
        {
            using (var testDir = new TemporaryFolder(GetType().Name))
            {
                var poFile = testDir.Combine("mesages.de.po");
                File.WriteAllText(poFile, DePoData);
                var stringsFile = testDir.Combine("strings-de.xml");
                File.WriteAllText(stringsFile, DeStringsData);

                // SUT
                PoToXml.StoreLocalizedStrings(poFile, stringsFile, null);

                var fullFileContent = File.ReadAllText(stringsFile);
                AssertThatXmlStartsWith(XDocument.Parse(DeStringsData).Root, XDocument.Parse(fullFileContent).Root);
                Assert.Greater(fullFileContent.Length, DeStringsData.Length + 640,
                               "The resulting file should be considerably longer than the original. 640 characters ought to be enough (for anyone).");
            }
        }