public void TestFilterResultsCategories()
        {
            var indexer = new TestWebIndexer();

            indexer.AddTestCategories();
            var results = new List <ReleaseInfo>
            {
                new ReleaseInfo
                {
                    Category = new List <int> {
                        TorznabCatType.Movies.ID
                    }
                },
                new ReleaseInfo
                {
                    Category = new List <int> {
                        TorznabCatType.MoviesSD.ID
                    }
                },
                new ReleaseInfo
                {
                    Category = new List <int> {
                        TorznabCatType.BooksEBook.ID, 100004
                    }                                                                 // torznab (mandatory) + custom cat
                },
                new ReleaseInfo
                {
                    Category = new List <int> {
                        TorznabCatType.AudioLossless.ID
                    }                                                            // unsupported category in this indexer
                },
                new ReleaseInfo()
            };

            var query           = new TorznabQuery(); // without categories
            var filteredResults = indexer._FilterResults(query, results).ToList();

            Assert.AreEqual(5, filteredResults.Count);

            query = new TorznabQuery // with child category
            {
                Categories = new [] { TorznabCatType.MoviesSD.ID }
            };
            filteredResults = indexer._FilterResults(query, results).ToList();
            Assert.AreEqual(2, filteredResults.Count);
            Assert.AreEqual(TorznabCatType.MoviesSD.ID, filteredResults[0].Category.First());
            Assert.AreEqual(null, filteredResults[1].Category);

            query = new TorznabQuery // with parent category
            {
                Categories = new [] { TorznabCatType.Movies.ID }
            };
            filteredResults = indexer._FilterResults(query, results).ToList();
            Assert.AreEqual(3, filteredResults.Count);
            Assert.AreEqual(TorznabCatType.Movies.ID, filteredResults[0].Category.First());
            Assert.AreEqual(TorznabCatType.MoviesSD.ID, filteredResults[1].Category.First());
            Assert.AreEqual(null, filteredResults[2].Category);

            query = new TorznabQuery // with custom category
            {
                Categories = new [] { 100004 }
            };
            filteredResults = indexer._FilterResults(query, results).ToList();
            Assert.AreEqual(2, filteredResults.Count);
            Assert.AreEqual(TorznabCatType.BooksEBook.ID, filteredResults[0].Category.First());
            Assert.AreEqual(null, filteredResults[1].Category);
        }
Ejemplo n.º 2
0
        public void TestFilterResults()
        {
            var indexer = new TestWebIndexer();
            var results = new List <ReleaseInfo>
            {
                new ReleaseInfo
                {
                    Category = new List <int> {
                        TorznabCatType.Movies.ID
                    }
                },
                new ReleaseInfo
                {
                    Category = new List <int> {
                        TorznabCatType.MoviesSD.ID
                    }
                },
                new ReleaseInfo
                {
                    Category = new List <int> {
                        TorznabCatType.BooksEBook.ID, 100004
                    }                                                                 // torznab (mandatory) + custom cat
                },
                new ReleaseInfo()
            };

            var query           = new TorznabQuery(); // without categories
            var filteredResults = indexer._FilterResults(query, results).ToList();

            Assert.AreEqual(4, filteredResults.Count);

            // TODO: fix this, we should return MoviesSD and null
            query = new TorznabQuery // with child category
            {
                Categories = new [] { TorznabCatType.MoviesSD.ID }
            };
            filteredResults = indexer._FilterResults(query, results).ToList();
            Assert.AreEqual(3, filteredResults.Count);
            Assert.AreEqual(TorznabCatType.Movies.ID, filteredResults[0].Category.First());
            Assert.AreEqual(TorznabCatType.MoviesSD.ID, filteredResults[1].Category.First());
            Assert.AreEqual(null, filteredResults[2].Category);

            // TODO: fix this, we should return Movies, MoviesSD and null
            query = new TorznabQuery // with parent category
            {
                Categories = new [] { TorznabCatType.Movies.ID }
            };
            filteredResults = indexer._FilterResults(query, results).ToList();
            Assert.AreEqual(2, filteredResults.Count);
            Assert.AreEqual(TorznabCatType.Movies.ID, filteredResults[0].Category.First());
            Assert.AreEqual(null, filteredResults[1].Category);

            query = new TorznabQuery // with custom category
            {
                Categories = new [] { 100004 }
            };
            filteredResults = indexer._FilterResults(query, results).ToList();
            Assert.AreEqual(2, filteredResults.Count);
            Assert.AreEqual(TorznabCatType.BooksEBook.ID, filteredResults[0].Category.First());
            Assert.AreEqual(null, filteredResults[1].Category);
        }