public void DeleteWritingSystemId_LangIsFoundInGloss_GlossDeleted() { var ws2Content = new Dictionary <string, string> { { "th", "thai Word" }, { "de", "de word" }, { "en", "en word" } }; var liftFileContent = LiftContentForTests.WrapEntriesInLiftElements("0.13", LiftContentForTests.GetSingleEntrywithGlossContainingWritingsystemsAndContent(ws2Content)); using (var e = new TestEnvironment(liftFileContent)) { AssertThatXmlIn.File(e.PathToLiftFile).HasSpecifiedNumberOfMatchesForXpath("/lift/entry/sense/gloss[@lang='de']/text[text()='de word']", 1); e.Helper.DeleteWritingSystemId("de"); AssertThatXmlIn.File(e.PathToLiftFile).HasNoMatchForXpath("/lift/entry/sense/gloss[@lang='de']"); } }
public void DeleteWritingSystemId_TwoEntries_OutPutHasTwoEntriesAsWell() { var ws2Content = new Dictionary <string, string> { { "th", "thai Word" }, { "de", "de word" }, { "en", "en word" } }; var liftFileContent = LiftContentForTests.WrapEntriesInLiftElements("0.13", LiftContentForTests.GetSingleEntrywithGlossContainingWritingsystemsAndContent(ws2Content) + LiftContentForTests.GetSingleEntrywithGlossContainingWritingsystemsAndContent(ws2Content)); using (var e = new TestEnvironment(liftFileContent)) { AssertThatXmlIn.File(e.PathToLiftFile).HasSpecifiedNumberOfMatchesForXpath("/lift/entry", 2); e.Helper.DeleteWritingSystemId("de"); AssertThatXmlIn.File(e.PathToLiftFile).HasSpecifiedNumberOfMatchesForXpath("/lift/entry", 2); } }
public void DeleteWritingSystemId_LangIsFoundInFormThatIsOnlyOne_ParentandFormAreDeleted() { var ws2Content = new Dictionary <string, string> { { "de", "de word" } }; var liftFileContent = LiftContentForTests.WrapEntriesInLiftElements("0.13", LiftContentForTests.GetSingleEntryWithLexicalUnitContainingWritingsystemsAndContent(ws2Content)); using (var e = new TestEnvironment(liftFileContent)) { AssertThatXmlIn.File(e.PathToLiftFile).HasSpecifiedNumberOfMatchesForXpath("/lift/entry/lexical-unit/form[@lang='de']", 1); e.Helper.DeleteWritingSystemId("de"); AssertThatXmlIn.File(e.PathToLiftFile).HasNoMatchForXpath("/lift/entry/lexical-unit"); } }
public void ReplaceWritingSystemId_ContainsGlossesWithUninvolvedWritingSystems_GlossesAreLeftAlone() { var ws2Content = new Dictionary <string, string> { { "th", "thai Word" }, { "de", "de word" }, { "en", "en word" } }; var liftFileContent = LiftContentForTests.WrapEntriesInLiftElements("0.13", LiftContentForTests.GetSingleEntrywithGlossContainingWritingsystemsAndContent(ws2Content)); using (var e = new TestEnvironment(liftFileContent)) { e.Helper.ReplaceWritingSystemId("th", "de"); AssertThatXmlIn.File(e.PathToLiftFile).HasAtLeastOneMatchForXpath("/lift/entry/sense/gloss[@lang='en']/text[text()='en word']"); AssertThatXmlIn.File(e.PathToLiftFile).HasAtLeastOneMatchForXpath("/lift/entry/sense/definition/form[@lang='en']/text[text()='eng-mean']"); } }
public void ReplaceWritingSystemId_FirstOfTwoGlossesContainsOldWritingSystemOtherContainsNewWritingSystemFirstHasContent_WritingSystemIsReplaced() { var ws2Content = new Dictionary <string, string> { { "th", "thai Word" }, { "de", "" } }; var liftFileContent = LiftContentForTests.WrapEntriesInLiftElements("0.13", LiftContentForTests.GetSingleEntrywithGlossContainingWritingsystemsAndContent(ws2Content)); using (var e = new TestEnvironment(liftFileContent)) { e.Helper.ReplaceWritingSystemId("th", "de"); AssertThatXmlIn.File(e.PathToLiftFile).HasSpecifiedNumberOfMatchesForXpath("/lift/entry/sense/gloss[@lang='de']", 2); AssertThatXmlIn.File(e.PathToLiftFile).HasAtLeastOneMatchForXpath("/lift/entry/sense/gloss[@lang='de']/text[text()='thai Word']"); AssertThatXmlIn.File(e.PathToLiftFile).HasNoMatchForXpath("/lift/entry/sense/gloss[@lang='th']"); } }
public void ReplaceWritingSystemId_FirstOfTwoFormsContainsOldWritingSystemOtherContainsNewWritingSystemBothHaveIdenticalContent_WritingSystemIsReplacedSecondFormIsDeleted() { var ws2Content = new Dictionary <string, string> { { "th", "de word" }, { "de", "de word" } }; var liftFileContent = LiftContentForTests.WrapEntriesInLiftElements("0.13", LiftContentForTests.GetSingleEntryWithLexicalUnitContainingWritingsystemsAndContent(ws2Content)); using (var e = new TestEnvironment(liftFileContent)) { e.Helper.ReplaceWritingSystemId("th", "de"); AssertThatXmlIn.File(e.PathToLiftFile).HasSpecifiedNumberOfMatchesForXpath("/lift/entry/lexical-unit/form[@lang='de']", 1); AssertThatXmlIn.File(e.PathToLiftFile).HasSpecifiedNumberOfMatchesForXpath("/lift/entry/lexical-unit/form[@lang='de']/text[text()='de word']", 1); AssertThatXmlIn.File(e.PathToLiftFile).HasNoMatchForXpath("/lift/entry/lexical-unit/form[@lang='th']"); } }
public void ReplaceWritingSystemId_OneOfTwoFormsContainsOldWritingSystem_WritingSystemIsReplaced() { var ws2Content = new Dictionary <string, string> { { "th", "thai Word" }, { "en", "en word" } }; var liftFileContent = LiftContentForTests.WrapEntriesInLiftElements("0.13", LiftContentForTests.GetSingleEntryWithLexicalUnitContainingWritingsystemsAndContent(ws2Content)); using (var e = new TestEnvironment(liftFileContent)) { e.Helper.ReplaceWritingSystemId("th", "de"); AssertThatXmlIn.File(e.PathToLiftFile).HasAtLeastOneMatchForXpath("/lift/entry/lexical-unit/form[@lang='de']"); AssertThatXmlIn.File(e.PathToLiftFile).HasAtLeastOneMatchForXpath("/lift/entry/lexical-unit/form[@lang='de']/text[text()='thai Word']"); AssertThatXmlIn.File(e.PathToLiftFile).HasNoMatchForXpath("/lift/entry/lexical-unit/form[@lang='th']"); } }
public void ReplaceWritingSystemId_headerContainsBadRfcTag_RfcTagIsReplaced() { var ws2Content = new Dictionary <string, string> { { "th", "thai" }, { "de", "deutsch" } }; var entryXml = LiftContentForTests.GetSingleEntrywithGlossContainingWritingsystemsAndContent(ws2Content); var entryWithHeader = LiftContentForTests.AddHeaderWithSingleCustomField("bogus", entryXml); var liftFileContent = LiftContentForTests.WrapEntriesInLiftElements("0.13", entryWithHeader); using (var e = new TestEnvironment(liftFileContent)) { e.Helper.ReplaceWritingSystemId("bogus", "qaa-x-bogus"); AssertThatXmlIn.File(e.PathToLiftFile).HasSpecifiedNumberOfMatchesForXpath("/lift/header/fields/field/form[@lang='qaa-x-bogus']", 1); AssertThatXmlIn.File(e.PathToLiftFile).HasNoMatchForXpath("/lift/header/fields/field/form[@lang='bogus']"); } }
public void ReplaceWritingSystemId_FirstOfTwoGlossesContainsOldWritingSystemOtherContainsNewWritingSystemBothHaveIdenticalContentWithSingleAndDoubleQuotes_WritingSystemIsReplacedSecondFormIsDeleted() { var problematicString = "He said: \"Life's good.\""; var ws2Content = new Dictionary <string, string> { { "th", problematicString }, { "de", problematicString } }; var liftFileContent = LiftContentForTests.WrapEntriesInLiftElements("0.13", LiftContentForTests.GetSingleEntrywithGlossContainingWritingsystemsAndContent(ws2Content)); using (var e = new TestEnvironment(liftFileContent)) { e.Helper.ReplaceWritingSystemId("th", "de"); AssertThatXmlIn.File(e.PathToLiftFile).HasSpecifiedNumberOfMatchesForXpath("/lift/entry/sense/gloss[@lang='de']/text", 1); AssertThatXmlIn.File(e.PathToLiftFile).HasNoMatchForXpath("/lift/entry/sense/gloss[@lang='th']"); // We are not using: //AssertThatXmlIn.File(e.PathToLiftFile).HasSpecifiedNumberOfMatchesForXpath("/lift/entry/sense/gloss[@lang='de']/text[text()='de word']", 1); //because the whole point is that the syntax is problematic for xpath var xmlDoc = new XmlDocument(); xmlDoc.Load(e.PathToLiftFile); var node = xmlDoc.SelectSingleNode("/lift/entry/sense/gloss[@lang='de']/text/text()"); Assert.That(node.Value, Is.EqualTo(problematicString)); } }