|
| 1 | +using AniAPI.NET.Enums; |
| 2 | +using AniAPI.NET.Filters; |
| 3 | +using AniAPI.NET.Models; |
| 4 | +using Newtonsoft.Json; |
| 5 | +using System; |
| 6 | +using System.Collections.Generic; |
| 7 | +using System.Linq; |
| 8 | +using System.Text; |
| 9 | +using System.Threading.Tasks; |
| 10 | +using Xunit; |
| 11 | +using Xunit.Abstractions; |
| 12 | + |
| 13 | +namespace AniAPI.NET.Test |
| 14 | +{ |
| 15 | + public class AnimeTest |
| 16 | + { |
| 17 | + private ITestOutputHelper output; |
| 18 | + |
| 19 | + public AnimeTest(ITestOutputHelper output) |
| 20 | + { |
| 21 | + this.output = output; |
| 22 | + } |
| 23 | + |
| 24 | + [Fact] |
| 25 | + public void Get_Anime() |
| 26 | + { |
| 27 | + long id = 1; |
| 28 | + |
| 29 | + var result = AniAPI.Instance.GetAnime(id); |
| 30 | + |
| 31 | + Assert.NotNull(result); |
| 32 | + Assert.IsType<APIResponse<Anime>>(result); |
| 33 | + |
| 34 | + Assert.True(result.StatusCode == 200); |
| 35 | + Assert.NotNull(result.Data); |
| 36 | + |
| 37 | + Assert.Equal(id, result.Data.Id); |
| 38 | + |
| 39 | + output.WriteLine(JsonConvert.SerializeObject(result)); |
| 40 | + } |
| 41 | + |
| 42 | + [Fact] |
| 43 | + public void Get_Anime_List() |
| 44 | + { |
| 45 | + AnimeFilter filter = new AnimeFilter() |
| 46 | + { |
| 47 | + Title = "Cowboy Bebop", |
| 48 | + AnilistId = 1, |
| 49 | + MyAnimeListId = 1, |
| 50 | + Formats = new AnimeFormatEnum[2] |
| 51 | + { |
| 52 | + AnimeFormatEnum.TV, |
| 53 | + AnimeFormatEnum.TV_SHORT |
| 54 | + }, |
| 55 | + Status = AnimeStatusEnum.FINISHED, |
| 56 | + Year = 1998, |
| 57 | + Season = AnimeSeasonEnum.SPRING, |
| 58 | + Genres = new string[3] |
| 59 | + { |
| 60 | + "Action", |
| 61 | + "Guns", |
| 62 | + "Military" |
| 63 | + }, |
| 64 | + Sort = new Dictionary<string, SortDirectionEnum>() |
| 65 | + { |
| 66 | + { "titles.en", SortDirectionEnum.DESCENDING } |
| 67 | + } |
| 68 | + }; |
| 69 | + |
| 70 | + var result = AniAPI.Instance.GetAnimeList(filter); |
| 71 | + |
| 72 | + Assert.NotNull(result); |
| 73 | + Assert.IsType<APIResponse<Pagination<Anime>>>(result); |
| 74 | + |
| 75 | + Assert.True(result.StatusCode == 200); |
| 76 | + Assert.NotNull(result.Data); |
| 77 | + |
| 78 | + output.WriteLine(JsonConvert.SerializeObject(result)); |
| 79 | + } |
| 80 | + } |
| 81 | +} |
0 commit comments