public async Task GetP2PBySlug_Should_Throw_ArgumentNullException_If_Slug_Is_Null() { PodcastServiceMock mock = PodcastServiceMock.Create(); string slug = null; await Assert.ThrowsAsync <ArgumentNullException>(() => mock.GetP2PBySlug(slug)); mock.PodcastRepository.Verify(repository => repository.GetP2PBySlug(It.IsAny <string>()), Times.Never); }
public async Task GetP2PBySlug_Should_Return_Call_IPodcastRepository_GetPodcastBySlug() { PodcastServiceMock mock = PodcastServiceMock.Create(); var slug = "birinci-bolum-dotnet-core"; mock.PodcastRepository .Setup(repository => repository.GetP2PBySlug(It.Is <string>(s => s == slug))) .ReturnsAsync(() => new P2P()); mock.PodcastModelMapper .Setup(mapper => mapper.Map(It.IsAny <P2P>())) .ReturnsAsync(() => new P2PModel()); IPodcastModel p2pModel = await mock.GetP2PBySlug(slug); mock.PodcastRepository.Verify(repository => repository.GetP2PBySlug(It.IsAny <string>()), Times.Once); Assert.NotNull(p2pModel); }
public async Task GetP2PBySlug_Should_Return_Call_IPodcastModelMapper_Map() { PodcastServiceMock mock = PodcastServiceMock.Create(); var slug = "yalin-kod-bilgem-cakir"; var p2p = new P2P { Id = 1, Title = "Yalın Kod - Bilgem Çakır" }; mock.PodcastRepository .Setup(repository => repository.GetP2PBySlug(It.Is <string>(s => s == slug))) .ReturnsAsync(() => p2p); mock.PodcastModelMapper .Setup(mapper => mapper.Map(It.Is <P2P>(p => p.Id == p2p.Id && p.Title == p2p.Title))) .ReturnsAsync(() => new P2PModel()); IPodcastModel p2pModel = await mock.GetP2PBySlug(slug); mock.PodcastModelMapper.Verify(repository => repository.Map(It.IsAny <P2P>()), Times.Once); Assert.NotNull(p2pModel); }