Ejemplo n.º 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));
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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;
            }
        }