public async Task GetPodcastByIdAsync_Should_Return_Podcast_By_Given_PodcastId() { PodcastClientMock podcastClientMock = PodcastClientMock.Create(); podcastClientMock.RestApiClientMock .Setup(client => client.GetApiResponseAsync <Podcast>( It.IsAny <string>(), It.IsAny <IList <KeyValuePair <string, string> > >(), It.IsAny <IDictionary <string, string> >())) .ReturnsAsync(() => new ApiResponse <Podcast>() { Model = new Podcast() }); Podcast podcast = await podcastClientMock.GetPodcastByIdAsync(PodcastId); podcastClientMock.RestApiClientMock.Verify(client => client.GetApiResponseAsync <Podcast>( It.Is <string>(url => url == PodcastByIdUrl), It.Is <IList <KeyValuePair <string, string> > >(keyValues => keyValues == null), It.Is <IDictionary <string, string> >(keyValues => keyValues == null)), Times.Once); Assert.NotNull(podcast); }
public async Task GetPodcastsAsync_Should_Return_ApiResponse_With_List_Of_Podcasts() { PodcastClientMock podcastClientMock = PodcastClientMock.Create(); podcastClientMock.RestApiClientMock .Setup(client => client.GetApiResponseAsync <List <Podcast> >( It.IsAny <string>(), It.IsAny <IList <KeyValuePair <string, string> > >(), It.IsAny <IDictionary <string, string> >())) .ReturnsAsync(() => new ApiResponse <List <Podcast> >() { Model = new List <Podcast>() }); List <Podcast> podcasts = await podcastClientMock.GetPodcastsAsync(); podcastClientMock.RestApiClientMock.Verify(client => client.GetApiResponseAsync <List <Podcast> >( It.Is <string>(url => url == PodcastUrl), It.Is <IList <KeyValuePair <string, string> > >(keyValues => keyValues == null), It.Is <IDictionary <string, string> >(keyValues => keyValues == null)), Times.Once); Assert.NotNull(podcasts); }
public async Task GetPodcastByIdResponseAsync_Should_Throw_ArgumentException_If_PodcastId_Not_Greater_Than_Zero() { PodcastClientMock podcastClientMock = PodcastClientMock.Create(); await Assert.ThrowsAsync <ArgumentException>(() => podcastClientMock.GetPodcastByIdResponseAsync(-1)); }