示例#1
0
        public void WillDownloadAllPagesInSequence()
        {
            Mock <IWebPageDownloader> fetcherMock = new Mock <IWebPageDownloader>();

            fetcherMock
            .Setup(m => m.GetPage("http://www.textsfromlastnight.com/Texts-From-Worst-Nights-Week.html"))
            .Returns(File.ReadAllText("TextFromLastNightSample.txt"));

            fetcherMock
            .Setup(m => m.GetPage("http://www.textsfromlastnight.com/texts-from-last-night/page:2/type:Worst/span:Week"))
            .Returns(
                File.ReadAllText("TextFromLastNightSample.txt")
                .Replace(
                    "<li class=\"next\"><a href=\"/texts-from-last-night/page:2/type:Worst/span:Week\"> Next Page</a></li>",
                    "<li class=\"next\"><a href=\"/texts-from-last-night/page:3/type:Worst/span:Week\"> Next Page</a></li>"));

            fetcherMock
            .Setup(m => m.GetPage("http://www.textsfromlastnight.com/texts-from-last-night/page:3/type:Worst/span:Week"))
            .Returns(
                File.ReadAllText("TextFromLastNightSample.txt")
                .Replace("<li class=\"next\"><a href=\"/texts-from-last-night/page:2/type:Worst/span:Week\"> Next Page</a></li>", ""));


            var trawler = new TextsFromLastNightSinTrawler(fetcherMock.Object);

            var result = trawler.GetSins();

            Assert.That(result.Sins.Count(), Is.EqualTo(45));
        }
示例#2
0
        public void CanParseIdFromTFLN()
        {
            Mock <IWebPageDownloader> fetcherMock = new Mock <IWebPageDownloader>();

            fetcherMock
            .Setup(m => m.GetPage("http://www.textsfromlastnight.com/Texts-From-Worst-Nights-Week.html"))
            .Returns(
                File.ReadAllText("TextFromLastNightSample.txt")
                .Replace(
                    "<li class=\"next\"><a href=\"/texts-from-last-night/page:2/type:Worst/span:Week\"> Next Page</a></li>",
                    "")
                );
            var trawler = new TextsFromLastNightSinTrawler(fetcherMock.Object);
            var texts   = trawler.GetSins();

            Assert.That(texts.Sins.ElementAt(0).SourceSinId, Is.EqualTo("20582"));
        }
示例#3
0
        public void CanFindTextsFromLastNight()
        {
            Mock <IWebPageDownloader> fetcherMock = new Mock <IWebPageDownloader>();

            fetcherMock
            .Setup(m => m.GetPage("http://www.textsfromlastnight.com/Texts-From-Worst-Nights-Week.html"))
            .Returns(
                File.ReadAllText("TextFromLastNightSample.txt")
                .Replace(
                    "<li class=\"next\"><a href=\"/texts-from-last-night/page:2/type:Worst/span:Week\"> Next Page</a></li>",
                    "")
                );


            var trawler = new TextsFromLastNightSinTrawler(fetcherMock.Object);

            var texts = trawler.GetSins();

            Assert.That(texts.Sins.Count() == 15);
            Assert.That(texts.Sins.ElementAt(0).Content.Equals("Just wrote the directions to get to the girls house im hooking up with on the back of my marriage certificate. Officially worst husband ever."));
        }