Пример #1
0
 public void Scrape_One_ImporterCalledOnce()
 {
     _parser.Setup(p => p.Parse(_page1)).Returns(new Post[30]);
     var scraper = new HackerNewsScraper(_importer.Object, _parser.Object, _formatter.Object, _exporter.Object);
     scraper.Scrape(1);
     _importer.Verify(i => i.Import(It.IsAny<string>()), Times.Once);
 }
Пример #2
0
 public void Scrape_One_FormatterCalledOnceOnListOfCountOne()
 {
     _parser.Setup(p => p.Parse(_page1)).Returns(new Post[30]);
     var scraper = new HackerNewsScraper(_importer.Object, _parser.Object, _formatter.Object, _exporter.Object);
     scraper.Scrape(1);
     _formatter.Verify(i => i.Format(It.Is<List<Post>>(p=>p.Count==1)), Times.Once);
 }
Пример #3
0
 public void Scrape_One_FormatterCalledOnceOnListStartingWithFirstPost()
 {
     var parsed = new Post[30];
     _parser.Setup(p => p.Parse(_page1)).Returns(parsed);
     var scraper = new HackerNewsScraper(_importer.Object, _parser.Object, _formatter.Object, _exporter.Object);
     scraper.Scrape(1);
     _formatter.Verify(i => i.Format(It.Is<List<Post>>(p => p[0] == parsed[0])), Times.Once);
 }
Пример #4
0
 public void Scrape_OneHundred_ImporterCalledFourTimes()
 {
     _parser.Setup(p => p.Parse(_page1)).Returns(new Post[30]);
     _parser.Setup(p => p.Parse(_page2)).Returns(new Post[29]);
     _parser.Setup(p => p.Parse(_page3)).Returns(new Post[28]);
     _parser.Setup(p => p.Parse(_page4)).Returns(new Post[27]);
     var scraper = new HackerNewsScraper(_importer.Object, _parser.Object, _formatter.Object, _exporter.Object);
     scraper.Scrape(100);
     _importer.Verify(i => i.Import(It.IsAny<string>()), Times.Exactly(4));
 }
Пример #5
0
 public void Scrape_Zero_ThrowsArgumentOutOfRangeException()
 {
     var scraper = new HackerNewsScraper(_importer.Object, _parser.Object, _formatter.Object, _exporter.Object);
     Assert.ThrowsException<ArgumentOutOfRangeException>(() => scraper.Scrape(0));
 }