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 GetSpecials_Should_Return_Call_IPodcastModelMapper_Map()
        {
            PodcastServiceMock mock = PodcastServiceMock.Create();

            var specials = new List <Special>
            {
                new Special {
                    Id = 1, Title = "Microsoft Ozel Yayını"
                },
                new Special {
                    Id = 2, Title = "Facebook Skandalı"
                }
            };

            mock.PodcastRepository
            .Setup(repository => repository.GetSpecials())
            .ReturnsAsync(() => specials);

            mock.PodcastModelMapper
            .Setup(mapper => mapper.Map(It.Is <IEnumerable <Special> >(p => p.Equals(specials))))
            .ReturnsAsync(() => new List <SpecialModel>());

            IEnumerable <IPodcastModel> specialModels = await mock.GetSpecials();

            mock.PodcastModelMapper.Verify(repository => repository.Map(It.IsAny <IEnumerable <Special> >()), Times.Once);
            Assert.NotNull(specialModels);
        }
        public async Task GetP2Ps_Should_Return_Call_IPodcastModelMapper_Map()
        {
            PodcastServiceMock mock = PodcastServiceMock.Create();

            var p2Ps = new List <P2P>
            {
                new P2P {
                    Id = 1, Title = "Bilgem Çakır"
                },
                new P2P {
                    Id = 2, Title = "Ebru Meriç Akgül"
                }
            };

            mock.PodcastRepository
            .Setup(repository => repository.GetP2Ps())
            .ReturnsAsync(() => p2Ps);

            mock.PodcastModelMapper
            .Setup(mapper => mapper.Map(It.Is <IEnumerable <P2P> >(p => p.Equals(p2Ps))))
            .ReturnsAsync(() => new List <P2PModel>());

            IEnumerable <IPodcastModel> p2pModels = await mock.GetP2Ps();

            mock.PodcastModelMapper.Verify(repository => repository.Map(It.IsAny <IEnumerable <P2P> >()), Times.Once);
            Assert.NotNull(p2pModels);
        }
        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 GetSpecials_Should_Return_Call_IPodcastRepository_GetSpecials()
        {
            PodcastServiceMock mock = PodcastServiceMock.Create();

            mock.PodcastRepository
            .Setup(repository => repository.GetSpecials())
            .ReturnsAsync(() => new List <Special>());

            mock.PodcastModelMapper.Setup(mapper => mapper.Map(It.IsAny <IEnumerable <Special> >()))
            .ReturnsAsync(() => new List <SpecialModel>());

            IEnumerable <IPodcastModel> specials = await mock.GetSpecials();

            mock.PodcastRepository.Verify(repository => repository.GetSpecials(), Times.Once);
            Assert.NotNull(specials);
        }
        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);
        }
        public async Task GetSpecialBySlug_Should_Return_Call_IPodcastRepository_GetSpecialBySlug()
        {
            PodcastServiceMock mock = PodcastServiceMock.Create();

            var slug = "microsoft-ozel-yayini";

            mock.PodcastRepository
            .Setup(repository => repository.GetSpecialBySlug(It.Is <string>(s => s == slug)))
            .ReturnsAsync(() => new Special());

            mock.PodcastModelMapper
            .Setup(mapper => mapper.Map(It.IsAny <Special>()))
            .ReturnsAsync(() => new SpecialModel());

            IPodcastModel specialModel = await mock.GetSpecialBySlug(slug);

            mock.PodcastRepository.Verify(repository => repository.GetSpecialBySlug(It.IsAny <string>()), Times.Once);
            Assert.NotNull(specialModel);
        }
        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);
        }