Пример #1
0
            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));
            }
Пример #2
0
            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));
            }
Пример #3
0
            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));
            }
Пример #4
0
 public Uri Create(ByIdsRequest request)
 {
     return(request.AddUriParams(new Uri(_settings.BaseUrl).SetPath("v1/gifs")));
 }
Пример #5
0
        /// <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));
        }