예제 #1
0
        public async Task EntitiesAsyncResult()
        {
            var httpResult = new HttpOperationResponse <EntitiesBatchResult>();

            httpResult.Body = new EntitiesBatchResult(new List <EntitiesBatchResultItem>(new List <EntitiesBatchResultItem>()
            {
                new EntitiesBatchResultItem(null, new List <EntityRecord>()
                {
                    new EntityRecord("name1"), new EntityRecord("name2")
                })
            }), null);
            clientMock.Setup(s => s.EntitiesWithHttpMessagesAsync(It.IsAny <MultiLanguageBatchInput>(), null,
                                                                  CancellationToken.None)).ReturnsAsync(httpResult);
            TextAnalyticsService textAnalyticsService = new TextAnalyticsService(clientMock.Object, configurationMock.Object, loggerMock.Object);
            var result = await textAnalyticsService.EntitiesAsync(It.IsAny <string>());

            clientMock.Verify(s => s.EntitiesWithHttpMessagesAsync(It.IsAny <MultiLanguageBatchInput>(), null,
                                                                   CancellationToken.None), Times.Once);
            Assert.IsType <List <string> >(result);
            Assert.Equal("name1", result[0]);
            Assert.Equal("name2", result[1]);
        }