public void TestFlexChorusMethods() { int cOrigEntries = m_cache.LangProject.LexDbOA.EntriesOC.Count; string sLiftFile = Path.GetTempFileName(); m_cache.EnableBulkLoadingIfPossible(true); TestFlexChorusDlg dlg = new TestFlexChorusDlg(m_cache); TestProgress prog = new TestProgress(); string sLiftFile2 = dlg.Export(sLiftFile, prog); Assert.AreEqual(sLiftFile2, sLiftFile); string sLiftFile3 = dlg.Merge(sLiftFile2, prog); Assert.IsNotNull(sLiftFile3); Assert.AreNotEqual(sLiftFile3, sLiftFile); string sLogFile = dlg.Import(sLiftFile3, prog); Assert.AreEqual(m_cache.LangProject.LexDbOA.EntriesOC.Count, cOrigEntries - 1); CheckDeletedEntries(); CheckModifiedEntry(); CheckCreatedEntry(); Assert.IsNotNull(sLogFile); // Clean up the temp directory and other debris. File.Delete(sLiftFile); File.Delete(Path.ChangeExtension(sLiftFile, ".lift-ranges")); // if it exists... File.Delete(sLiftFile3); File.Delete(sLogFile); }
/// <summary> /// Fake a merge operation by deleting an entry, adding an entry, and /// modifying an entry in the given LIFT file. /// </summary> internal string Merge(string sLiftFile, TestProgress prog) { XmlDocument xdoc = new XmlDocument(); xdoc.Load(sLiftFile); XmlNode xnLift = xdoc.SelectSingleNode("lift"); XmlNodeList xnlEntries = xnLift.SelectNodes("entry"); Assert.AreEqual(m_cache.LangProject.LexDbOA.EntriesOC.Count, xnlEntries.Count); // Effectively delete the first entry listed by removing its contents and adding a // "dateDeleted" attribute. XmlNode xnDelete = xnlEntries[0]; Assert.AreEqual(xnDelete.Attributes["guid"].Value.ToLowerInvariant(), TestFlexChorus.ksguidDelete1); XmlNodeList xnlDeleted = xnDelete.ChildNodes; foreach (XmlNode xn in xnlDeleted) { xnDelete.RemoveChild(xn); } AddXmlAttribute(xnDelete, "dateDeleted", DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssK")); // Totally delete the second entry listed. Assert.AreEqual(xnlEntries[1].Attributes["guid"].Value.ToLowerInvariant(), TestFlexChorus.ksguidDelete2); xnLift.RemoveChild(xnlEntries[1]); // Modify an entry by deleting 3 senses and adding 1 sense. ModifyAnEntry(xnlEntries); // Add an entirely new entry (stolen from TestLangProj). CreateNewEntry(xnLift); string sNewLiftFile = Path.GetTempFileName(); using (TextWriter w = new StreamWriter(sNewLiftFile)) { w.Write(xdoc.OuterXml); } return(sNewLiftFile); }
/// <summary> /// Call the base class's ImportLexicon method. /// </summary> internal string Import(string sLiftFile, TestProgress prog) { return(base.ImportLexicon(prog, sLiftFile) as string); }
/// <summary> /// Call the base class's ImportLexicon method. /// </summary> internal string Import(string sLiftFile, TestProgress prog) { return base.ImportLexicon(prog, sLiftFile) as string; }
/// <summary> /// Fake a merge operation by deleting an entry, adding an entry, and /// modifying an entry in the given LIFT file. /// </summary> internal string Merge(string sLiftFile, TestProgress prog) { XmlDocument xdoc = new XmlDocument(); xdoc.Load(sLiftFile); XmlNode xnLift = xdoc.SelectSingleNode("lift"); XmlNodeList xnlEntries = xnLift.SelectNodes("entry"); Assert.AreEqual(m_cache.LangProject.LexDbOA.EntriesOC.Count, xnlEntries.Count); // Effectively delete the first entry listed by removing its contents and adding a // "dateDeleted" attribute. XmlNode xnDelete = xnlEntries[0]; Assert.AreEqual(xnDelete.Attributes["guid"].Value.ToLowerInvariant(), TestFlexChorus.ksguidDelete1); XmlNodeList xnlDeleted = xnDelete.ChildNodes; foreach (XmlNode xn in xnlDeleted) xnDelete.RemoveChild(xn); AddXmlAttribute(xnDelete, "dateDeleted", DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssK")); // Totally delete the second entry listed. Assert.AreEqual(xnlEntries[1].Attributes["guid"].Value.ToLowerInvariant(), TestFlexChorus.ksguidDelete2); xnLift.RemoveChild(xnlEntries[1]); // Modify an entry by deleting 3 senses and adding 1 sense. ModifyAnEntry(xnlEntries); // Add an entirely new entry (stolen from TestLangProj). CreateNewEntry(xnLift); string sNewLiftFile = Path.GetTempFileName(); using (TextWriter w = new StreamWriter(sNewLiftFile)) { w.Write(xdoc.OuterXml); } return sNewLiftFile; }