public async Task AnalyzeOperationRecognizeEntitiesWithRequestOptions() { var mockResponse = new MockResponse(202); mockResponse.AddHeader(new HttpHeader("Operation-Location", "something/jobs/2a96a91f-7edf-4931-a880-3fdee1d56f15")); var mockTransport = new MockTransport(new[] { mockResponse, mockResponse }); var client = CreateTestClient(mockTransport); var documents = new List <string> { "Elon Musk is the CEO of SpaceX and Tesla." }; var options = new TextAnalyticsRequestOptions(); var actions = new RecognizeEntitiesAction(options); TextAnalyticsActions batchActions = new TextAnalyticsActions() { RecognizeEntitiesActions = new List <RecognizeEntitiesAction>() { actions }, }; await client.StartAnalyzeActionsAsync(documents, batchActions); var contentString = GetString(mockTransport.Requests.Single().Content); ValidateRequestOptions(contentString); }
public async Task AnalyzeOperationRecognizeEntitiesWithDisableServiceLogs() { var mockResponse = new MockResponse(202); mockResponse.AddHeader(new HttpHeader("Operation-Location", "something/jobs/2a96a91f-7edf-4931-a880-3fdee1d56f15")); var mockTransport = new MockTransport(new[] { mockResponse, mockResponse }); var client = CreateTestClient(mockTransport); var documents = new List <string> { "Elon Musk is the CEO of SpaceX and Tesla." }; var actions = new RecognizeEntitiesAction() { DisableServiceLogs = true }; TextAnalyticsActions batchActions = new TextAnalyticsActions() { RecognizeEntitiesActions = new List <RecognizeEntitiesAction>() { actions }, }; await client.StartAnalyzeActionsAsync(documents, batchActions); var content = mockTransport.Requests.Single().Content; using var stream = new MemoryStream(); await content.WriteToAsync(stream, default); stream.Position = 0; using var streamReader = new StreamReader(stream); string contentString = streamReader.ReadToEnd(); string logging = contentString.Substring(contentString.IndexOf("loggingOptOut"), 19); var expectedContent = "loggingOptOut\":true"; Assert.AreEqual(expectedContent, logging); }