public void TranslateEmptyTest() { var translator = new TextTranslatorGoogleUnofficial(enmLanguage.English, enmLanguage.Russian); var translation = translator.Translate(""); Assert.AreEqual(null, translation.Translation); }
public void TranslateToAllLanguagesTest() { var translator = new TextTranslatorGoogleUnofficial(enmLanguage.English); foreach (var translatorTranslation in TranslatorTranslations) { translator.SetLanguageTo(translatorTranslation.Key); var translatedWord = translator.Translate(WordToTranslate).Translation; if (translatedWord != translatorTranslation.Value) { Assert.Inconclusive("Translation to language '{0}' failed. Expected '{1}' but actual is '{2}'", translatorTranslation.Key, translatorTranslation.Value, translatedWord); } } }
public void DetectAllLanguagesTest() { TextTranslatorGoogleUnofficial translator = new TextTranslatorGoogleUnofficial(enmLanguage.English); foreach (var translatorTranslation in TranslatorTranslations) { translator.SetLanguageFrom(null); var translatedWord = translator.Translate(translatorTranslation.Value).Translation; if (translatedWord != WordToTranslate) { Assert.Inconclusive("Wrong translation ('{0}') of language '{1}'", translatedWord, translatorTranslation.Key); } if (translator.LanguageFrom != translatorTranslation.Key) { Assert.Inconclusive("Language '{0}' has not been deteced. Actual language is '{1}'", translatorTranslation.Key, translator.LanguageFrom); } } }