Пример #1
0
        public ActionResult Index(string sortBy = "Brand.BrandName", bool ascending = true, int page = 1)
        {
            page--; // user's page numbers start at 1.

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

            return(View(vm));
        }
Пример #2
0
        public void GetAllAds_Normal_ReturnsCorrectNumberOfAds()
        {
            var target = new AdRepository(_mockDataService);

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

            Assert.AreEqual(12, result.DisplayAds.Count());
            Assert.AreEqual(0, result.Page);
            Assert.AreEqual(1, result.TotalPageCount);
        }
Пример #3
0
        public void GetAllAds_Pages()
        {
            var target = new AdRepository(_mockDataService);

            var result = target.GetAllAds(_startDate, _endDate, "AdId", true, 6, 1);

            Assert.AreEqual(6, result.DisplayAds.Count());
            Assert.AreEqual(2, result.TotalPageCount);
            Assert.AreEqual(1, result.Page);
        }
Пример #4
0
        public void GetAllAds_SortsNestedDescending()
        {
            var target = new AdRepository(_mockDataService);

            var result = target.GetAllAds(_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 GetAllAds_SortsAscending()
        {
            var target = new AdRepository(_mockDataService);

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

            int lastAdId = Int32.MinValue;

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