public void HasFeaturedCampaignShouldReturnTrueIfViewMModelHasAFeaturedCampaign() { var sut = new IndexViewModel { FeaturedCampaign = new CampaignSummaryViewModel { Id = 1, Title = "Something" } }; Assert.True(sut.HasFeaturedCampaign); }
public async Task<IActionResult> Index() { var model = new IndexViewModel { FeaturedCampaign = await mediator.SendAsync(new FeaturedCampaignQuery()), ActiveOrUpcomingCampaigns = await mediator.SendAsync(new ActiveOrUpcomingCampaignsQuery()) }; return View(model); }
public async Task<IActionResult> Index() { var model = new IndexViewModel { FeaturedCampaign = await mediator.SendAsync(new FeaturedCampaignQuery()), ActiveOrUpcomingCampaigns = await mediator.SendAsync(new ActiveOrUpcomingCampaignsQuery()) }; if (model.HasFeaturedCampaign) { var indexOfFeaturedCampaign = model.ActiveOrUpcomingCampaigns.FindIndex(s => s.Id == model.FeaturedCampaign.Id); model.ActiveOrUpcomingCampaigns.RemoveAt(indexOfFeaturedCampaign); } return View(model); }
public void HasFeaturedCampaignShouldReturnFalseIfViewModelHasNoFeaturedCampaign() { var sut = new IndexViewModel(); Assert.False(sut.HasFeaturedCampaign); }