예제 #1
0
        public async Task GetPodcastStatisticOverallResponseAsync_Should_Return_ApiResponse_With_Statistic_By_Given_OverallStatisticFilter()
        {
            StatisticClientMock statisticClientMock = StatisticClientMock.Create();

            statisticClientMock.RestApiClientMock
            .Setup(client => client.GetApiResponseAsync <Statistic>(
                       It.IsAny <string>(),
                       It.IsAny <IList <KeyValuePair <string, string> > >(),
                       It.IsAny <IDictionary <string, string> >()))
            .ReturnsAsync(() => new ApiResponse <Statistic>()
            {
                Model = new Statistic()
            });

            var queryParams = OverallStatisticFilter.ToQueryParams();

            ApiResponse <Statistic> apiResponse = await statisticClientMock.GetPodcastStatisticOverallResponseAsync(PodcastId, OverallStatisticFilter);

            statisticClientMock.RestApiClientMock.Verify(client => client.GetApiResponseAsync <Statistic>(
                                                             It.Is <string>(url => url == PodcastStatisticOverallUrl),
                                                             It.Is <IList <KeyValuePair <string, string> > >(keyValues => keyValues.Any(pair => queryParams.Contains(pair))),
                                                             It.Is <IDictionary <string, string> >(keyValues => keyValues == null)), Times.Once);

            Assert.NotNull(apiResponse);
            Assert.NotNull(apiResponse.Model);
        }
        public async Task <ApiResponse <Statistic> > GetPodcastStatisticOverallResponseAsync(
            int podcastId, OverallStatisticFilter overallStatisticFilter = null)
        {
            Ensure.GreaterThanZero(podcastId, nameof(podcastId));

            ApiResponse <Statistic> apiResponse = await _restApiClient.GetApiResponseAsync <Statistic>(
                UrlPathBuilder.GetPodcastStatisticOverallUrl(podcastId),
                overallStatisticFilter?.ToQueryParams());

            return(apiResponse);
        }