コード例 #1
0
        public async void GetGoogleSearchResults_ReturnsNullValue()
        {
            //Arrange
            SearchQueryDto searchQuery = new SearchQueryDto();

            var items = await GetGoogleSearchResultFromFileAsync();

            var distributedCacheMock = new Mock <IDistributedCache>();
            var cacheProviderMock    = new Mock <ISearchResultCacheProvider <SearchResult> >();

            var googleSearchExecutor = new GoogleSearchExecutor(distributedCacheMock.Object, cacheProviderMock.Object);

            //Act
            var result = await googleSearchExecutor.ExecuteSearchAsync(searchQuery);

            //Assert
            Assert.Null(result);
        }
コード例 #2
0
        public async void GetGoogleSearchResults_ReturnsValue()
        {
            //Arrange
            SearchQueryDto searchQuery = new SearchQueryDto();

            var items = await GetGoogleSearchResultFromFileAsync();

            var distributedCacheMock = new Mock <IDistributedCache>();
            var cacheProviderMock    = new Mock <ISearchResultCacheProvider <SearchResult> >();

            cacheProviderMock.Setup(m => m.GetOrCreate(It.IsAny <string>(), It.IsAny <Func <SearchResult> >())).Returns(Task.FromResult(items));

            var googleSearchExecutor = new GoogleSearchExecutor(distributedCacheMock.Object, cacheProviderMock.Object);

            //Act
            var result = await googleSearchExecutor.ExecuteSearchAsync(searchQuery);

            //Assert
            Assert.NotNull(result);
        }