public async Task IndexFiltersOutFeaturedCampaignFromListOfUpcomingCampaings()
        {
            var mockMediator = new Mock<IMediator>();
            var featuredCampaign = new CampaignSummaryViewModel
            {
                Id = 1,
                Title = "Featured campaign",
                Description = "This is a featured campaign"
            };

            mockMediator.Setup(s => s.SendAsync(It.IsAny<FeaturedCampaignQuery>()))
                        .ReturnsAsync(featuredCampaign);

            mockMediator.Setup(s => s.SendAsync(It.IsAny<ActiveOrUpcomingCampaignsQuery>()))
                        .ReturnsAsync(new List<ActiveOrUpcomingCampaign>
                        {
                            new ActiveOrUpcomingCampaign { Id = featuredCampaign.Id, Name = featuredCampaign.Title, Description = featuredCampaign.Description },
                            new ActiveOrUpcomingCampaign { Id = 2, Name = "Not a featured campaign", Description = "This is not a featured campaign" }
                        });

            var sut = new HomeController(mockMediator.Object);
            var result = ((ViewResult)await sut.Index()).Model as IndexViewModel;

            result.ShouldNotBeNull();
            result.ActiveOrUpcomingCampaigns.ShouldNotContain(c => c.Id == featuredCampaign.Id);
        }
        public void PrivacyPolicy_ReturnsCorrectView()
        {
            var controller = new HomeController(Mock.Of<IMediator>());

            var result = (ViewResult)controller.PrivacyPolicy();

            Assert.NotNull(result);
            Assert.Equal("PrivacyPolicy", result.ViewName);
        }
        public async Task IndexReturnsCorrectViewResult()
        {
            var mockMediator = new Mock<IMediator>();

            var sut = new HomeController(mockMediator.Object);
            var result = (ViewResult)await sut.Index();

            Assert.NotNull(result);       
        }
        public async Task IndexSendsFeaturedCampaignQuery()
        {
            var mockMediator = new Mock<IMediator>();

            var sut = new HomeController(mockMediator.Object);
            var result = (ViewResult)await sut.Index();

            mockMediator.Verify(x => x.SendAsync(It.IsAny<FeaturedCampaignQueryAsync>()), Times.Once());
        }
        public async Task IndexSendsActiveOrUpcomingCampaignsQueryAsync()
        {
            var mockMediator = new Mock<IMediator>();

            var sut = new HomeController(mockMediator.Object);
            await sut.Index();

            mockMediator.Verify(x => x.SendAsync(It.IsAny<ActiveOrUpcomingCampaignsQueryAsync>()), Times.Once());
        }
        public void IndexSendsCampaignQuery()
        {
            var mockMediator = new Mock<IMediator>();
            mockMediator.Setup(m => m.Send(It.IsAny<CampaignQuery>())).Returns(new List<CampaignViewModel>());

            var sut = new HomeController(mockMediator.Object);
            sut.Index();

            mockMediator.Verify(x => x.Send(It.IsAny<CampaignQuery>()), Times.Once());
        }
 public void AesopReturnsAView()
 {
     var sut = new HomeController(null);
     var result = sut.Aesop();
     Assert.IsType<ViewResult>(result);
 }
 public void AccessDeniedReturnsTheCorrectView()
 {
     var controller = new HomeController(null);
     var result = (ViewResult)controller.AccessDenied();
     Assert.Equal("~/Views/Shared/AccessDenied.cshtml", result.ViewName);
 }
 public void ErrorReturnsTheCorrectView()
 {
     var controller = new HomeController(null);
     var result = (ViewResult)controller.Error();
     Assert.Equal("~/Views/Shared/Error.cshtml", result.ViewName);
 }