コード例 #1
0
        public async Task PredictNerBatchAsyncTest(string key, string endpoint, string language, List <string> queries, CliException expectedException)
        {
            if (expectedException == null)
            {
                // act
                ITextAnalyticsService predictionService = new TextAnalyticsService(key, endpoint, language);
                var result = await predictionService.PredictNerBatchAsync(queries);

                // assert
                Assert.NotNull(result);
                Assert.NotEmpty(result);
                foreach (RecognizeEntitiesResult r in result)
                {
                    Assert.NotNull(r.Entities);
                    Assert.NotEmpty(r.Entities);
                    foreach (CategorizedEntity e in r.Entities)
                    {
                        Assert.NotNull(e.Text);
                    }
                }
            }
            else
            {
                await Assert.ThrowsAsync(expectedException.GetType(), async() =>
                {
                    ITextAnalyticsService predictionService = new TextAnalyticsService(key, endpoint, language);
                    await predictionService.PredictNerBatchAsync(queries);
                });
            }
        }