Exemplo n.º 1
0
        public void Test_Search_Parse_Middle_Page2()
        {
            var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            UrlResponsePair pair = new UrlResponsePair(@"/search/movie/love/results?page=2",
                                                       File.ReadAllText(dir + @"\TestData\search_love_2.txt"), 3, 20);

            SearchRequestItem item = new SearchRequestItem("1", "love", "movie", "offset=11&limit=65");

            item.Urls = new List <string>();
            item.Urls.Add(@"/search/movie/love/results?page=0");
            item.Urls.Add(@"/search/movie/love/results?page=1");
            item.Urls.Add(@"/search/movie/love/results?page=2");
            item.Urls.Add(@"/search/movie/love/results?page=3");
            IMetacriticData resp = item.Parse(pair);

            CollectionAssert.AllItemsAreInstancesOfType(((SearchData)resp).SearchItems,
                                                        typeof(SearchData.SearchItem));
            Assert.IsNull(((SearchData)resp).TotalResultCount);
            Assert.AreEqual(((SearchData)resp).SearchItems.Count, 20);
            Assert.AreEqual(((SearchData)resp).SearchItems[1].Title, "To Rome with Love");
            Assert.AreEqual(((SearchData)resp).SearchItems[2].Rating.CriticRating, 0);
            Assert.AreEqual(((SearchData)resp).SearchItems[9].ReleaseDate, "August 9, 2013");
            Assert.AreEqual(((SearchData)resp).SearchItems[17].Id, "/movie/love-sex");
        }
Exemplo n.º 2
0
        public void Test_Search_Parse_Last_Page()
        {
            var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            UrlResponsePair pair = new UrlResponsePair(@"/search/movie/love/results?page=3",
                                                       File.ReadAllText(dir + @"\TestData\search_love_3.txt"), 4, 15);

            SearchRequestItem item = new SearchRequestItem("1", "love", "movie", "offset=11&limit=65");

            item.Urls = new List <string>();
            item.Urls.Add(@"/search/movie/love/results?page=0");
            item.Urls.Add(@"/search/movie/love/results?page=1");
            item.Urls.Add(@"/search/movie/love/results?page=2");
            item.Urls.Add(@"/search/movie/love/results?page=3");
            IMetacriticData resp = item.Parse(pair);

            CollectionAssert.AllItemsAreInstancesOfType(((SearchData)resp).SearchItems,
                                                        typeof(SearchData.SearchItem));
            Assert.IsNull(((SearchData)resp).TotalResultCount);
            Assert.AreEqual(((SearchData)resp).SearchItems.Count, 15);
            Assert.AreEqual(((SearchData)resp).SearchItems[2].Title, "A Lot Like Love");
            Assert.AreEqual(((SearchData)resp).SearchItems[6].Rating.CriticRating, 33);
            Assert.AreEqual(((SearchData)resp).SearchItems[8].ReleaseDate, "October 19, 2007");
            Assert.AreEqual(((SearchData)resp).SearchItems[13].Id, "/movie/my-summer-of-love");
        }
Exemplo n.º 3
0
        public void Test_Search_Parse_First_Page()
        {
            var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            UrlResponsePair pair = new UrlResponsePair(@"/search/movie/love/results?page=0",
                                                       File.ReadAllText(dir + @"\TestData\search_love_0.txt"), 1, 10);

            SearchRequestItem item = new SearchRequestItem("1", "love", "movie", "offset=11&limit=65");

            item.Urls = new List <string>();
            item.Urls.Add(@"/search/movie/love/results?page=0");
            item.Urls.Add(@"/search/movie/love/results?page=1");
            item.Urls.Add(@"/search/movie/love/results?page=2");
            item.Urls.Add(@"/search/movie/love/results?page=3");
            IMetacriticData resp = item.Parse(pair);

            CollectionAssert.AllItemsAreInstancesOfType(((SearchData)resp).SearchItems,
                                                        typeof(SearchData.SearchItem));
            Assert.AreEqual(((SearchData)resp).TotalResultCount, 238);
            Assert.AreEqual(((SearchData)resp).SearchItems.Count, 10);
            Assert.AreEqual(((SearchData)resp).SearchItems[0].Title, "After Love");
            Assert.AreEqual(((SearchData)resp).SearchItems[5].Id, "/movie/love-rosie");
            Assert.AreEqual(((SearchData)resp).SearchItems[8].ReleaseDate, "April 11, 2014");
            Assert.AreEqual(((SearchData)resp).SearchItems[9].Rating.CriticRating, 39);
        }
Exemplo n.º 4
0
        public void Test_Search_Parse_Album()
        {
            var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            UrlResponsePair pair = new UrlResponsePair(@"/search/album/futire/results?page=0",
                                                       File.ReadAllText(dir + @"\TestData\search_album_future.txt"), 1, 20);

            SearchRequestItem item = new SearchRequestItem("1", "future", "album", "");

            item.Urls = new List <string>();
            item.Urls.Add(@"/search/album/future/results?page=0");
            IMetacriticData resp = item.Parse(pair);

            CollectionAssert.AllItemsAreInstancesOfType(((SearchData)resp).SearchItems,
                                                        typeof(SearchData.SearchItem));
            Assert.AreEqual(((SearchData)resp).TotalResultCount, 58);
            Assert.AreEqual(((SearchData)resp).SearchItems.Count, 20);
            Assert.AreEqual(((SearchData)resp).SearchItems[2].Id, "/album/future-present-past-ep");
            Assert.AreEqual(((SearchData)resp).SearchItems[6].Id, "/album/barbara-barbara-we-face-a-shining-future");
            Assert.AreEqual(((SearchData)resp).SearchItems[8].Id, "/album/love-in-the-future");
            Assert.AreEqual(((SearchData)resp).SearchItems[13].Id, "/album/in-the-future");
            Assert.AreEqual(((SearchData)resp).SearchItems[17].Id, "/album/future-standards");
        }