Esempio n. 1
0
        public async Task SentimentAsyncResult()
        {
            var httpResult = new HttpOperationResponse <SentimentBatchResult>();

            httpResult.Body = new SentimentBatchResult(new List <SentimentBatchResultItem>(new List <SentimentBatchResultItem>()
            {
                new SentimentBatchResultItem((double?)1)
            }), null);
            clientMock.Setup(s => s.SentimentWithHttpMessagesAsync(It.IsAny <MultiLanguageBatchInput>(), null,
                                                                   CancellationToken.None)).ReturnsAsync(httpResult);
            TextAnalyticsService textAnalyticsService = new TextAnalyticsService(clientMock.Object, configurationMock.Object, loggerMock.Object);
            var result = await textAnalyticsService.SentimentAsync(It.IsAny <string>());

            clientMock.Verify(s => s.SentimentWithHttpMessagesAsync(It.IsAny <MultiLanguageBatchInput>(), null,
                                                                    CancellationToken.None), Times.Once);
            Assert.IsType <double>(result);
            Assert.Equal(1, result);
        }