public void TestTranslateScript() { string TssFileName = "BTL_EP_210_090"; int ExpectedTextCount = 4; var ExpectedStrings = new Queue <String>(); var Tss = new TSS().Load(File.OpenRead(Utils.TestInputPath + "/" + TssFileName)); int mm = 0; Tss.TranslateTexts((Text) => { for (int n = 0; n < Text.Translated.Length; n++) { Text.Original[n].Text = "Original" + mm++; Text.Translated[n].Text = "Translated" + mm++; } }, (String) => { try { //Console.WriteLine(String); if (String == "VB36_1402") { return(String = "**VB36_1403**"); } return(null); } finally { ExpectedStrings.Enqueue(String); } }); Assert.AreEqual(ExpectedTextCount * 2 * 2, mm); mm = 0; var Tss2 = new TSS().Load(Tss.Save()); var TranslatedTexts = Tss2.ExtractTexts(); Assert.AreEqual(ExpectedTextCount, TranslatedTexts.Count); foreach (var Text in TranslatedTexts) { for (int n = 0; n < Text.Translated.Length; n++) { Assert.AreEqual("Original" + mm++, Text.Original[n].Text); Assert.AreEqual("Translated" + mm++, Text.Translated[n].Text); } } var TranslatedStrings = Tss2.ExtractStrings(); foreach (var StringInfo in TranslatedStrings) { //Assert.AreEqual("Original" + mm++, Text.Original[n].Text); Assert.AreEqual(ExpectedStrings.Dequeue(), StringInfo.Text); } Assert.AreEqual(ExpectedTextCount * 2 * 2, mm); //File.WriteAllBytes(Utils.TestOutputPath + "/BTL_EP_210_090.translated", Tss.Save().ToArray()); }