private static TorznabCapabilitiesCategories CreateTestDataset()
        {
            var tcc = new TorznabCapabilitiesCategories();

            TestCategories.AddTestCategories(tcc);
            return(tcc);
        }
예제 #2
0
        private List <string> GetAttributeString(Type attribute)
        {
            if (_browserQueue.IsNullOrEmpty())
            {
                IEnumerable <string> availableEnvironments = attribute.GetFields().Select(e => e.GetRawConstantValue().ToString());
                _browserQueue = TestCategories.Where(c => availableEnvironments.Any(e => e == c)).ToList();
            }

            return(_browserQueue);
        }
 //custom body
 //equals trait
 //hash code trait
 //pretty print
 public override void Print(PrettyPrinter printer)
 {
     printer.Println("UnitTestLaunch (");
     using (printer.IndentCookie()) {
         printer.Print("testNames = "); TestNames.PrintEx(printer); printer.Println();
         printer.Print("testGroups = "); TestGroups.PrintEx(printer); printer.Println();
         printer.Print("testCategories = "); TestCategories.PrintEx(printer); printer.Println();
         printer.Print("testResult = "); _TestResult.PrintEx(printer); printer.Println();
         printer.Print("runResult = "); _RunResult.PrintEx(printer); printer.Println();
     }
     printer.Print(")");
 }
예제 #4
0
        public void Update(TestCategories categoryInput)
        {
            var category = _context.TestCategories.Find(categoryInput.Id);

            if (category != null)
            {
                category.Name = categoryInput.Name;
                _context.SaveChanges();
            }
            else
            {
                throw new Exception("Category not found");
            }
        }
        public void TestAddCategoryMapping()
        {
            var indexer = new TestWebIndexer();

            // you can find more complex tests in TorznabCapabilitiesCategoriesTests.cs
            indexer._AddCategoryMapping("11", TorznabCatType.MoviesSD, "MoviesSD");
            var expected = new List <TorznabCategory>
            {
                TorznabCatType.Movies.CopyWithoutSubCategories(),
                new TorznabCategory(100011, "MoviesSD")
            };

            expected[0].SubCategories.Add(TorznabCatType.MoviesSD.CopyWithoutSubCategories());
            TestCategories.CompareCategoryTrees(expected, indexer.TorznabCaps.Categories.GetTorznabCategoryTree());

            indexer._AddCategoryMapping(14, TorznabCatType.MoviesHD);
            expected[0].SubCategories.Add(TorznabCatType.MoviesHD.CopyWithoutSubCategories());
            TestCategories.CompareCategoryTrees(expected, indexer.TorznabCaps.Categories.GetTorznabCategoryTree());
        }
