コード例 #1
0
        protected override async ValueTask <bool> IsEnvironmentReadyAsync()
        {
            string endpoint = GetOptionalVariable(EndpointEnvironmentVariableName);
            var    client   = new DocumentTranslationClient(new Uri(endpoint), Credential);

            try
            {
                await client.GetSupportedDocumentFormatsAsync();

                await client.GetSupportedGlossaryFormatsAsync();

                client.GetTranslationStatuses().Take(2);
            }
            catch (RequestFailedException e) when(e.Status == 401)
            {
                return(false);
            }
            return(true);
        }
        public async Task GetGlossaryFormatsTest(bool usetokenCredential)
        {
            DocumentTranslationClient client = GetClient(useTokenCredential: usetokenCredential);

            var glossaryFormats = await client.GetSupportedGlossaryFormatsAsync();

            Assert.GreaterOrEqual(glossaryFormats.Value.Count, 0);
            foreach (DocumentTranslationFileFormat glossaryFormat in glossaryFormats.Value)
            {
                Assert.IsFalse(string.IsNullOrEmpty(glossaryFormat.Format));
                Assert.IsNotNull(glossaryFormat.FileExtensions);
                Assert.IsNotNull(glossaryFormat.FormatVersions);

                if (glossaryFormat.Format == "XLIFF")
                {
                    Assert.IsFalse(string.IsNullOrEmpty(glossaryFormat.DefaultFormatVersion));
                }
            }
        }