public async Task GetUpcomingVideoList_ARIRANG_OK()
        {
            UpcomingVideoListResponse upcomingVideoListResponse = await service.GetUpcomingVideoListAsync(ARIRANG_CHANNEL_SEQ, 5, 1);

            Assert.AreEqual(upcomingVideoListResponse.TotalVideoCount, 5);
            Assert.AreEqual(upcomingVideoListResponse.Videos.Count, 5);
        }
        public async Task GetUpcomingVideoList_EMPTY_OK()
        {
            UpcomingVideoListResponse upcomingVideoListResponse = await service.GetUpcomingVideoListAsync(TWICE_CHANNEL_SEQ, 10, 1);

            Assert.AreEqual(upcomingVideoListResponse.TotalVideoCount, 0);
            Assert.AreEqual(upcomingVideoListResponse.Videos.Count, 0);
        }
 public async Task GetUpcomingVideoList_ArgumentException_By_Negative_Page()
 {
     int count = 5, page = -1;
     await Assert.ThrowsExceptionAsync <ArgumentException>(async() =>
     {
         UpcomingVideoListResponse channelVideoListResponse = await service.GetUpcomingVideoListAsync(INVALID_NEGATIVE_CHANNEL_SEQ, count, page);
     });
 }
 public async Task GetUpcomingVideoList_TaskCanceledException()
 {
     CancellationTokenSource cts = new CancellationTokenSource(100);
     int count = 5;
     await Assert.ThrowsExceptionAsync <TaskCanceledException>(async() =>
     {
         UpcomingVideoListResponse channelVideoListResponse = await service.GetUpcomingVideoListAsync(TWICE_CHANNEL_SEQ, count, 1, cts.Token);
     });
 }
        public async Task <UpcomingVideoListResponse> FetchNextAsync()
        {
            if (!hasNext)
            {
                return(null);
            }

            UpcomingVideoListResponse channelVideoListResponse = await _service.GetUpcomingVideoListAsync(_channelSeq, _count, currentPage);

            if (channelVideoListResponse.Videos.Count < _count)
            {
                hasNext = false;
            }

            currentPage++;

            return(channelVideoListResponse);
        }
Beispiel #6
0
        public async Task <UpcomingVideoListResponse> GetUpcomingVideoListAsync(int channelSeq, int count, int page, CancellationToken cancellationToken)
        {
            ValidateStrictlyPostiveInteger(channelSeq, nameof(channelSeq));
            ValidateStrictlyPostiveInteger(count, nameof(count));
            ValidateStrictlyPostiveInteger(page, nameof(page));

            count = Math.Min(count, 50);

            HttpRequestMessage  request  = new HttpRequestMessage(HttpMethod.Get, string.Format(_upcomingVideoListEndpoint, _appId, channelSeq, count, page, _locale.Value));
            HttpResponseMessage response = await _http.SendAsync(request, cancellationToken);

            if (!response.IsSuccessStatusCode)
            {
                await HandleNonSuccessStatusCodeAsync(response);
            }

            string responseText = await response.Content.ReadAsStringAsync();

            if (string.IsNullOrEmpty(responseText) || string.IsNullOrWhiteSpace(responseText))
            {
                throw new UnkownErrorException();
            }

            dynamic responseTextDynamic = JsonConvert.DeserializeObject <dynamic>(responseText);

            if (responseTextDynamic == null ||
                (responseTextDynamic != null && responseTextDynamic["result"] == null))
            {
                throw new UnkownErrorException();
            }

            UpcomingVideoListResponse upcomingVideoListResponse = JsonConvert.DeserializeObject <UpcomingVideoListResponse>(responseTextDynamic["result"].ToString());

            if (upcomingVideoListResponse == null)
            {
                throw new UnmappableResponseException();
            }

            return(upcomingVideoListResponse);
        }
 public async Task GetUpcomingVideoList_ArgumentException_By_Negative_Invalid_Channel_Seq()
 {
     await Assert.ThrowsExceptionAsync <ArgumentException>(async() => {
         UpcomingVideoListResponse upcomingVideoListResponse = await service.GetUpcomingVideoListAsync(INVALID_NEGATIVE_CHANNEL_SEQ, 10, 1);
     });
 }
 public async Task GetUpcomingVideoList_InternalServerErrorException_By_Invalid_Channel_Seq()
 {
     await Assert.ThrowsExceptionAsync <InternalServerErrorException>(async() => {
         UpcomingVideoListResponse upcomingVideoListResponse = await service.GetUpcomingVideoListAsync(INVALID_CHANNEL_SEQ, 10, 1);
     });
 }