mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00

* Core: Categories are stored in a real tree * Sorting: First Torznab categories sorted by Id and then custom cats sorted by Name * Filtering: Results with child category are not removed when searching by parent category. Details in #8049 * Jacket UI: Add parent category when at least one child category exists * Torznab (caps): Remove non existent children categories. Remove duplicated categories. Details in #10006
37 lines
1.6 KiB
C#
37 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
using Jackett.Common.Models;
|
|
using NUnit.Framework;
|
|
|
|
namespace Jackett.Test.TestHelpers
|
|
{
|
|
public static class TestCategories
|
|
{
|
|
public static void AddTestCategories(TorznabCapabilitiesCategories tcc)
|
|
{
|
|
// these categories are chosen to test all kind of category types:
|
|
// - with integer and string id
|
|
// - with and without description
|
|
// - parent and child categories
|
|
// - custom categories are not added automatically but they are created from other categories automatically
|
|
// - categories and subcategories are unsorted to test the sort when required
|
|
tcc.AddCategoryMapping("1", TorznabCatType.Movies);
|
|
tcc.AddCategoryMapping("mov_sd", TorznabCatType.MoviesSD);
|
|
tcc.AddCategoryMapping("33", TorznabCatType.BooksComics);
|
|
tcc.AddCategoryMapping("44", TorznabCatType.ConsoleXBox, "Console/Xbox_c");
|
|
tcc.AddCategoryMapping("con_wii", TorznabCatType.ConsoleWii, "Console/Wii_c");
|
|
tcc.AddCategoryMapping("40", TorznabCatType.ConsoleXBox, "Console/Xbox_c2");
|
|
}
|
|
|
|
public static void CompareCategoryTrees(List<TorznabCategory> tree1, List<TorznabCategory> tree2)
|
|
{
|
|
Assert.AreEqual(tree1.Count, tree2.Count);
|
|
for (var i = 0; i < tree1.Count; i++)
|
|
{
|
|
Assert.AreEqual(tree1[i].ID, tree2[i].ID);
|
|
Assert.AreEqual(tree1[i].Name, tree2[i].Name);
|
|
CompareCategoryTrees(tree1[i].SubCategories, tree2[i].SubCategories);
|
|
}
|
|
}
|
|
}
|
|
}
|