Ejemplo n.º 1
0
        public async Task KeyPhrasesResult()
        {
            var httpResult = new HttpOperationResponse <KeyPhraseBatchResult>();

            httpResult.Body = new KeyPhraseBatchResult(new List <KeyPhraseBatchResultItem>(new List <KeyPhraseBatchResultItem>()
            {
                new KeyPhraseBatchResultItem(new List <string>()
                {
                    "phrase1", "phrase2"
                })
            }), null);
            clientMock.Setup(s => s.KeyPhrasesWithHttpMessagesAsync(It.IsAny <MultiLanguageBatchInput>(), null,
                                                                    CancellationToken.None)).ReturnsAsync(httpResult);
            TextAnalyticsService textAnalyticsService = new TextAnalyticsService(clientMock.Object, configurationMock.Object, loggerMock.Object);
            var result = await textAnalyticsService.KeyPhrasesAsync(It.IsAny <string>());

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