public async Task GetPodcastBySlug_Should_Throw_ArgumentNullException_If_Slug_Is_Null() { PodcastServiceMock mock = PodcastServiceMock.Create(); string slug = null; await Assert.ThrowsAsync <ArgumentNullException>(() => mock.GetPodcastBySlug(slug)); mock.PodcastRepository.Verify(repository => repository.GetPodcastBySlug(It.IsAny <string>()), Times.Never); }
public async Task GetPodcastBySlug_Should_Return_Call_IPodcastRepository_GetPodcastBySlug() { PodcastServiceMock mock = PodcastServiceMock.Create(); var slug = "birinci-bolum-dotnet-core"; mock.PodcastRepository .Setup(repository => repository.GetPodcastBySlug(It.Is <string>(s => s == slug))) .ReturnsAsync(() => new Podcast()); mock.PodcastModelMapper .Setup(mapper => mapper.Map(It.IsAny <Podcast>())) .ReturnsAsync(() => new PodcastModel()); IPodcastModel podcastModel = await mock.GetPodcastBySlug(slug); mock.PodcastRepository.Verify(repository => repository.GetPodcastBySlug(It.IsAny <string>()), Times.Once); Assert.NotNull(podcastModel); }