Ejemplo n.º 1
0
        public async Task LoadCityHtml_ReturnNodeCollection()
        {
            // Arrange
            var expectedResult = new HtmlNodeCollection(null)
            {
                HtmlNode.CreateNode(_htmlDummyNodeLiteral),
                HtmlNode.CreateNode(_htmlDummyNodeLiteral)
            };

            var          LoadHtmlNodesTask = Task.Run(() => expectedResult);
            const string cityXPath         = "//*[@id='geo-control']/div[3]/div[2]/div/div[4]/a[*]";

            var htmlParserMock = new Mock <HtmlParser>(new HtmlWeb());

            htmlParserMock
            .Setup(htmlParser => htmlParser.LoadHtmlNodes(_homePageUrl, cityXPath))
            .Returns(LoadHtmlNodesTask);

            var pageHandler = new PageHandler(htmlParserMock.Object);

            // Act
            var actualResult = await pageHandler.LoadCityHtml();

            // Assert
            Assert.Equal(expectedResult, actualResult);
        }