Esempio n. 1
0
        public async void InvalidUrl_ShouldReturnInvalidUrlResult()
        {
            var command = new SubmitForReview.Command {
                RssFeedUrl = "https://"
            };

            var handler = new SubmitForReview.CommandHandler(A.Fake <ApplicationDbContext>(), A.Fake <RssParser>(), A.Fake <PodcastEmailService>(), A.Fake <ILogger>());
            var result  = await handler.Handle(command);

            Assert.Equal(SuccessResult.InvalidUrl, result.SuccessResult);
        }
Esempio n. 2
0
        public async void AllThingsGit_ShouldStorePodcastInDatabaseForReview()
        {
            var command = new SubmitForReview.Command {
                RssFeedUrl = "https://www.allthingsgit.com/rss.xml"
            };

            var handler = new SubmitForReview.CommandHandler(Context, A.Fake <RssParser>(), A.Fake <PodcastEmailService>(), A.Fake <ILogger>());
            var result  = await handler.Handle(command);

            var podcast = Context.Podcasts.SingleOrDefault(p => p.Title == "All Things Git");

            Assert.Equal(SuccessResult.Success, result.SuccessResult);
            Assert.NotNull(podcast);
            Assert.Equal("All Things Git", podcast.Title);
            Assert.Null(podcast.IsApproved);
        }
Esempio n. 3
0
        public async void AllThingsGit_ShouldReturnAlreadyInDatabaseResult()
        {
            var podcast = new DataLayer.Models.Podcast
            {
                Title      = "All Things Git",
                FeedUrl    = "https://www.allthingsgit.com/rss.xml",
                IsApproved = true
            };

            Context.Podcasts.Add(podcast);
            await Context.SaveChangesAsync();

            var command = new SubmitForReview.Command {
                RssFeedUrl = "https://www.allthingsgit.com/rss.xml"
            };

            var handler = new SubmitForReview.CommandHandler(Context, A.Fake <RssParser>(), A.Fake <PodcastEmailService>(), A.Fake <ILogger>());
            var result  = await handler.Handle(command);

            Assert.Equal(SuccessResult.AlreadyExists, result.SuccessResult);
        }