예제 #6
0
        public void TestTorznabCapsCategories()
        {
            var torznabCaps = new TorznabCapabilities();

            TestCategories.AddTestCategories(torznabCaps.Categories);

            // test Torznab caps (XML) => more in Common.Model.TorznabCapabilitiesTests
            var xDocument           = torznabCaps.GetXDocument();
            var xDocumentCategories = xDocument.Root?.Element("categories")?.Elements("category").ToList();

            Assert.AreEqual(7, xDocumentCategories?.Count);
            Assert.AreEqual("100044", xDocumentCategories?[0].Attribute("id")?.Value);
            Assert.AreEqual("100045", xDocumentCategories?[1].Attribute("id")?.Value);
            Assert.AreEqual("1030", xDocumentCategories?[2].Attribute("id")?.Value);
            Assert.AreEqual("1040", xDocumentCategories?[3].Attribute("id")?.Value);
            Assert.AreEqual("2000", xDocumentCategories?[4].Attribute("id")?.Value); // Movies
            Assert.AreEqual("2030", xDocumentCategories?[5].Attribute("id")?.Value);
            Assert.AreEqual("7030", xDocumentCategories?[6].Attribute("id")?.Value);
            Assert.AreEqual(9, xDocumentCategories?[4]?.Elements("subcat").ToList().Count); // Movies
        }
        public void TestGetTorznabCategoryList()
        {
            var tcc = CreateTestDataset();

            // unsorted list
            var cats     = tcc.GetTorznabCategoryList();
            var expected = new List <TorznabCategory>
            {
                TorznabCatType.Movies.CopyWithoutSubCategories(),
                TorznabCatType.MoviesSD.CopyWithoutSubCategories(),
                TorznabCatType.Books.CopyWithoutSubCategories(),
                TorznabCatType.BooksComics.CopyWithoutSubCategories(),
                TorznabCatType.Console.CopyWithoutSubCategories(),
                TorznabCatType.ConsoleXBox.CopyWithoutSubCategories(),
                TorznabCatType.ConsoleWii.CopyWithoutSubCategories(),
                new TorznabCategory(100044, "Console/Xbox_c"),
                new TorznabCategory(137107, "Console/Wii_c"),
                new TorznabCategory(100040, "Console/Xbox_c2")
            };

            TestCategories.CompareCategoryTrees(expected, cats);

            // sorted list
            cats     = tcc.GetTorznabCategoryList(true);
            expected = new List <TorznabCategory>
            {
                TorznabCatType.Console.CopyWithoutSubCategories(),
                    TorznabCatType.ConsoleWii.CopyWithoutSubCategories(),
                    TorznabCatType.ConsoleXBox.CopyWithoutSubCategories(),
                    TorznabCatType.Movies.CopyWithoutSubCategories(),
                    TorznabCatType.MoviesSD.CopyWithoutSubCategories(),
                    TorznabCatType.Books.CopyWithoutSubCategories(),
                    TorznabCatType.BooksComics.CopyWithoutSubCategories(),
                new TorznabCategory(137107, "Console/Wii_c"),
                new TorznabCategory(100044, "Console/Xbox_c"),
                new TorznabCategory(100040, "Console/Xbox_c2")
            };
            TestCategories.CompareCategoryTrees(expected, cats);
        }
        public void TestConcat()
        {
            var lhs = new TorznabCapabilitiesCategories();
            var rhs = CreateTestDataset();

            lhs.Concat(rhs);
            var expected = new List <TorznabCategory>
            {
                TorznabCatType.Movies.CopyWithoutSubCategories(),
                TorznabCatType.Books.CopyWithoutSubCategories(),
                TorznabCatType.Console.CopyWithoutSubCategories()
            };

            expected[0].SubCategories.Add(TorznabCatType.MoviesSD.CopyWithoutSubCategories());
            expected[1].SubCategories.Add(TorznabCatType.BooksComics.CopyWithoutSubCategories());
            expected[2].SubCategories.Add(TorznabCatType.ConsoleXBox.CopyWithoutSubCategories());
            expected[2].SubCategories.Add(TorznabCatType.ConsoleWii.CopyWithoutSubCategories());
            TestCategories.CompareCategoryTrees(expected, lhs.GetTorznabCategoryTree()); // removed custom cats
            Assert.AreEqual(0, lhs.GetTrackerCategories().Count);                        // removed tracker mapping

            lhs = CreateTestDataset();
            rhs = CreateTestDataset();
            lhs.Concat(rhs);
            expected = new List <TorznabCategory>
            {
                TorznabCatType.Movies.CopyWithoutSubCategories(),
                    TorznabCatType.Books.CopyWithoutSubCategories(),
                    TorznabCatType.Console.CopyWithoutSubCategories(),
                new TorznabCategory(100044, "Console/Xbox_c"),
                new TorznabCategory(137107, "Console/Wii_c"),
                new TorznabCategory(100040, "Console/Xbox_c2")
            };
            expected[0].SubCategories.Add(TorznabCatType.MoviesSD.CopyWithoutSubCategories());
            expected[1].SubCategories.Add(TorznabCatType.BooksComics.CopyWithoutSubCategories());
            expected[2].SubCategories.Add(TorznabCatType.ConsoleXBox.CopyWithoutSubCategories());
            expected[2].SubCategories.Add(TorznabCatType.ConsoleWii.CopyWithoutSubCategories());
            TestCategories.CompareCategoryTrees(expected, lhs.GetTorznabCategoryTree()); // check there are not duplicates
        }
예제 #9
0
 protected TestBase(string name, TestCategories categories)
 {
     Name     = name;
     Category = categories;
 }
