Skip to content

Commit

Permalink
test: add mixed test-direction test
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-jones-dev committed May 13, 2024
1 parent 42594bc commit 46d807d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions DeepLTests/GeneralTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,23 @@ public async Task TestInvalidAuthKey() {
await Assert.ThrowsAsync<AuthorizationException>(() => translator.GetUsageAsync());
}

[RealServerOnlyFact]
public async Task TestMixedDirectionText() {
var translator = CreateTestTranslator();
var options = new TextTranslateOptions { TagHandling = "xml", IgnoreTags = { "ignore" } };
const string arIgnorePart = "<ignore>يجب تجاهل هذا الجزء.</ignore>";
const string enSentenceWithArIgnorePart =
"<p>This is a <b>short</b> <i>sentence</i>. " + arIgnorePart + " This is another sentence.";
const string enIgnorePart = "<ignore>This part should be ignored.</ignore>";
const string arSentenceWithEnIgnorePart =
"<p>هذه <i>جملة</i> <b>قصيرة</b>. " + enIgnorePart + " هذه جملة أخرى.</p>";

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<Exception>(
Expand Down

0 comments on commit 46d807d

Please sign in to comment.