Skip to content

Commit

Permalink
core: add more unit tests (#9907)
Browse files Browse the repository at this point in the history
  • Loading branch information
ngosang committed Oct 19, 2020
1 parent ec48676 commit 74d08c9
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion src/Jackett.Test/Common/Models/TorznabCapabilitiesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,49 @@ public void TestTorznabCaps()
Assert.AreEqual(TorznabCatType.MoviesSD.Name, xDoumentCategories?[1].Attribute("name")?.Value);
}

// TODO: test concatenation
[Test]
public void TestTorznabConcat()
{
var torznabCaps1 = new TorznabCapabilities();
var torznabCaps2 = new TorznabCapabilities();
var res = TorznabCapabilities.Concat(torznabCaps1, torznabCaps2);

Assert.True(res.SearchAvailable);
Assert.IsEmpty(res.TvSearchParams);
Assert.IsEmpty(res.MovieSearchParams);
Assert.IsEmpty(res.MusicSearchParams);
Assert.IsEmpty(res.BookSearchParams);
Assert.IsEmpty(res.Categories);

torznabCaps1 = new TorznabCapabilities
{
SearchAvailable = false,
TvSearchParams = new List<TvSearchParam> {TvSearchParam.Q},
MovieSearchParams = new List<MovieSearchParam> {MovieSearchParam.Q},
MusicSearchParams = new List<MusicSearchParam> {MusicSearchParam.Q},
BookSearchParams = new List<BookSearchParam> {BookSearchParam.Q},
Categories = new List<TorznabCategory>{TorznabCatType.Movies, new TorznabCategory(100001, "CustomCat1")}
};
torznabCaps2 = new TorznabCapabilities
{
SearchAvailable = false,
TvSearchParams = new List<TvSearchParam> {TvSearchParam.Season},
MovieSearchParams = new List<MovieSearchParam> {MovieSearchParam.ImdbId},
MusicSearchParams = new List<MusicSearchParam> {MusicSearchParam.Artist},
BookSearchParams = new List<BookSearchParam> {BookSearchParam.Title},
Categories = new List<TorznabCategory>{TorznabCatType.TVAnime, new TorznabCategory(100002, "CustomCat2")}
};
res = TorznabCapabilities.Concat(torznabCaps1, torznabCaps2);

Assert.False(res.SearchAvailable);
Assert.True(res.TvSearchParams.Count == 2);
Assert.True(res.MovieSearchParams.Count == 2);
Assert.True(res.MusicSearchParams.Count == 2);
Assert.True(res.BookSearchParams.Count == 2);
Assert.True(res.Categories.Count == 3); // only CustomCat2 is removed
}

// TODO: test SupportsCategories
// TODO: test categories in GetXDocument
}
}

0 comments on commit 74d08c9

Please sign in to comment.