Пример #1
0
        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));
        }
Пример #2
0
        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());
        }
Пример #3
0
        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);
            }
        }
Пример #4
0
        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;
            }
        }
Пример #5
0
        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));
            }
        }
Пример #6
0
        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;
            }
        }