public async Task GetPodcasts_Should_Return_Call_IPodcastModelMapper_Map() { PodcastServiceMock mock = PodcastServiceMock.Create(); var podcasts = new List <Podcast> { new Podcast { Id = 1, Title = "Angular 5" }, new Podcast { Id = 2, Title = "Google IO" } }; mock.PodcastRepository .Setup(repository => repository.GetPodcasts()) .ReturnsAsync(() => podcasts); mock.PodcastModelMapper .Setup(mapper => mapper.Map(It.Is <IEnumerable <Podcast> >(p => p.Equals(podcasts)))) .ReturnsAsync(() => new List <PodcastModel>()); IEnumerable <IPodcastModel> podcastModels = await mock.GetPodcasts(); mock.PodcastModelMapper.Verify(repository => repository.Map(It.IsAny <IEnumerable <Podcast> >()), Times.Once); Assert.NotNull(podcastModels); }
public async Task GetPodcasts_Should_Return_Call_IPodcastRepository_GetPodcasts() { PodcastServiceMock mock = PodcastServiceMock.Create(); mock.PodcastRepository .Setup(repository => repository.GetPodcasts()) .ReturnsAsync(() => new List <Podcast>()); mock.PodcastModelMapper.Setup(mapper => mapper.Map(It.IsAny <IEnumerable <Podcast> >())) .ReturnsAsync(() => new List <PodcastModel>()); IEnumerable <IPodcastModel> podcastModels = await mock.GetPodcasts(); mock.PodcastRepository.Verify(repository => repository.GetPodcasts(), Times.Once); Assert.NotNull(podcastModels); }