public void ShouldThrowGivenFeedUrlIsInvalid(string feedUrl, string exceptionMessage) { // When Action action = () => Podcast.Create(feedUrl); // Then action.ShouldThrow <ArgumentException>().WithMessage(exceptionMessage); }
public async Task Given2PodcastsExist() { var podcastFileRepository = new PodcastFileRepository(); Podcast podcast1 = Podcast.Create("http://www.dr.dk/mu/Feed/harddisken?format=podcast&limit=500"); Podcast podcast2 = Podcast.Create("http://www.dr.dk/mu/Feed/troldspejlet?format=podcast&limit=500"); await podcastFileRepository.Add(podcast1); await podcastFileRepository.Add(podcast2); }
public void ShouldGetFeed() { // Given Podcast sut = Podcast.Create("http://www.dr.dk/mu/Feed/harddisken?format=podcast&limit=500"); // When SyndicationFeed feed = sut.GetFeed(); // Then feed.Should().NotBeNull(); feed.Title.Text.Should().Be("Harddisken"); feed.Description.Text.Should().Be("Harddisken er radioens teknologimagasin på P1. Vi forklarer de konkrete teknologiske udviklinger og deres konsekvenser for kulturen, samfundet og hverdagen."); feed.ImageUrl.AbsoluteUri.Should().Be("http://www.dr.dk/mu/Asset?Id=5576dda66187a4061caf6d0e.jpg"); feed.Items.Should().HaveCount(151); }
public void ShouldCreatePodcast() { // Given string feedUrl = "http://www.dr.dk/mu/Feed/harddisken?format=podcast&limit=500"; // When Podcast sut = Podcast.Create(feedUrl); // Then sut.Should().NotBeNull(); sut.Id.Should().NotBeEmpty(); sut.Title.Should().Be("Harddisken"); sut.Description.Should().Be("Harddisken er radioens teknologimagasin på P1. Vi forklarer de konkrete teknologiske udviklinger og deres konsekvenser for kulturen, samfundet og hverdagen."); sut.FeedUrl.Should().Be(feedUrl); sut.ImageUrl.Should().Be("http://www.dr.dk/mu/Asset?Id=5576dda66187a4061caf6d0e.jpg"); }
public async Task ShouldAddPodcast() { using (var context = new Context <PodcastFileRepository>()) { // Given Podcast podcast = Podcast.Create("http://www.dr.dk/mu/Feed/harddisken?format=podcast&limit=500"); var sut = context.CreateSut(); // When await sut.Add(podcast); // Then var podcastFileRepository = new PodcastFileRepository(); Podcast podcastFromRepository = podcastFileRepository.Get(podcast.Id); podcastFromRepository.ShouldBeEquivalentTo(podcast); podcastFromRepository.Should().NotBeSameAs(podcast); } }
public async Task ShouldDeletePodcast() { using (var context = new Context <PodcastFileRepository>()) { // Given Podcast podcast = Podcast.Create("http://www.dr.dk/mu/Feed/harddisken?format=podcast&limit=500"); await context.GivenPodcastsExist(podcast); var sut = context.CreateSut(); // When await sut.Delete(podcast.Id); // Then var podcastFileRepository = new PodcastFileRepository(); Action action = () => podcastFileRepository.Get(podcast.Id); action.ShouldThrow <InvalidOperationException>(); } }
public Context() { _moqAutoMocker = new MoqAutoMocker <T>(); Podcast podcast = Podcast.Create("http://www.dr.dk/mu/Feed/harddisken?format=podcast&limit=500"); var podcasts = new ReadOnlyCollection <Podcast>(new List <Podcast> { podcast, podcast }); var podcastsModels = new ReadOnlyCollection <PodcastModel>(new List <PodcastModel> { new PodcastModel(), new PodcastModel() }); var feed = new FeedModel(); Mock.Get(_moqAutoMocker.Get <IPodcastRepository>()) .Setup(repository => repository.Add(It.IsAny <Podcast>())) .Returns(Task.FromResult(true)) .Callback((Podcast p) => AddedPodcast = p); Mock.Get(_moqAutoMocker.Get <IPodcastRepository>()) .Setup(repository => repository.Delete(It.IsAny <Guid>())) .Returns(Task.FromResult(true)) .Callback((Guid podcastId) => DeletedPodcastId = podcastId); Mock.Get(_moqAutoMocker.Get <IPodcastRepository>()) .Setup(repository => repository.GetAll()) .Returns(podcasts); Mock.Get(_moqAutoMocker.Get <IPodcastRepository>()) .Setup(repository => repository.Get(It.IsAny <Guid>())) .Returns(podcast); Mock.Get(_moqAutoMocker.Get <IMapper>()) .Setup(mapper => mapper.Map <IReadOnlyCollection <PodcastModel> >(It.IsAny <IReadOnlyCollection <Podcast> >())) .Returns(podcastsModels); Mock.Get(_moqAutoMocker.Get <IMapper>()) .Setup(mapper => mapper.Map <FeedModel>(It.IsAny <SyndicationFeed>())) .Returns(feed); }
public async Task AddPodcast(string feedUrl) { Podcast podcast = Podcast.Create(feedUrl); await _podcastRepository.Add(podcast); }