public ActionResult TopAds() { const int NUM_ADS_TO_RETURN = 5; var vm = _repo.GetTopAds(START_DATE, END_DATE, NUM_ADS_TO_RETURN); return(View(vm)); }
public void GetTopAds_Normal_ReturnsCorrectLength() { const int maxLength = 5; var target = new AdRepository(_mockDataService); var result = target.GetTopAds(_startDate, _endDate, maxLength); Assert.AreEqual(maxLength, result.DisplayAds.Count()); }
public void GetTopAds_Normal_AreFiveLargest() { const int maxLength = 5; var target = new AdRepository(_mockDataService); var result = target.GetTopAds(_startDate, _endDate, maxLength); foreach (Ad ad in result.DisplayAds) { // This number was determined by looking at our sample set. This should probably be determined programmatically. Assert.IsTrue(ad.NumPages >= 1); } }
public void GetTopAds_Normal_SortedDescendingByPageCoverageAmount() { var target = new AdRepository(_mockDataService); var result = target.GetTopAds(_startDate, _endDate, 5); decimal lastPageCoverageAmount = decimal.MaxValue; foreach (Ad ad in result.DisplayAds) { Assert.IsTrue(ad.NumPages <= lastPageCoverageAmount); lastPageCoverageAmount = ad.NumPages; } }
public void GetTopAds_Normal_DistinctByBrand() { const int maxLength = 5; var target = new AdRepository(_mockDataService); var result = target.GetTopAds(_startDate, _endDate, maxLength); HashSet <int> brands = new HashSet <int>(); foreach (Ad ad in result.DisplayAds) { Assert.IsTrue(brands.Add(ad.Brand.BrandId)); } }
public void GetTopAds_Normal_SecondarySortBrandName() { var target = new AdRepository(_mockDataService); var result = target.GetTopAds(_startDate, _endDate, 5); decimal lastPageCoverageAmount = decimal.MaxValue; string lastBrandName = null; foreach (Ad ad in result.DisplayAds) { if (ad.NumPages == lastPageCoverageAmount) { Assert.IsTrue(string.Compare(ad.Brand.BrandName, lastBrandName) > 0); } lastPageCoverageAmount = ad.NumPages; lastBrandName = ad.Brand.BrandName; } }