Ejemplo n.º 1
0
        public void TestJobAds()
        {
            // Refresh whatever may be in the cache.

            var administrator = _administratorAccountsCommand.CreateTestAdministrator(0);

            _featuredCommand.UpdateFeaturedStatistics(GetFeaturedStatistics());
            ClearCache(administrator);

            // No job ads.

            Get(HomeUrl);
            Assert.AreEqual(0, GetJobAds());

            // Post a job ad yesterday.

            var employer = _employerAccountsCommand.CreateTestEmployer(0, _organisationsCommand.CreateTestOrganisation(0));
            var jobAd    = employer.CreateTestJobAd();

            jobAd.CreatedTime = DateTime.Now.AddDays(-1);
            _jobAdsCommand.CreateJobAd(jobAd);

            // Should not show up until cache is refreshed.

            Get(HomeUrl);
            Assert.AreEqual(0, GetJobAds());

            _featuredCommand.UpdateFeaturedStatistics(GetFeaturedStatistics());
            ClearCache(administrator);
            Get(HomeUrl);
            Assert.AreEqual(1, GetJobAds());

            // Post another job ad.

            jobAd             = employer.CreateTestJobAd();
            jobAd.CreatedTime = DateTime.Now.AddDays(-4);
            _jobAdsCommand.CreateJobAd(jobAd);

            Get(HomeUrl);
            Assert.AreEqual(1, GetJobAds());

            _featuredCommand.UpdateFeaturedStatistics(GetFeaturedStatistics());
            ClearCache(administrator);
            Get(HomeUrl);
            Assert.AreEqual(2, GetJobAds());

            // Post another outside the 7 day timeframe.

            jobAd             = employer.CreateTestJobAd();
            jobAd.CreatedTime = DateTime.Now.AddDays(-14);
            _jobAdsCommand.CreateJobAd(jobAd);

            Get(HomeUrl);
            Assert.AreEqual(2, GetJobAds());

            _featuredCommand.UpdateFeaturedStatistics(GetFeaturedStatistics());
            ClearCache(administrator);
            Get(HomeUrl);
            Assert.AreEqual(2, GetJobAds());
        }
Ejemplo n.º 2
0
        public void TestUpdateStatistics()
        {
            var statistics = new FeaturedStatistics {
                CreatedJobAds = 1, Members = 2, MemberSearches = 3, MemberAccesses = 4
            };

            _featuredCommand.UpdateFeaturedStatistics(statistics);
            AssertStatistics(1, 2, 3, 4, _featuredQuery.GetFeaturedStatistics());
        }
Ejemplo n.º 3
0
        public void TestUpdateStatistics()
        {
            var statistics = new FeaturedStatistics();

            _featuredCommand.UpdateFeaturedStatistics(statistics);
            AssertStatistics(0, 0, 0, 0, _featuredQuery.GetFeaturedStatistics());

            _memberAccountsCommand.CreateTestMember(0);
            _memberAccountsCommand.CreateTestMember(1);
            _memberAccountsCommand.CreateTestMember(2);

            new UpdateFeaturedTask(_featuredCommand, _jobAdsQuery, _jobAdReportsQuery, _accountReportsQuery, _employerMemberAccessReportsQuery, _memberSearchReportsQuery).ExecuteTask(new[] { "7", "100" });
            AssertStatistics(0, 3, 0, 0, _featuredQuery.GetFeaturedStatistics());
        }
Ejemplo n.º 4
0
        private void UpdateFeaturedStatistics(int days)
        {
            var today     = DateTime.Today;
            var dateRange = new DateRange(today.AddDays(-1 * days), today);

            var statistics = new FeaturedStatistics
            {
                CreatedJobAds  = _jobAdReportsQuery.GetCreatedJobAds(dateRange),
                Members        = _accountReportsQuery.GetUsers(UserType.Member, DateTime.Now),
                MemberSearches = _memberSearchReportsQuery.GetAllMemberSearches(dateRange),
                MemberAccesses = _employerMemberAccessReportsQuery.GetMemberAccesses(dateRange)
            };

            _featuredCommand.UpdateFeaturedStatistics(statistics);
        }