public void TestWriteAndReadPoFile() { var poStrings = new List <POString>(); var fwLayoutDoc = XDocument.Parse(FwlayoutData); Assert.IsNotNull(fwLayoutDoc.Root); XmlToPo.ProcessConfigElement(fwLayoutDoc.Root, "/Language Explorer/Configuration/Parts/LexEntry.fwlayout", poStrings); var fwDictConfigDoc = XDocument.Parse(DictConfigData); Assert.IsNotNull(fwDictConfigDoc.Root); XmlToPo.ProcessFwDictConfigElement(fwDictConfigDoc.Root, "/Language Explorer/DefaultConfigurations/Dictionary/Root.fwdictconfig", poStrings); Assert.AreEqual(53, poStrings.Count); Assert.AreEqual("Lexeme Form", poStrings[0].MsgIdAsString()); Assert.AreEqual("modified on: ", poStrings[49].MsgIdAsString()); poStrings.Sort(POString.CompareMsgIds); // SUT POString.MergeDuplicateStrings(poStrings); Assert.AreEqual(40, poStrings.Count); Assert.AreEqual(" - ", poStrings[0].MsgIdAsString()); Assert.AreEqual("Variants", poStrings[39].MsgIdAsString()); var sw = new StringWriter(); XmlToPo.WritePotFile(sw, "/home/testing/fw", poStrings); var potFileStr = sw.ToString(); Assert.IsNotNull(potFileStr); var sr = new StringReader(potFileStr); var dictPot = PoToXml.ReadPoFile(sr, null); Assert.AreEqual(40, dictPot.Count); var listPot = dictPot.ToList(); Assert.AreEqual(" - ", listPot[0].Value.MsgIdAsString()); Assert.AreEqual("Variants", listPot[39].Value.MsgIdAsString()); var posHeadword = dictPot["Headword"]; Assert.AreEqual(6, posHeadword.AutoComments.Count, "Headword AutoComments"); Assert.AreEqual("/Language Explorer/Configuration/Parts/LexEntry.fwlayout::/LayoutInventory/layout[\"LexEntry-jtview-CrossRefPub\"]/part[@ref=\"MLHeadWordPub\"]/@label", posHeadword.AutoComments[0]); Assert.AreEqual("/Language Explorer/Configuration/Parts/LexEntry.fwlayout::/LayoutInventory/layout[\"LexEntry-jtview-SubentryUnderPub\"]/part[@ref=\"MLHeadWordPub\"]/@label", posHeadword.AutoComments[1]); Assert.AreEqual("/Language Explorer/DefaultConfigurations/Dictionary/Root.fwdictconfig:://ConfigurationItem[@name='Main Entry']/ConfigurationItem/@name", posHeadword.AutoComments[2]); Assert.AreEqual("/Language Explorer/DefaultConfigurations/Dictionary/Root.fwdictconfig:://ConfigurationItem[@name='MainEntrySubentries']/ConfigurationItem/@name", posHeadword.AutoComments[3]); Assert.AreEqual("/Language Explorer/DefaultConfigurations/Dictionary/Root.fwdictconfig:://ConfigurationItem[@name='Minor Entry (Complex Forms)']/ConfigurationItem/@name", posHeadword.AutoComments[4]); Assert.AreEqual("(String used 5 times.)", posHeadword.AutoComments[5]); var posComma = dictPot[", "]; Assert.AreEqual(4, posComma.AutoComments.Count, "AutoCommas"); Assert.AreEqual("/Language Explorer/DefaultConfigurations/Dictionary/Root.fwdictconfig:://ConfigurationItem[@name='Allomorphs']/@between", posComma.AutoComments[0]); Assert.AreEqual("(String used 3 times.)", posComma.AutoComments[3]); }
public void ReadPoData() { var srIn = new StringReader(FrenchPoData); var dictFrenchPo = PoToXml.ReadPoFile(srIn, null); var rgsPoStrings = dictFrenchPo.ToList(); var postr0 = rgsPoStrings[0].Value; Assert.IsNotNull(postr0, "French po string[0] has data"); Assert.IsNotNull(postr0.MsgId, "French po string[0] has MsgId data"); Assert.AreEqual(1, postr0.MsgId.Count, "French po string[0] has one line of MsgId data"); Assert.AreEqual(" - ", postr0.MsgId[0], "French po string[0] has the expected MsgId data"); Assert.AreEqual(" - ", postr0.MsgIdAsString(), "French po string[0] is ' - '"); Assert.AreEqual(1, postr0.MsgStr.Count, "French po string[0] has one line of MsgStr data"); Assert.AreEqual(" - ", postr0.MsgStr[0], "French po string[0] MsgStr is ' - '"); Assert.IsNull(postr0.UserComments, "French po string[0] has no User Comments (as expected)"); Assert.IsNull(postr0.References, "French po string[0] has no Reference data (as expected)"); Assert.IsNull(postr0.Flags, "French po string[0] has no Flags data (as expected)"); Assert.IsNotNull(postr0.AutoComments, "French po string[0] has Auto Comments"); Assert.AreEqual(3, postr0.AutoComments.Count, "French po string[0] has three lines of Auto Comments"); Assert.AreEqual("separate name and abbreviation (space dash space)", postr0.AutoComments[0], "French po string[0] has the expected first line of Auto Comment"); var postr5 = rgsPoStrings[5].Value; Assert.IsNotNull(postr5, "French po string[5] has data"); Assert.IsNotNull(postr5.MsgId, "French po string[5] has MsgId data"); Assert.AreEqual(1, postr5.MsgId.Count, "French po string[5] has one line of MsgId data"); Assert.AreEqual("Academic Domain", postr5.MsgId[0], "French po string[5] has the expected MsgId data"); Assert.AreEqual("Academic Domain", postr5.MsgIdAsString(), "French po string[5] is 'Academic Domain'"); Assert.AreEqual(1, postr5.MsgStr.Count, "French po string[5] has one line of MsgStr data"); Assert.AreEqual("Domaine technique", postr5.MsgStr[0], "French po string[5] has the expected MsgStr data"); Assert.IsNotNull(postr5.UserComments, "French po string[5] has User Comments"); Assert.AreEqual(1, postr5.UserComments.Count, "French po string[5] has one line of User Comments"); Assert.AreEqual("JDX:JN", postr5.UserComments[0], "French po string[5] has the expected User Comment"); Assert.IsNull(postr5.References, "French po string[5] has no Reference data (as expected)"); Assert.IsNull(postr5.Flags, "French po string[5] has no Flags data (as expected)"); Assert.IsNotNull(postr5.AutoComments, "French po string[5] has Auto Comments"); Assert.AreEqual(1, postr5.AutoComments.Count, "French po string[5] has one line of Auto Comments"); Assert.AreEqual("/|strings-en.xml::/PossibilityListItemTypeNames/DomainTypes|", postr5.AutoComments[0], "French po string[5] has the expected Auto Comment"); var postr48 = rgsPoStrings[48].Value; Assert.IsNotNull(postr48, "French po string[48] has data"); Assert.IsNotNull(postr48.MsgId, "French po string[48] has MsgId data"); Assert.AreEqual(1, postr48.MsgId.Count, "French po string[48] has one line of MsgId data"); Assert.AreEqual("You still have {0} difference(s) left. Are you sure you want to exit?", postr48.MsgId[0], "French po string[48] has the expected MsgId data"); Assert.AreEqual("You still have {0} difference(s) left. Are you sure you want to exit?", postr48.MsgIdAsString(), "French po string[48] is 'You still have {0} difference(s) left. Are you sure you want to exit?'"); Assert.AreEqual(1, postr48.MsgStr.Count, "French po string[48] has one line of MsgStr data"); Assert.AreEqual("Il reste {0} différences. Êtes-vous sûr de vouloir quitter?", postr48.MsgStr[0], "French po string[48] has the expected MsgStr data"); Assert.IsNotNull(postr48.UserComments, "French po string[48] has User Comments"); Assert.AreEqual(1, postr48.UserComments.Count, "French po string[48] has one line of User Comments"); Assert.AreEqual("JDX", postr48.UserComments[0], "French po string[48] has the expected User Comment"); Assert.IsNull(postr48.References, "French po string[48] has no Reference data (as expected)"); Assert.IsNull(postr48.Flags, "French po string[48] has no Flags data (as expected)"); Assert.IsNotNull(postr48.AutoComments, "French po string[48] has Auto Comments"); Assert.AreEqual(2, postr48.AutoComments.Count, "French po string[48] has two lines of Auto Comments"); Assert.AreEqual("This text will be displayed if a user tries to exit the diff dialog before all the differences have been taken care of.", postr48.AutoComments[0], "French po string[48] has the expected first line of Auto Comment"); Assert.AreEqual("/Src/TE/TeResources/TeStrings.resx::kstidExitDiffMsg", postr48.AutoComments[1], "French po string[48] has the expected second line of Auto Comment"); var postr49 = rgsPoStrings[49].Value; Assert.IsNotNull(postr49, "French po string[49] has data"); Assert.IsNotNull(postr49.MsgId, "French po string[49] has MsgId data"); Assert.AreEqual(1, postr49.MsgId.Count, "French po string[49] has one line of MsgId data"); Assert.AreEqual("You don't know how to translate this yet do you?", postr49.MsgId[0], "French po string[49] has the expected MsgId data"); Assert.AreEqual("Que?", postr49.MsgStrAsString()); Assert.IsNotNull(postr49.Flags); Assert.AreEqual(postr49.Flags[0], "fuzzy"); Assert.AreEqual(50, dictFrenchPo.Count); }