예제 #10
0
 protected TestBase(string name, TestCategories categories)
 {
     Name = name;
     Category = categories;
 }
 public TestCategoryAttribute(TestCategories category)
 {
     _category = category;
 }
예제 #12
0
        public void TestCardigannTorznabCategories()
        {
            var definition = new IndexerDefinition // minimun indexer definition
            {
                Links = new List <string> {
                    "https://example.com"
                },
                Caps = new capabilitiesBlock
                {
                    Modes = new Dictionary <string, List <string> >
                    {
                        { "search", new List <string> {
                              "q"
                          } }
                    }
                },
                Search = new searchBlock()
            };
            var indexer = new CardigannIndexer(null, null, null, null, definition);

            Assert.True(indexer.TorznabCaps.SearchAvailable);
            Assert.IsEmpty(indexer.TorznabCaps.TvSearchParams);
            Assert.False(indexer.TorznabCaps.TvSearchAvailable);
            Assert.False(indexer.TorznabCaps.TvSearchSeasonAvailable);
            Assert.False(indexer.TorznabCaps.TvSearchEpAvailable);
            Assert.False(indexer.TorznabCaps.TvSearchImdbAvailable);
            Assert.False(indexer.TorznabCaps.TvSearchTvdbAvailable);
            Assert.False(indexer.TorznabCaps.TvSearchTvRageAvailable);
            Assert.IsEmpty(indexer.TorznabCaps.MovieSearchParams);
            Assert.False(indexer.TorznabCaps.MovieSearchAvailable);
            Assert.False(indexer.TorznabCaps.MovieSearchImdbAvailable);
            Assert.False(indexer.TorznabCaps.MovieSearchTmdbAvailable);
            Assert.IsEmpty(indexer.TorznabCaps.MusicSearchParams);
            Assert.False(indexer.TorznabCaps.MusicSearchAvailable);
            Assert.False(indexer.TorznabCaps.MusicSearchAlbumAvailable);
            Assert.False(indexer.TorznabCaps.MusicSearchArtistAvailable);
            Assert.False(indexer.TorznabCaps.MusicSearchLabelAvailable);
            Assert.False(indexer.TorznabCaps.MusicSearchYearAvailable);
            Assert.IsEmpty(indexer.TorznabCaps.BookSearchParams);
            Assert.False(indexer.TorznabCaps.BookSearchAvailable);
            Assert.False(indexer.TorznabCaps.BookSearchTitleAvailable);
            Assert.False(indexer.TorznabCaps.BookSearchAuthorAvailable);
            Assert.AreEqual(0, indexer.TorznabCaps.Categories.GetTorznabCategoryTree().Count);

            definition = new IndexerDefinition // test categories (same as in C# indexer)
            {
                Links = new List <string> {
                    "https://example.com"
                },
                Caps = new capabilitiesBlock
                {
                    Modes = new Dictionary <string, List <string> >
                    {
                        { "search", new List <string> {
                              "q"
                          } }
                    },
                    Categories = new Dictionary <string, string>
                    {
                        { "1", TorznabCatType.Movies.Name },        // integer cat (has children)
                        { "mov_sd", TorznabCatType.MoviesSD.Name }, // string cat (child cat)
                        { "33", TorznabCatType.BooksComics.Name } // integer cat (child cat)
                    },
                    Categorymappings = new List <CategorymappingBlock>
                    {
                        new CategorymappingBlock // integer cat with description (child cat) => generates custom cat 100044
                        {
                            id   = "44",
                            cat  = TorznabCatType.ConsoleXBox.Name,
                            desc = "Console/Xbox_c"
                        },
                        new CategorymappingBlock // string cat with description (child cat)
                        {
                            id   = "con_wii",
                            cat  = TorznabCatType.ConsoleWii.Name,
                            desc = "Console/Wii_c"
                        },
                        new CategorymappingBlock // duplicate category (2 indexer cats => 1 toznab cat)
                        {
                            id   = "45",
                            cat  = TorznabCatType.ConsoleXBox.Name,
                            desc = "Console/Xbox_c2"
                        },
                    }
                },
                Search = new searchBlock()
            };
            indexer = new CardigannIndexer(null, null, null, null, definition);

            // test categories
            var expected = new List <TorznabCategory>
            {
                TorznabCatType.Movies.CopyWithoutSubCategories(),
                TorznabCatType.Books.CopyWithoutSubCategories(),
                TorznabCatType.Console.CopyWithoutSubCategories(),
                new TorznabCategory(100044, "Console/Xbox_c"),
                new TorznabCategory(137107, "Console/Wii_c"),
                new TorznabCategory(100045, "Console/Xbox_c2")
            };

            expected[0].SubCategories.Add(TorznabCatType.MoviesSD.CopyWithoutSubCategories());
            expected[1].SubCategories.Add(TorznabCatType.BooksComics.CopyWithoutSubCategories());
            expected[2].SubCategories.Add(TorznabCatType.ConsoleXBox.CopyWithoutSubCategories());
            expected[2].SubCategories.Add(TorznabCatType.ConsoleWii.CopyWithoutSubCategories());
            TestCategories.CompareCategoryTrees(expected, indexer.TorznabCaps.Categories.GetTorznabCategoryTree());

            definition = new IndexerDefinition // test search modes
            {
                Links = new List <string> {
                    "https://example.com"
                },
                Caps = new capabilitiesBlock
                {
                    Modes = new Dictionary <string, List <string> >
                    {
                        { "search", new List <string> {
                              "q"
                          } },
                        { "tv-search", new List <string> {
                              "q", "season", "ep", "imdbid", "tvdbid", "rid"
                          } },
                        { "movie-search", new List <string> {
                              "q", "imdbid", "tmdbid"
                          } },
                        { "music-search", new List <string> {
                              "q", "album", "artist", "label", "year"
                          } },
                        { "book-search", new List <string> {
                              "q", "title", "author"
                          } }
                    },
                    Categories = new Dictionary <string, string>()
                },
                Search = new searchBlock()
            };
            indexer = new CardigannIndexer(null, null, null, null, definition);

            Assert.True(indexer.TorznabCaps.SearchAvailable);
            Assert.AreEqual(
                new List <TvSearchParam>
            {
                TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep, TvSearchParam.ImdbId, TvSearchParam.TvdbId, TvSearchParam.RId
            },
                indexer.TorznabCaps.TvSearchParams
                );
            Assert.True(indexer.TorznabCaps.TvSearchAvailable);
            Assert.True(indexer.TorznabCaps.TvSearchSeasonAvailable);
            Assert.True(indexer.TorznabCaps.TvSearchEpAvailable);
            // TODO: SupportsImdbTVSearch is disabled in Jackett.Common.Models.TorznabCapabilities.TvSearchImdbAvailable
            Assert.False(indexer.TorznabCaps.TvSearchImdbAvailable);
            Assert.True(indexer.TorznabCaps.TvSearchTvdbAvailable);
            Assert.True(indexer.TorznabCaps.TvSearchTvRageAvailable);
            Assert.AreEqual(
                new List <MovieSearchParam>
            {
                MovieSearchParam.Q, MovieSearchParam.ImdbId, MovieSearchParam.TmdbId
            },
                indexer.TorznabCaps.MovieSearchParams
                );
            Assert.True(indexer.TorznabCaps.MovieSearchAvailable);
            Assert.True(indexer.TorznabCaps.MovieSearchImdbAvailable);
            Assert.True(indexer.TorznabCaps.MovieSearchTmdbAvailable);
            Assert.AreEqual(
                new List <MusicSearchParam>
            {
                MusicSearchParam.Q, MusicSearchParam.Album, MusicSearchParam.Artist, MusicSearchParam.Label, MusicSearchParam.Year
            },
                indexer.TorznabCaps.MusicSearchParams
                );
            Assert.True(indexer.TorznabCaps.MusicSearchAvailable);
            Assert.True(indexer.TorznabCaps.MusicSearchAlbumAvailable);
            Assert.True(indexer.TorznabCaps.MusicSearchArtistAvailable);
            Assert.True(indexer.TorznabCaps.MusicSearchLabelAvailable);
            Assert.True(indexer.TorznabCaps.MusicSearchYearAvailable);
            Assert.AreEqual(
                new List <BookSearchParam>
            {
                BookSearchParam.Q, BookSearchParam.Title, BookSearchParam.Author
            },
                indexer.TorznabCaps.BookSearchParams
                );
            Assert.True(indexer.TorznabCaps.BookSearchAvailable);
            Assert.True(indexer.TorznabCaps.BookSearchTitleAvailable);
            Assert.True(indexer.TorznabCaps.BookSearchAuthorAvailable);

            // test Jackett UI categories (internal JSON) => same code path as C# indexer
            // test Torznab caps (XML) => same code path as C# indexer
        }
        public void TestAddCategoryMapping()
        {
            var tcc  = new TorznabCapabilitiesCategories();
            var cats = tcc.GetTorznabCategoryTree();

            // add "int" category (parent category)
            // + Movies
            tcc.AddCategoryMapping("1", TorznabCatType.Movies);
            var expected = new List <TorznabCategory>
            {
                TorznabCatType.Movies.CopyWithoutSubCategories()
            };

            TestCategories.CompareCategoryTrees(expected, cats);

            // add "string" category (child category)
            // - Movies
            //   + MoviesSD
            tcc.AddCategoryMapping("mov_sd", TorznabCatType.MoviesSD);
            expected[0].SubCategories.Add(TorznabCatType.MoviesSD.CopyWithoutSubCategories());
            TestCategories.CompareCategoryTrees(expected, cats);

            // add subcategory of books (child category)
            // - Movies
            //   - MoviesSD
            // + Books
            //   + BooksComics
            tcc.AddCategoryMapping("33", TorznabCatType.BooksComics);
            expected.Add(TorznabCatType.Books.CopyWithoutSubCategories());
            expected[1].SubCategories.Add(TorznabCatType.BooksComics.CopyWithoutSubCategories());
            TestCategories.CompareCategoryTrees(expected, cats);

            // add int category with description => custom category. it's converted into 2 different categories
            // - Movies
            //   - MoviesSD
            // - Books
            //   - BooksComics
            // + Console
            //   + ConsoleXBox
            // + Custom Cat "Console/Xbox_c"
            tcc.AddCategoryMapping("44", TorznabCatType.ConsoleXBox, "Console/Xbox_c");
            expected.Add(TorznabCatType.Console.CopyWithoutSubCategories());
            expected[2].SubCategories.Add(TorznabCatType.ConsoleXBox.CopyWithoutSubCategories());
            expected.Add(new TorznabCategory(100044, "Console/Xbox_c"));
            TestCategories.CompareCategoryTrees(expected, cats);

            // add string category with description => custom category. it's converted into 2 different categories
            // - Movies
            //   - MoviesSD
            // - Books
            //   - BooksComics
            // - Console
            //   - ConsoleXBox
            //   + ConsoleWii
            // - Custom Cat "Console/Xbox_c"
            // + Custom Cat "Console/Wii_c"
            tcc.AddCategoryMapping("con_wii", TorznabCatType.ConsoleWii, "Console/Wii_c");
            expected[2].SubCategories.Add(TorznabCatType.ConsoleWii.CopyWithoutSubCategories());
            expected.Add(new TorznabCategory(137107, "Console/Wii_c"));
            TestCategories.CompareCategoryTrees(expected, cats);

            // add another int category with description that maps to ConsoleXbox (there are 2 tracker cats => 1 torznab cat)
            // - Movies
            //   - MoviesSD
            // - Books
            //   - BooksComics
            // - Console
            //   - ConsoleXBox (this is not added again)
            //   - ConsoleWii
            // - Custom Cat "Console/Xbox_c"
            // - Custom Cat "Console/Wii_c"
            // + Custom Cat "Console/Xbox_c2"
            tcc.AddCategoryMapping("45", TorznabCatType.ConsoleXBox, "Console/Xbox_c2");
            expected.Add(new TorznabCategory(100045, "Console/Xbox_c2"));
            TestCategories.CompareCategoryTrees(expected, cats);
        }
예제 #14
0
 public void Add(TestCategories category)
 {
     _context.TestCategories.Add(category);
     _context.SaveChanges();
 }