From 46d807d28153a28aa1f3f93e8f09bbcd0d084411 Mon Sep 17 00:00:00 2001 From: Daniel Jones Date: Mon, 6 May 2024 16:09:56 +0200 Subject: [PATCH] test: add mixed test-direction test --- DeepLTests/GeneralTest.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/DeepLTests/GeneralTest.cs b/DeepLTests/GeneralTest.cs index 81a0e66..a4d59ad 100644 --- a/DeepLTests/GeneralTest.cs +++ b/DeepLTests/GeneralTest.cs @@ -133,6 +133,23 @@ public async Task TestInvalidAuthKey() { await Assert.ThrowsAsync(() => translator.GetUsageAsync()); } + [RealServerOnlyFact] + public async Task TestMixedDirectionText() { + var translator = CreateTestTranslator(); + var options = new TextTranslateOptions { TagHandling = "xml", IgnoreTags = { "ignore" } }; + const string arIgnorePart = "يجب تجاهل هذا الجزء."; + const string enSentenceWithArIgnorePart = + "

This is a short sentence. " + arIgnorePart + " This is another sentence."; + const string enIgnorePart = "This part should be ignored."; + const string arSentenceWithEnIgnorePart = + "

هذه جملة قصيرة. " + enIgnorePart + " هذه جملة أخرى.

"; + + var enResult = await translator.TranslateTextAsync(enSentenceWithArIgnorePart, null, "en-US", options); + Assert.Contains(arIgnorePart, enResult.Text); + var arResult = await translator.TranslateTextAsync(arSentenceWithEnIgnorePart, null, "ar", options); + Assert.Contains(enIgnorePart, arResult.Text); + } + [Fact] public void TestInvalidServerUrl() => Assert.ThrowsAny(