コード例 #1
0
        public async Task SearchProvider_WritesResultToDb()
        {
            //Arrange
            var context = _fixture.SearchApiDbContext;

            _googleSearchClient.Setup(x => x.SearchAsync(It.IsAny <string>())).ReturnsAsync(new List <string>()
            {
                "G1", "G2", "G3", "G4", "G5", "G6"
            });
            _bingSearchClient.Setup(x => x.SearchAsync(It.IsAny <string>())).ReturnsAsync(new List <string>()
            {
                "B1", "B2", "B3", "B4", "B5", "B6"
            });

            var searchProvider = new SearchProvider(_bingSearchClient.Object, _googleSearchClient.Object, _mapper, context, _logger);

            //Act
            var result = await searchProvider.SearchAsync("cat");

            //Assert
            Assert.Equal(12, _fixture.SearchApiDbContext.SearchData.Count());
        }