Пример #1
0
        public void ETSApi_FetchTranslation_InvalidTranslation()
        {
            XliffConverter.xliff xliffDocument = new XliffConverter.xliff(engFraLP.SourceCulture, engFraLP.TargetCulture);
            xliffDocument.AddSourceText(StringResource.BasicText);

            ETSTranslatorHelper.GetTranslation(apiKeyTranslationOptions, engInvLP, xliffDocument);
        }
Пример #2
0
        public void ETSApi_FetchTranslationNoTags_ValidTranslation()
        {
            XliffConverter.xliff xliffDocument = new XliffConverter.xliff(engFraLP.SourceCulture, engFraLP.TargetCulture);
            xliffDocument.AddSourceText(StringResource.BasicText);

            string translatedXliffText = ETSTranslatorHelper.GetTranslation(apiKeyTranslationOptions, engFraLP, xliffDocument);

            XliffConverter.xliff translatedXliff = XliffConverter.Converter.ParseXliffString(translatedXliffText);

            Assert.IsTrue(translatedXliff.GetTargetSegments().Any());
            Assert.AreEqual(
                StringResource.BasicTranslation,
                translatedXliff.GetTargetSegments()[0].ToString());

            string token = ETSTranslatorHelper.GetAuthToken(basicAuthTranslationOptions, userCredentials);

            basicAuthTranslationOptions.ApiToken = token;

            translatedXliffText = ETSTranslatorHelper.GetTranslation(basicAuthTranslationOptions, engFraLP, xliffDocument);
            translatedXliff     = XliffConverter.Converter.ParseXliffString(translatedXliffText);

            Assert.IsTrue(translatedXliff.GetTargetSegments().Any());
            Assert.AreEqual(
                StringResource.BasicTranslation,
                translatedXliff.GetTargetSegments()[0].ToString());
        }
Пример #3
0
        public void ETSApi_FetchTranslationEmoji_ValidTranslation()
        {
            XliffConverter.xliff xliffDocument = new XliffConverter.xliff(engFraLP.SourceCulture, engFraLP.TargetCulture, encodeUTF16: true);

            xliffDocument.AddSourceText(StringResource.BasicEmojiTest);

            string translatedXliffText = ETSTranslatorHelper.GetTranslation(apiKeyTranslationOptions, engFraLP, xliffDocument);

            XliffConverter.xliff translatedXliff = XliffConverter.Converter.ParseXliffString(translatedXliffText);
            Assert.IsTrue(translatedXliff.GetTargetSegments().Any());
            Assert.AreEqual(
                StringResource.BasicEmojiTranslation,
                translatedXliff.GetTargetSegments()[0].ToString());
        }
Пример #4
0
 public void AddSourceText_NullSourceText_ThrowsException()
 {
     XliffConverter.xliff xliff = new XliffConverter.xliff(
         CultureInfo.GetCultureInfo("en-us"), CultureInfo.GetCultureInfo("fr"));
     xliff.AddSourceText(null);
 }