예제 #1
0
        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);
        }
예제 #2
0
        public void PrivacyPolicy_ReturnsCorrectView()
        {
            var controller = new HomeController(Mock.Of<IMediator>());

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

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

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

            Assert.NotNull(result);       
        }
예제 #4
0
        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());
        }
예제 #5
0
        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());
        }
예제 #6
0
        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());
        }
예제 #7
0
 public void AesopReturnsAView()
 {
     var sut = new HomeController(null);
     var result = sut.Aesop();
     Assert.IsType<ViewResult>(result);
 }
예제 #8
0
 public void AccessDeniedReturnsTheCorrectView()
 {
     var controller = new HomeController(null);
     var result = (ViewResult)controller.AccessDenied();
     Assert.Equal("~/Views/Shared/AccessDenied.cshtml", result.ViewName);
 }
예제 #9
0
 public void ErrorReturnsTheCorrectView()
 {
     var controller = new HomeController(null);
     var result = (ViewResult)controller.Error();
     Assert.Equal("~/Views/Shared/Error.cshtml", result.ViewName);
 }