public async Task GetDocumentFormatsTest() { DocumentTranslationClient client = GetClient(); var documentFormats = await client.GetDocumentFormatsAsync(); Assert.GreaterOrEqual(documentFormats.Value.Count, 0); foreach (FileFormat fileFormat in documentFormats.Value) { Assert.IsFalse(string.IsNullOrEmpty(fileFormat.Format)); Assert.IsNotNull(fileFormat.FileExtensions); Assert.IsNotNull(fileFormat.FormatVersions); } }
protected override async ValueTask <bool> IsEnvironmentReadyAsync() { string endpoint = Environment.GetEnvironmentVariable(EndpointEnvironmentVariableName); var client = new DocumentTranslationClient(new Uri(endpoint), Credential); try { await client.GetDocumentFormatsAsync(); } catch (RequestFailedException e) when(e.Status == 401) { return(false); } return(true); }
public void ClientCannotAuthenticateWithFakeApiKey() { DocumentTranslationClient client = GetClient(credential: new AzureKeyCredential("fakeKey")); RequestFailedException ex = Assert.ThrowsAsync <RequestFailedException>(async() => await client.GetDocumentFormatsAsync()); Assert.AreEqual("401", ex.ErrorCode); }