コード例 #1
0
        public void GetDirectly()
        {
            var url    = "http://comic.com/009.png";
            var parser = new ComicParser(url);
            var img0   = "http://comic.com/613.png";
            var img1   = "http://comic.com/614.png";
            var img2   = "http://comic.com/615.png";

            // get the generator object
            UrlGenerator urlGen = parser.GetUrlGenerator();

            Assert.AreEqual("1", urlGen.Start);

            // generate 10 urls, starting from 605
            List <string> backUrls = urlGen.Get(612, 10);
            // generate 10 urls, starting from 615
            List <string> forwardUrls = urlGen.Get(614, 10);

            // each url should be the comic, directly
            // urls are sorted
            Assert.AreEqual(10, backUrls.Count());
            Assert.AreEqual(img0, backUrls [0]);
            Assert.AreEqual(img1, backUrls [1]);
            Assert.AreEqual(img2, backUrls [2]);
            Assert.AreEqual(10, forwardUrls.Count());
            Assert.AreEqual(img2, forwardUrls [0]);
        }
コード例 #2
0
        public void GetFromPageXkcd()
        {
            var xkcdUrl    = "http://xkcd.com/614";
            var xkcdParser = new ComicParser(xkcdUrl);
            var xkcdImg    = "http://imgs.xkcd.com/comics/woodpecker.png";
            var xkcdImg2   = "http://imgs.xkcd.com/comics/avoidance.png";

            // get the generator object
            UrlGenerator urlGen = xkcdParser.GetUrlGenerator();

            Assert.AreEqual("1", urlGen.Start);

            // generate 10 urls, starting from 605
            List <string> backUrls = urlGen.Get(605, 10);
            // generate 10 urls, starting from 615
            List <string> forwardUrls = urlGen.Get(615, 10);
            // generate 10 urls, starting from 614
            List <string> incUrls = urlGen.Get(614, 10);

            // each url should be the comic, directly
            // urls are sorted

//			foreach (var x in backUrls) {
//				Console.WriteLine (x);
//			}

            // Seems like this is a legitimate fail...
            // backUrls[0] is actually comic 606, expected 605
            // further investigation required
            Assert.AreEqual(10, backUrls.Count());
            Assert.AreEqual(xkcdImg, backUrls [9]);
            Assert.AreEqual(10, forwardUrls.Count());
            Assert.AreEqual(xkcdImg2, forwardUrls [0]);
            Assert.AreEqual(10, incUrls.Count());
            Assert.AreEqual(xkcdImg, incUrls [0]);
            Assert.AreEqual(xkcdImg2, incUrls [1]);
        }