コード例 #1
0
        public ActionResult CoverAds(string sortBy = "Brand.BrandName", bool ascending = true, int page = 1)
        {
            page--; // user's page numbers start at 1.

            var vm = _repo.GetCoverAds(START_DATE, END_DATE, sortBy, ascending, ITEMS_PER_PAGE, page);

            return(View("Index", vm));
        }
コード例 #2
0
        public void GetCoverAds_Normal_ReturnsCorrectNumberOfAds()
        {
            var target = new AdRepository(_mockDataService);

            var result = target.GetCoverAds(_startDate, _endDate, "AdId", true, 9000, 0);

            Assert.AreEqual(4, result.DisplayAds.Count());
            Assert.AreEqual(0, result.Page);
            Assert.AreEqual(1, result.TotalPageCount);
        }
コード例 #3
0
        public void GetCoverAds_Pages()
        {
            var target = new AdRepository(_mockDataService);

            var result = target.GetCoverAds(_startDate, _endDate, "AdId", true, 2, 1);

            Assert.AreEqual(2, result.DisplayAds.Count());
            Assert.AreEqual(2, result.TotalPageCount);
            Assert.AreEqual(1, result.Page);
        }
コード例 #4
0
        public void GetCoverAds_SortsNestedDescending()
        {
            var target = new AdRepository(_mockDataService);

            var result = target.GetCoverAds(_startDate, _endDate, "Brand.BrandId", false, 9000, 0);

            int lastBrandId = Int32.MaxValue;

            foreach (Ad ad in result.DisplayAds)
            {
                Assert.IsTrue(ad.Brand.BrandId <= lastBrandId);
                lastBrandId = ad.Brand.BrandId;
            }
        }
コード例 #5
0
        public void GetCoverAds_SortsAscending()
        {
            var target = new AdRepository(_mockDataService);

            var result = target.GetCoverAds(_startDate, _endDate, "AdId", true, 9000, 0);

            int lastAdId = Int32.MinValue;

            foreach (Ad ad in result.DisplayAds)
            {
                Assert.IsTrue(ad.AdId > lastAdId);
                lastAdId = ad.AdId;
            }
        }