예제 #1
0
        public void InvalidExtractCommentsTest()
        {
            _hackerPageMock.Setup(
                x => x.ExtractComments(null, It.IsAny <int>(), It.IsAny <NewsItem>()))
            .Throws(new Exception());
            _hackerPage = _hackerPageMock.Object;

            var ex = Assert.Throws <Exception>(() =>
                                               _hackerPage.ExtractComments(null, 1, new NewsItem()),
                                               "Exception was not thrown for empty HtmlNodeCollection.");
        }
예제 #2
0
        public void ValidExtractCommentsTest()
        {
            _hackerPageMock.Setup(
                x => x.ExtractComments(It.IsAny <HtmlNodeCollection>(), It.IsAny <int>(), It.IsAny <NewsItem>()))
            .Returns(new NewsItem());
            _hackerPage = _hackerPageMock.Object;

            var newsItem = _hackerPage.ExtractComments(new HtmlNodeCollection(null), 1, new NewsItem());

            Assert.IsNotNull(newsItem, "An empty NewsItem has been returned.");
        }