Пример #1
0
        public void TestFilterHasViewed()
        {
            var employer = CreateEmployer(0);
            var jobAd1   = _jobAdsCommand.PostTestJobAd(employer);
            var jobAd2   = _jobAdsCommand.PostTestJobAd(employer);
            var member   = _membersCommand.CreateTestMember(1);

            // Member1 has been viewed.

            _jobAdViewsCommand.ViewJobAd(member.Id, jobAd1.Id);

            // Filter.

            TestFilter(member, CreateHasViewedQuery, new[] { jobAd1.Id, jobAd2.Id }, new[] { jobAd1.Id }, new[] { jobAd2.Id });
        }
Пример #2
0
        private void TestResults <T>(bool createReport, Func <Guid, IOrganisation> createOrganisation, Action <Administrator, IOrganisation, EmployerReport> test)
            where T : EmployerReport
        {
            var administrator = _administratorAccountsCommand.CreateTestAdministrator(1);
            var organisation  = createOrganisation(administrator.Id);
            var employer      = _employerAccountsCommand.CreateTestEmployer(1, organisation);
            var member        = _memberAccountsCommand.CreateTestMember(1);

            if (typeof(T) == typeof(ResumeSearchActivityReport))
            {
                _employerMemberViewsCommand.ViewMember(_app, employer, member);
            }
            else if (typeof(T) == typeof(JobBoardActivityReport))
            {
                var jobAd = _jobAdsCommand.PostTestJobAd(employer);
                _jobAdViewsCommand.ViewJobAd(Guid.NewGuid(), jobAd.Id);
                var application = new InternalApplication {
                    ApplicantId = Guid.NewGuid()
                };
                _jobAdApplicationSubmissionsCommand.CreateApplication(jobAd, application);
                _jobAdApplicationSubmissionsCommand.SubmitApplication(jobAd, application);
                _jobAdsCommand.CloseJobAd(jobAd);
            }

            var report = _employerReportsCommand.CreateReportTemplate <T>(organisation.Id);

            if (createReport)
            {
                _employerReportsCommand.CreateReport(report);
            }
            test(administrator, organisation, report);
        }
Пример #3
0
        public void Test1MemberViewed()
        {
            var employer = CreateEmployer();
            var jobAd    = PostJobAd(employer);

            // View.

            _jobAdViewsCommand.ViewJobAd(Guid.NewGuid(), jobAd.Id);

            // Get the job.

            Get(GetJobUrl(jobAd.Id));
            AssertViewed(1);
        }
Пример #4
0
        public void TestFilterHasViewed()
        {
            var jobAd1   = CreateJobAd(1);
            var jobAd2   = CreateJobAd(2);
            var memberId = Guid.NewGuid();

            // JobAd1 has been viewed.

            _jobAdViewsCommand.ViewJobAd(memberId, jobAd1.Id);

            // Filter.

            TestFilter(employer, CreateHasViewedCriteria, new[] { jobAd1.Id, jobAd2.Id }, new[] { jobAd1.Id }, new[] { jobAd2.Id });
        }
Пример #5
0
        public ActionResult Viewed(Guid jobAdId)
        {
            try
            {
                var user = CurrentUser;
                _jobAdViewsCommand.ViewJobAd(user == null ? (Guid?)null : user.Id, jobAdId);

                Prompts.AddView();
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new JobAdsErrorHandler());
            }

            return(Json(new JsonResponseModel()));
        }
Пример #6
0
        public void TestFilterHasViewed()
        {
            var employer = CreateEmployer(1);

            var jobAd1 = CreateJobAd(employer);
            var jobAd2 = CreateJobAd(employer);

            var member = CreateMember(0);

            // JobAd1 has been viewed.

            _jobAdViewsCommand.ViewJobAd(member.Id, jobAd1.Id);

            // Filter.

            TestFilter(member, CreateHasViewedCriteria, new[] { jobAd1.Id, jobAd2.Id }, new[] { jobAd1.Id }, new[] { jobAd2.Id });
        }
Пример #7
0
        public void TestHasViewed()
        {
            var member = CreateMember(0);
            var jobAd  = CreateJobAd();

            _jobAdViewsCommand.ViewJobAd(member.Id, jobAd.Id);

            LogIn(member);
            Search(Keywords);
            var node = GetResult(jobAd.Id);

            Assert.IsNotNull(node.SelectSingleNode(".//div[@class='icon viewed active']"));
            Assert.IsNull(node.SelectSingleNode(".//div[@class='icon viewed ']"));

            var model = ApiSearch(Keywords);

            Assert.AreEqual(1, model.JobAds.Count);
            Assert.IsTrue(model.JobAds[0].HasViewed);
        }
Пример #8
0
        public void TestViewings()
        {
            var viewerId1 = Guid.NewGuid();
            var viewerId2 = Guid.NewGuid();
            var jobAdId   = Guid.NewGuid();

            _jobAdViewsCommand.ViewJobAd(viewerId1, jobAdId);

            Assert.AreEqual(1, _jobAdViewsQuery.GetViewedCount(jobAdId));
            Assert.AreEqual(1, _jobAdViewsQuery.GetDistinctViewedCount(jobAdId));

            Assert.IsTrue(_jobAdViewsQuery.HasViewedJobAd(viewerId1, jobAdId));
            Assert.IsFalse(_jobAdViewsQuery.HasViewedJobAd(viewerId2, jobAdId));

            Assert.IsTrue(new[] { jobAdId }.CollectionEqual(_jobAdViewsQuery.GetViewedJobAdIds(viewerId1, new[] { jobAdId })));
            Assert.IsTrue(new[] { jobAdId }.CollectionEqual(_jobAdViewsQuery.GetViewedJobAdIds(viewerId1)));

            Assert.AreEqual(0, _jobAdViewsQuery.GetViewedJobAdIds(viewerId2, new[] { jobAdId }).Count);
            Assert.AreEqual(0, _jobAdViewsQuery.GetViewedJobAdIds(viewerId2).Count);
        }