public async Task WhenTwoGifQuery_AndOneExists_ThenReturnOneResult() { var request = new ByIdsRequest(ApiKeys.Valid, new[] { GifIds.GifIdNotExists, GifIds.GifIdExists1 }); var response = await _sut.GetByIdsAsync(request); Assert.That(response.Gifs.Single().Id, Is.EqualTo(GifIds.GifIdExists1)); }
public void WhenNoGifExists_ThenThrowExceptionNotFound() { var request = new ByIdsRequest(ApiKeys.Valid, new [] { GifIds.GifIdNotExists }); var ex = Assert.ThrowsAsync <GiphyApiClientException>(() => _sut.GetByIdsAsync(request)); Assert.That(ex.HttpStatusCode, Is.EqualTo(ApiStatusCodes.NotFound)); }
public async Task WhenTwoGifQuery_AndBothExists_ThenReturnTwoResults() { var request = new ByIdsRequest(ApiKeys.Valid, new[] { GifIds.GifIdExists1, GifIds.GifIdExists2 }); var response = await _sut.GetByIdsAsync(request); Assert.That(response.Gifs.Count(), Is.EqualTo(2)); Assert.That(response.Gifs.First().Id, Is.EqualTo(GifIds.GifIdExists1)); Assert.That(response.Gifs.Second().Id, Is.EqualTo(GifIds.GifIdExists2)); }
public Uri Create(ByIdsRequest request) { return(request.AddUriParams(new Uri(_settings.BaseUrl).SetPath("v1/gifs"))); }
/// <summary> /// Returns metadata of multiple GIFs when a user enters multiple GIF unique ID. /// </summary> /// <param name="request">Request object.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>The task object representing the asynchronous operation.</returns> public async Task <ByIdsResponse> GetByIdsAsync(ByIdsRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var uri = _uriFactory.Create(request); return(await GetAsync <ByIdsResponse>(uri, cancellationToken)); }