public void DetectRequest_DetectEnglish() { IResponseGenerator responseGenerator = new TranslatorResponseGenerator(); var requestModels = new List <TranslatorRequestModel> { new TranslatorRequestModel() { Text = "This is an English example." } }; var detectRequest = GetDetectRequestMessage(requestModels); var response = responseGenerator.GenerateDetectResponseAsync(detectRequest).GetAwaiter().GetResult(); var lang = response.FirstOrDefault().Language; Assert.AreEqual("en", lang); }
public void DetectRequest_DetectFrench() { IResponseGenerator responseGenerator = new TranslatorResponseGenerator(); var requestModels = new List <TranslatorRequestModel> { new TranslatorRequestModel() { Text = "C'est un exemple français." } }; var detectRequest = GetDetectRequestMessage(requestModels); var response = responseGenerator.GenerateDetectResponseAsync(detectRequest).GetAwaiter().GetResult(); var lang = response.FirstOrDefault().Language; Assert.AreEqual("fr", lang); }
public void TranslateRequest_TranslateEnglishToFrench() { IResponseGenerator responseGenerator = new TranslatorResponseGenerator(); List <TranslatorRequestModel> requestModels = new List <TranslatorRequestModel> { new TranslatorRequestModel() { Text = "This is an English example." } }; string from = "en", to = "fr"; var detectRequest = GetTranslateRequestMessage(from, to, requestModels); var response = responseGenerator.GenerateTranslateResponseAsync(detectRequest).GetAwaiter().GetResult(); var lang = response.FirstOrDefault(); Assert.AreEqual("C'est un exemple anglais.", lang.Translations.FirstOrDefault().Text); }