Example #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);
        }
Example #2
0
        public async Task GetPodcastStatisticOverallAsync_Should_Return_Statistic_By_Given_PodcastId()
        {
            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()
            });

            Statistic statistic = await statisticClientMock.GetPodcastStatisticOverallAsync(PodcastId);

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

            Assert.NotNull(statistic);
        }
        public async Task GetEpisodeStatisticResponseAsync_Should_Throw_ArgumentException_If_EpisodeStatisticFilter_EpisodeId_Not_Greater_Than_Zero()
        {
            StatisticClientMock statisticClientMock = StatisticClientMock.Create();

            await Assert.ThrowsAsync <ArgumentException>(() => statisticClientMock.GetEpisodeStatisticResponseAsync(PodcastId, new EpisodeStatisticFilter(-1)));
        }
Example #4
0
        public async Task GetPodcastStatisticOverallResponseAsync_Should_Throw_ArgumentException_If_PodcastId_Not_Greater_Than_Zero()
        {
            StatisticClientMock statisticClientMock = StatisticClientMock.Create();

            await Assert.ThrowsAsync <ArgumentException>(() => statisticClientMock.GetPodcastStatisticOverallResponseAsync(-1));
        }
        public async Task GetEpisodeStatisticResponseAsync_Should_Throw_ArgumentNullException_If_EpisodeStatisticFilter_Is_Null()
        {
            StatisticClientMock statisticClientMock = StatisticClientMock.Create();

            await Assert.ThrowsAsync <ArgumentNullException>(() => statisticClientMock.GetEpisodeStatisticResponseAsync(PodcastId, null));
        }