public ActionResult TopBrands() { const int NUM_ADS_TO_RETURN = 5; var vm = _repo.GetTopBrands(START_DATE, END_DATE, NUM_ADS_TO_RETURN); return(View(vm)); }
public void GetTopBrands_Normal_ReturnsCorrectLength() { const int maxLength = 5; var target = new AdRepository(_mockDataService); var result = target.GetTopBrands(_startDate, _endDate, maxLength); Assert.AreEqual(maxLength, result.Count()); }
public void GetTopBrands_Normal_SortedDescendingByPageCoverageAmount() { var target = new AdRepository(_mockDataService); var result = target.GetTopBrands(_startDate, _endDate, 5); decimal lastPageCoverageAmount = decimal.MaxValue; foreach (TopBrandViewModel vm in result) { Assert.IsTrue(vm.TotalPageCoverage <= lastPageCoverageAmount); lastPageCoverageAmount = vm.TotalPageCoverage; } }
public void GetTopBrands_Normal_DistinctByBrand() { const int maxLength = 5; var target = new AdRepository(_mockDataService); var result = target.GetTopBrands(_startDate, _endDate, maxLength); HashSet <string> brands = new HashSet <string>(); foreach (TopBrandViewModel vm in result) { Assert.IsTrue(brands.Add(vm.BrandName)); } }
public void GetTopBrands_Normal_SecondarySortBrandName() { var target = new AdRepository(_mockDataService); var result = target.GetTopBrands(_startDate, _endDate, 5); decimal lastPageCoverageAmount = decimal.MaxValue; string lastBrandName = null; foreach (TopBrandViewModel vm in result) { if (vm.TotalPageCoverage == lastPageCoverageAmount) { Assert.IsTrue(string.Compare(vm.BrandName, lastBrandName) > 0); } lastPageCoverageAmount = vm.TotalPageCoverage; lastBrandName = vm.BrandName; } }