public async Task GetPerson_CorrectId_ShouldReturnNotNullPerson(long malId) { // Given var returnedPerson = await _jikan.GetPerson(malId); // Then returnedPerson.Should().NotBeNull(); }
public async Task <MalSeiyuuUpdateData> GetSeiyuuDataAsync(long malId) { var parsedData = await _jikanClient.GetPerson(malId); if (parsedData is null) { return(null); } return(new MalSeiyuuUpdateData( parsedData.Name, parsedData.More, $"{parsedData.FamilyName ?? string.Empty} {parsedData.GivenName ?? string.Empty}".Trim(), EmptyStringIfPlaceholder(parsedData.ImageURL), parsedData.MemberFavorites, parsedData.Birthday, parsedData.VoiceActingRoles?.Select( x => new MalVoiceActingRoleUpdateData( x.Anime.MalId, x.Character.MalId, x.Role ) ) .ToList() ?? new List <MalVoiceActingRoleUpdateData>() )); }
private async Task <Person> SendSinglePersonRequest(long malId, short retryCount) { Person seiyuu = null; await Task.Delay(3000 + retryCount * 10000); try { seiyuu = await jikan.GetPerson(malId); } catch (Exception ex) { if (retryCount < 10) { if (ex.InnerException is JikanRequestException && (ex.InnerException as JikanRequestException).ResponseCode == System.Net.HttpStatusCode.TooManyRequests) { retryCount++; return(await SendSinglePersonRequest(malId, retryCount)); } else { if (ex.InnerException is JikanRequestException) { System.Net.HttpStatusCode responseCode = (ex.InnerException as JikanRequestException).ResponseCode; switch (responseCode) { case (System.Net.HttpStatusCode.NotFound): BlacklistId(malId, "Seiyuu", "404 Not Found"); break; case (System.Net.HttpStatusCode.InternalServerError): // BlacklistId(malId, "Seiyuu", "Not exist"); break; case (System.Net.HttpStatusCode.TooManyRequests): BlacklistId(malId, "Seiyuu", "429 Too much request"); break; default: BlacklistId(malId, "Seiyuu", "Other"); break; } } } } } return(seiyuu); }
public void GetPerson_WrongIdDoNotSurpressExceptions_ShouldThrowJikanRequestExceptionGetPerson() { Assert.ThrowsAnyAsync <JikanRequestException>(() => jikan.GetPerson(13308)); }
public void ShouldThrowJikanRequestExceptionGetPerson() { Assert.ThrowsAnyAsync <JikanRequestException>(() => jikan.GetPerson(13308)); }
public async Task GetPerson_CorrectId_ShouldReturnNotNullPerson(long malId) { Person returnedPerson = await _jikan.GetPerson(malId); Assert.NotNull(returnedPerson); }
public void ShouldReturnNotNullPerson(long malId) { Person returnedPerson = Task.Run(() => jikan.GetPerson(malId)).Result; Assert.NotNull(returnedPerson); }