-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #148 from vosmiic/extend-unit-tests
Extend unit tests
- Loading branch information
Showing
14 changed files
with
1,181 additions
and
305 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
jellyfin-ani-sync-unit-tests/HelperTests/AnimeListHelperTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using jellyfin_ani_sync.Helpers; | ||
using NUnit.Framework; | ||
|
||
namespace jellyfin_ani_sync_unit_tests.HelperTests; | ||
|
||
public class AnimeListHelperTests { | ||
[Test] | ||
public void GetCorrectAniDbSeasonCount() { | ||
int aniDbId = 1; | ||
string tvdbId = "abc123"; | ||
AnimeListHelpers.AnimeListXml animeListXml = new AnimeListHelpers.AnimeListXml { | ||
Anime = new List<AnimeListHelpers.AnimeListAnime> { | ||
new() { | ||
Anidbid = aniDbId.ToString(), | ||
Tvdbid = tvdbId | ||
}, | ||
new() { | ||
Anidbid = aniDbId.ToString(), | ||
Tvdbid = tvdbId | ||
}, | ||
new() { | ||
Anidbid = aniDbId.ToString(), | ||
Tvdbid = String.Empty | ||
} | ||
} | ||
}; | ||
var returned = AnimeListHelpers.ListAllSeasonOfAniDbSeries(aniDbId, animeListXml); | ||
Assert.IsTrue(returned != null); | ||
Assert.IsTrue(returned.Count() == 2); | ||
} | ||
|
||
[Test] | ||
public void GetCorrectAniDbSeason() { | ||
int aniDbId = 1; | ||
string tvdbId = "abc123"; | ||
AnimeListHelpers.AnimeListXml animeListXml = new AnimeListHelpers.AnimeListXml { | ||
Anime = new List<AnimeListHelpers.AnimeListAnime> { | ||
new() { | ||
Anidbid = aniDbId.ToString(), | ||
Tvdbid = tvdbId | ||
}, | ||
new() { | ||
Anidbid = aniDbId.ToString(), | ||
Tvdbid = tvdbId | ||
}, | ||
new() { | ||
Anidbid = aniDbId.ToString(), | ||
Tvdbid = String.Empty | ||
} | ||
} | ||
}; | ||
var returned = AnimeListHelpers.GetAniDbSeason(aniDbId, animeListXml); | ||
Assert.IsTrue(returned != null); | ||
Assert.IsTrue(returned.Anidbid == aniDbId.ToString()); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
jellyfin-ani-sync-unit-tests/HelperTests/AnimeOfflineDatabaseHelperTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System.Collections.Generic; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Text.Json; | ||
using System.Threading.Tasks; | ||
using jellyfin_ani_sync.Helpers; | ||
using NUnit.Framework; | ||
|
||
namespace jellyfin_ani_sync_unit_tests.HelperTests; | ||
|
||
public class AnimeOfflineDatabaseHelperTests { | ||
private HttpClient _httpClient; | ||
|
||
private void Setup(List<Helpers.HttpCall> httpCalls) { | ||
Helpers.MockHttpCalls(httpCalls, ref _httpClient); | ||
} | ||
|
||
[Test] | ||
public async Task DeserializeMetadataCall() { | ||
Setup(new List<Helpers.HttpCall> { | ||
new() { | ||
RequestMethod = HttpMethod.Get, | ||
RequestUrlMatch = url => url.EndsWith("ids"), | ||
ResponseCode = HttpStatusCode.OK, | ||
ResponseContent = JsonSerializer.Serialize(new AnimeOfflineDatabaseHelpers.OfflineDatabaseResponse { | ||
AniDb = 1, | ||
Anilist = 1, | ||
Kitsu = 1, | ||
MyAnimeList = 1 | ||
}) | ||
} | ||
}); | ||
|
||
AnimeOfflineDatabaseHelpers.OfflineDatabaseResponse? result = await AnimeOfflineDatabaseHelpers.GetProviderIdsFromMetadataProvider(_httpClient, 1, AnimeOfflineDatabaseHelpers.Source.Myanimelist); | ||
Assert.IsTrue(result != null); | ||
Assert.IsTrue(result.AniDb == 1); | ||
Assert.IsTrue(result.Anilist == 1); | ||
Assert.IsTrue(result.Kitsu == 1); | ||
Assert.IsTrue(result.MyAnimeList == 1); | ||
} | ||
} |
Oops, something went wrong.