Esempio n. 1
0
        public void GooglePageRankAction_IfUrlIsNotCorrectFormat_ShouldThrowBadRequest()
        {
            var inputSanitizerMock  = new Mock <IInputSanitizer>();
            var searchAssistantMock = new Mock <ISearchAssistant>();

            inputSanitizerMock.Setup(m => m.IsAbsoluteUrl(It.IsAny <string>())).Returns(false);

            var sut = new PageRanksController(searchAssistantMock.Object, inputSanitizerMock.Object);

            Assert.ThrowsAsync <BadHttpRequestException>(() => sut.Google(It.IsAny <string>(), It.IsAny <string>()));
        }
Esempio n. 2
0
        public async Task GooglePageRankAction_ShouldCallSearchAssistantGetPageRanks_With50MaxResultsToSearch_AND_GoogleSearchEngine()
        {
            var inputSanitizerMock  = new Mock <IInputSanitizer>();
            var searchAssistantMock = new Mock <ISearchAssistant>();

            inputSanitizerMock.Setup(m => m.IsAbsoluteUrl(It.IsAny <string>())).Returns(true);
            searchAssistantMock.Setup(m => m.GetPageRanks(It.IsAny <string>(), It.IsAny <string>(), 50, SearchEngines.GOOGLE)).ReturnsAsync(new List <int>());

            var sut = new PageRanksController(searchAssistantMock.Object, inputSanitizerMock.Object);

            await sut.Google(It.IsAny <string>(), It.IsAny <string>());

            searchAssistantMock.Verify(m => m.GetPageRanks(It.IsAny <string>(), It.IsAny <string>(), 50, SearchEngines.GOOGLE), Times.Once);
        }