private void ApplyForJob(Candidate candidate)
        {
            var employer = CreateEmployer();
            var jobAd    = _jobAdsCommand.PostTestJobAd(employer);

            TestObjectMother.ApplyForTestJobAd(jobAd, candidate, "This is a cover letter");
        }
Example #2
0
        public void TestAddJobAdToBlocklist()
        {
            var employer = CreateEmployer(0);
            var jobAd    = _jobAdsCommand.PostTestJobAd(employer);
            var member   = CreateMember(0);

            CreateLists(member);
            AssertCounts(member, 0, 0, 0, 0);

            // Add member to lists.

            _memberJobAdListsCommand.AddJobAdToFlagList(member, _flagList, jobAd.Id);
            _memberJobAdListsCommand.AddJobAdToFolder(member, _folder1, jobAd.Id);
            _memberJobAdListsCommand.AddJobAdToFolder(member, _folder2, jobAd.Id);

            AssertCounts(member, 0, 1, 1, 1);

            // Add to permanent blocklist.

            _memberJobAdListsCommand.AddJobAdToBlockList(member, _blockList, jobAd.Id);

            // Check lists are updated.

            AssertCounts(member, 1, 0, 0, 0);
        }
Example #3
0
        private JobAd CreateJobAd(IEmployer employer, bool hasLogoFeature)
        {
            var jobAd = _jobAdsCommand.PostTestJobAd(employer);

            AddLogo(jobAd, hasLogoFeature);
            return(jobAd);
        }
        public void TestJobAds()
        {
            var employer = CreateEmployer(0);

            var credit = _creditsQuery.GetCredit <ContactCredit>();

            _allocationsCommand.CreateAllocation(new Allocation {
                CreditId = credit.Id, InitialQuantity = null, OwnerId = employer.Id
            });
            var jobAdCredit = _creditsQuery.GetCredit <JobAdCredit>();

            _allocationsCommand.CreateAllocation(new Allocation {
                CreditId = jobAdCredit.Id, InitialQuantity = null, OwnerId = employer.Id
            });

            // Set up members which the employer can and cannot see and add them to the shortlist folder.

            var folder    = _candidateFoldersQuery.GetShortlistFolder(employer);
            var blockList = _candidateBlockListsQuery.GetPermanentBlockList(employer);

            // Folder.
            var member = _memberAccountsCommand.CreateTestMember(0);

            for (var index = 1; index < 50; ++index)
            {
                member = _memberAccountsCommand.CreateTestMember(index);
                var candidate = _candidatesQuery.GetCandidate(member.Id);
                _candidateResumesCommand.AddTestResume(candidate);
                _employerMemberViewsCommand.AccessMember(_app, employer, _employerMemberViewsQuery.GetProfessionalView(employer, member), MemberAccessReason.Unlock);
                if (index <= 45)
                {
                    _candidateListsCommand.AddCandidateToFolder(employer, folder, member.Id);
                }
                else
                {
                    _candidateListsCommand.AddCandidateToBlockList(employer, blockList, member.Id);
                }
            }

            // Add some jobs.

            var jobAd = _jobAdsCommand.PostTestJobAd(employer, JobAdStatus.Open);

            for (var i = 0; i < 6; i++)
            {
                _jobAdsCommand.PostTestJobAd(employer, JobAdStatus.Open);
                _jobAdsCommand.PostTestJobAd(employer, JobAdStatus.Closed);
            }

            var application = new InternalApplication {
                ApplicantId = member.Id, PositionId = jobAd.Id
            };

            _jobAdApplicationSubmissionsCommand.CreateApplication(jobAd, application);
            _jobAdApplicationSubmissionsCommand.SubmitApplication(jobAd, application);
        }
Example #5
0
        public void TestResultsNoLocation()
        {
            // Create a member and search.

            var member = CreateMember();
            var search = CreateSearch(member.Id, JobTitle, null, null, null, null, JobTypes.None);

            // No location.

            var employer = CreateEmployer();
            var jobAd    = _jobAdsCommand.PostTestJobAd(employer);

            jobAd.Description.Location = null;
            _jobAdsCommand.UpdateJobAd(jobAd);
            search.Results = new JobAdSearchResults {
                TotalMatches = 1, JobAdIds = new List <Guid> {
                    jobAd.Id
                }
            };

            // Send.

            var templateEmail = SendIt(member, search, true);

            // Check.

            var bodyTemplate = File.ReadAllText(FileSystem.GetAbsolutePath(@"Apps\Agents\Test\Communications\Emails\MemberAlerts\TestResultsNoLocation.htm", RuntimeEnvironment.GetSourceFolder()));

            AssertMail(templateEmail, member, search, bodyTemplate);
        }
Example #6
0
        public void TestNote()
        {
            var employer = CreateEmployer(0);
            var jobAd    = _jobAdsCommand.PostTestJobAd(employer);

            var noteCreator = _membersCommand.CreateTestMember(1);

            // Add one.

            var note = CreateNote(1, noteCreator, jobAd.Id);

            AssertNotes(noteCreator, jobAd.Id, new[] { note }, new MemberJobAdNote[0]);
            AssertHasNotes(noteCreator, jobAd.Id);
        }
Example #7
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);
        }
Example #8
0
        private JobAd CreateJobAd(IEmployer employer, DateTime lastUpdatedTime, DateTime?modifiedTime)
        {
            var jobAd = _jobAdsCommand.PostTestJobAd(employer);

            jobAd.CreatedTime     = lastUpdatedTime;
            jobAd.LastUpdatedTime = lastUpdatedTime;
            _jobAdsRepository.UpdateJobAd(jobAd);

            // Delete what is already there.

            using (var dc = new MaintenanceDataContext(_connectionFactory.CreateConnection()))
            {
                var entity = (from i in dc.JobAdIndexingEntities where i.jobAdId == jobAd.Id select i).SingleOrDefault();
                if (entity != null)
                {
                    dc.JobAdIndexingEntities.DeleteOnSubmit(entity);
                    dc.SubmitChanges();
                }
            }

            if (modifiedTime != null)
            {
                using (var dc = new MaintenanceDataContext(_connectionFactory.CreateConnection()))
                {
                    dc.JobAdIndexingEntities.InsertOnSubmit(new JobAdIndexingEntity {
                        jobAdId = jobAd.Id, modifiedTime = modifiedTime.Value
                    });
                    dc.SubmitChanges();
                }
            }

            return(jobAd);
        }
Example #9
0
        public void TestSnippetContent()
        {
            var employer = _employersCommand.CreateTestEmployer(_organisationsCommand.CreateTestOrganisation(0));

            var poster = new JobPoster {
                Id = employer.Id, SendSuggestedCandidates = false, ShowSuggestedCandidates = true
            };

            _jobPostersCommand.CreateJobPoster(poster);

            var jobAd = _jobAdsCommand.PostTestJobAd(employer, JobAdStatus.Open);

            jobAd.Description.Content += jobAd.Description.Content;
            jobAd.Description.Content += jobAd.Description.Content;

            var criteria = new JobAdSearchCriteria();

            criteria.SetKeywords("mutley");
            var highlighter = _highlighterFactory.Create(JobAdHighlighterKind.Full, criteria, new HighlighterConfiguration {
                FragmentSize = 40
            });

            var highlightedText = highlighter.SummarizeContent(jobAd);

            Assert.AreEqual("<span class=\"highlighted-word\">Mutley</span>, you snickering, floppy eared ...  never around.<span class=\"highlighted-word\">Mutley</span>, you snickering, floppy ...  is needed, you're never around.<span class=\"highlighted-word\">Mutley</span>, you snickering", highlightedText);
        }
Example #10
0
        protected virtual JobAd CreateJobAd(IEmployer employer)
        {
            var jobAd = _jobAdsCommand.PostTestJobAd(employer);

            jobAd.ContactDetails.CompanyName = ContactCompanyName;
            jobAd.Description.CompanyName    = EmployerCompanyName;
            _jobAdsCommand.UpdateJobAd(jobAd);
            return(jobAd);
        }
Example #11
0
        public void TestGetOpenJobAds()
        {
            var employer = CreateEmployer(1);

            _jobAdsCommand.PostTestJobAd(employer);
            _jobAdsCommand.PostTestJobAd(employer);
            Assert.AreEqual(2, _jobAdReportsQuery.GetOpenJobAds());

            // Create another.

            var closedJobAd = _jobAdsCommand.PostTestJobAd(employer);

            Assert.AreEqual(3, _jobAdReportsQuery.GetOpenJobAds());

            // Close it.

            _jobAdsCommand.CloseJobAd(closedJobAd);
            Assert.AreEqual(2, _jobAdReportsQuery.GetOpenJobAds());
        }
        private void Apply(IEmployer employer, IUser member)
        {
            var jobAd = _jobAdsCommand.PostTestJobAd(employer);

            // Apply for the job.

            LogIn(member);
            Post(new ReadOnlyApplicationUrl(true, "~/members/jobs/api/" + jobAd.Id + "/applywithprofile"));
            LogOut();
        }
Example #13
0
        public void TestUpdateJobAds()
        {
            new UpdateFeaturedTask(_featuredCommand, _jobAdsQuery, _jobAdReportsQuery, _accountReportsQuery, _employerMemberAccessReportsQuery, _memberSearchReportsQuery).ExecuteTask(new[] { "7", "100" });
            AssertJobAds(new FeaturedItem[0], _featuredQuery.GetFeaturedJobAds());

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

            new UpdateFeaturedTask(_featuredCommand, _jobAdsQuery, _jobAdReportsQuery, _accountReportsQuery, _employerMemberAccessReportsQuery, _memberSearchReportsQuery).ExecuteTask(new[] { "7", "100" });

            AssertJobAds(new[] { CreateFeaturedJobAd(jobAd) }, _featuredQuery.GetFeaturedJobAds());
        }
Example #14
0
        private void TestAddJobAdsToFolder(Func <IMember, JobAdFolder> getFolder, Func <JobAdFolder, JobAd[], JsonListCountModel> addJobAds)
        {
            const int count    = 3;
            var       jobAds   = new JobAd[count];
            var       employer = _employerAccountsCommand.CreateTestEmployer(0, _organisationsCommand.CreateTestVerifiedOrganisation(0));

            for (var index = 0; index < count; ++index)
            {
                jobAds[index] = _jobAdsCommand.PostTestJobAd(employer);
            }

            // Create member and folder.

            var member = _memberAccountsCommand.CreateTestMember(0);
            var folder = getFolder(member);

            // Log in and add JobAds.

            LogIn(member);
            var model = addJobAds(folder, jobAds);

            // Assert.

            AssertModel(3, model);
            AssertJobAds(member, folder.Id, jobAds);

            // Add again.

            model = addJobAds(folder, jobAds);

            // Assert.

            AssertModel(3, model);
            AssertJobAds(member, folder.Id, jobAds);
        }
Example #15
0
        private JobAd[] CreateJobAds(int count)
        {
            var employer = _employerAccountsCommand.CreateTestEmployer(0, _organisationsCommand.CreateTestOrganisation(0));

            var jobAds = new JobAd[count];

            for (var index = 0; index < count; ++index)
            {
                jobAds[index] = _jobAdsCommand.PostTestJobAd(employer);
            }

            return(jobAds);
        }
Example #16
0
        public void Test()
        {
            var employer = _employerAccountsCommand.CreateTestEmployer("employer", _organisationsCommand.CreateTestOrganisation(0));

            var jobAd = _jobAdsCommand.PostTestJobAd(employer);
            var view  = _memberJobAdViewsQuery.GetMemberJobAdView(null, jobAd.Id);

            var viewJobAdUrl  = new ReadOnlyApplicationUrl("~/", new ReadOnlyQueryString("jobAdId", jobAd.Id.ToString()));
            var applyJobAdUrl = new ReadOnlyApplicationUrl("~/", new ReadOnlyQueryString("jobAdId", jobAd.Id.ToString()));
            var credits       = _employerCreditsQuery.GetEffectiveActiveAllocation <ApplicantCredit>(employer);

            CheckInstances(view.Map(viewJobAdUrl.AbsoluteUri, applyJobAdUrl.AbsoluteUri, credits.RemainingQuantity > 0), employer, jobAd, viewJobAdUrl.AbsoluteUri.ToLower(), applyJobAdUrl.AbsoluteUri.ToLower());
        }
Example #17
0
        private bool CreateJobBoardActivity(IEmployer employer)
        {
            var jobAd = _jobAdsCommand.PostTestJobAd(employer);

            // Tweak the JobAdStatus directly.

            var statusChanges = _jobAdsRepository.GetStatusChanges(jobAd.Id);

            Assert.AreEqual(1, statusChanges.Count);
            statusChanges[0].Time = DateTime.Now.AddMonths(-2);
            _jobAdsRepository.UpdateStatusChange(statusChanges[0]);

            return(true);
        }
Example #18
0
        public void TestJobAdFeedCreation()
        {
            const string testLoginId = "employer";

            var employer = _employerAccountsCommand.CreateTestEmployer(testLoginId, _organisationsCommand.CreateTestOrganisation(0));
            var jobAd    = _jobAdsCommand.PostTestJobAd(employer);
            var view     = _memberJobAdViewsQuery.GetMemberJobAdView(null, jobAd.Id);

            var viewJobAdUrl  = string.Format("{0}jobs/Job.aspx?jobAdId={1}", new ReadOnlyApplicationUrl("~/").AbsoluteUri, jobAd.Id);
            var applyJobAdUrl = string.Format("{0}ui/unregistered/common/JobApplicationSignInForm.aspx?jobAdId={1}", new ReadOnlyApplicationUrl("~/").AbsoluteUri, jobAd.Id);
            var credits       = _employerCreditsQuery.GetEffectiveActiveAllocation <ApplicantCredit>(employer);

            AssertJobAdFeed(view.Map(viewJobAdUrl, applyJobAdUrl, credits.RemainingQuantity > 0), jobAd, employer, viewJobAdUrl.ToLower(), applyJobAdUrl.ToLower());
        }
Example #19
0
        public void TestJobPromotionCode()
        {
            var employer = _employerAccountsCommand.CreateTestEmployer(0, _organisationsCommand.CreateTestOrganisation(0));
            var jobAd    = _jobAdsCommand.PostTestJobAd(employer);

            // Get the job url.

            Get(new ReadOnlyApplicationUrl("~/jobs/" + jobAd.Id));
            var url = new Url(Browser.CurrentUrl);

            // Attach promo code to job url.

            const string pcode = "chucknorris";

            url.QueryString["pcode"] = pcode;

            Browser.Cookies = new CookieContainer();
            Get(url);

            // Join.

            Get(GetJoinUrl());
            SubmitJoin();
            var instanceId = GetInstanceId();

            var member = CreateMember(FirstName, LastName, EmailAddress);

            UpdateMember(member, MobilePhoneNumber, PhoneNumberType.Mobile, Location);
            var candidate = CreateCandidate();

            UpdateCandidate(candidate, SalaryLowerBound, SalaryRate);
            SubmitPersonalDetails(instanceId, member, candidate, Password);

            // Promotion code should have been saved.

            AssertAffiliationReferral(pcode, _loginCredentialsQuery.GetUserId(member.GetBestEmailAddress().Address).Value);
        }
Example #20
0
        public void TestEmployerHasCredits()
        {
            var organisation = CreateOrganisation(0, true);
            var employer1    = CreateEmployer(1, organisation);
            var employer2    = CreateEmployer(2, organisation);

            // Allocate to parent organisation and to second employer.

            Allocate(organisation.Id, 2, null);
            Allocate(employer2.Id, 2, null);

            var jobAd1 = _jobAdsCommand.PostTestJobAd(employer1);
            var jobAd2 = _jobAdsCommand.PostTestJobAd(employer2);

            Assert.AreEqual(JobAdStatus.Open, _jobAdsQuery.GetJobAd <JobAdEntry>(jobAd1.Id).Status);
            Assert.AreEqual(JobAdStatus.Open, _jobAdsQuery.GetJobAd <JobAdEntry>(jobAd2.Id).Status);

            // Submit.

            var member = _memberAccountsCommand.CreateTestMember(0);

            Submit(member.Id, jobAd1);

            AssertAllocations(organisation.Id, 1, null);
            AssertAllocations(employer2.Id, 2, null);
            Assert.AreEqual(JobAdStatus.Open, _jobAdsQuery.GetJobAd <JobAdEntry>(jobAd1.Id).Status);
            Assert.AreEqual(JobAdStatus.Open, _jobAdsQuery.GetJobAd <JobAdEntry>(jobAd2.Id).Status);

            // Submit again.

            member = _memberAccountsCommand.CreateTestMember(1);
            Submit(member.Id, jobAd1);

            AssertAllocations(organisation.Id, 0);
            AssertAllocations(employer2.Id, 2, null);
            Assert.AreEqual(JobAdStatus.Closed, _jobAdsQuery.GetJobAd <JobAdEntry>(jobAd1.Id).Status);

            // This job ad remains open because employer2 has their own credits.

            Assert.AreEqual(JobAdStatus.Open, _jobAdsQuery.GetJobAd <JobAdEntry>(jobAd2.Id).Status);
        }
Example #21
0
        public void TestGetExpiredJobAds()
        {
            var employer = CreateEmployer();

            // Create an open job ad.

            var activeJobAd = _jobAdsCommand.PostTestJobAd(employer);

            // Create an open job ad that has expired.

            var expiredJobAd = employer.CreateTestJobAd();

            _jobAdsCommand.PostJobAd(expiredJobAd);
            expiredJobAd.ExpiryTime = DateTime.Now.AddDays(-1);
            _jobAdsCommand.UpdateJobAd(expiredJobAd);

            Assert.AreEqual(JobAdStatus.Open, activeJobAd.Status);
            Assert.AreEqual(JobAdStatus.Open, expiredJobAd.Status);

            // Get the expired job ads.

            var ids = _jobAdsQuery.GetExpiredJobAdIds();

            Assert.AreEqual(1, ids.Count);
            Assert.AreEqual(expiredJobAd.Id, ids[0]);

            // Close them.

            foreach (var id in ids)
            {
                var closeJobAd = _jobAdsQuery.GetJobAd <JobAdEntry>(id);
                _jobAdsCommand.CloseJobAd(closeJobAd);
            }

            // Check the status.

            var jobAd = _jobAdsCommand.GetJobAd <JobAdEntry>(activeJobAd.Id);

            Assert.AreEqual(JobAdStatus.Open, jobAd.Status);
            jobAd = _jobAdsCommand.GetJobAd <JobAdEntry>(expiredJobAd.Id);
            Assert.AreEqual(JobAdStatus.Closed, jobAd.Status);

            // Do it again.

            Assert.AreEqual(0, _jobAdsQuery.GetExpiredJobAdIds().Count);
        }
Example #22
0
        public void TestDefaultAspx()
        {
            var employer = _employerAccountsCommand.CreateTestEmployer(0, _organisationsCommand.CreateTestOrganisation(0));
            var jobAd    = _jobAdsCommand.PostTestJobAd(employer);

            // Get the job page.

            var url = new ReadOnlyApplicationUrl("~/jobs");

            AssertNoRedirect(url);

            var redirectUrl = url;

            url = new ReadOnlyApplicationUrl("~/jobs/default.aspx");
            AssertRedirect(url, redirectUrl, redirectUrl);

            // Individual job.

            url = new ReadOnlyApplicationUrl(true, "~/jobs/" + jobAd.GetJobRelativePath());
            AssertNoRedirect(url);

            redirectUrl = url;
            url         = new ReadOnlyApplicationUrl(true, "~/jobs/" + jobAd.GetJobRelativePath() + "/default.aspx");
            AssertRedirect(url, redirectUrl, redirectUrl);

            // Browse jobs.

            url = new ReadOnlyApplicationUrl(false, "~/jobs/sydney-jobs/primary-industry-jobs");
            AssertNoRedirect(url);

            redirectUrl = url;
            url         = new ReadOnlyApplicationUrl(false, "~/jobs/sydney-jobs/primary-industry-jobs/default.aspx");
            AssertRedirect(url, redirectUrl, redirectUrl);

            // Home page.

            url = new ReadOnlyApplicationUrl("~/");
            AssertNoRedirect(url);

            redirectUrl = url;
            url         = new ReadOnlyApplicationUrl("~/default.aspx");
            AssertRedirect(url, redirectUrl, redirectUrl);
        }
Example #23
0
        public void TestEmployerSecurePage()
        {
            // Will be redirected to login.

            var url         = new ReadOnlyApplicationUrl(true, "~/employers/settings");
            var redirectUrl = new ReadOnlyApplicationUrl(true, "~/employers/login", new ReadOnlyQueryString("returnUrl", url.PathAndQuery));

            Test(url, HttpStatusCode.Found, redirectUrl, false);

            // redirect to the secure version
            url         = new ReadOnlyApplicationUrl(false, "~/ui/registered/employers/JobAdCandidates.aspx");
            redirectUrl = new ReadOnlyApplicationUrl(true, "~/ui/registered/employers/JobAdCandidates.aspx");
            Test(url, HttpStatusCode.Found, redirectUrl, true);

            //Redirect from secure to new manageCandidates page
            url         = new ReadOnlyApplicationUrl(true, "~/ui/registered/employers/JobAdCandidates.aspx");
            redirectUrl = new ReadOnlyApplicationUrl(true, "~/employers/candidates/manage");
            Test(url, HttpStatusCode.MovedPermanently, redirectUrl, true);

            // Log in and do it again.

            var employer = CreateEmployer();

            LogIn(employer);

            // Should be redirected to https.

            url = new ReadOnlyApplicationUrl(true, "~/employers/jobads/jobad");
            Test(url, HttpStatusCode.OK, null, true);

            var jobAd = _jobAdsCommand.PostTestJobAd(employer);
            var path  = "~/employers/candidates/manage/" + jobAd.Id;

            url         = new ReadOnlyApplicationUrl(false, path);
            redirectUrl = new ReadOnlyApplicationUrl(true, path);
            Test(url, HttpStatusCode.Found, redirectUrl, true);

            url = new ReadOnlyApplicationUrl(true, path);
            Test(url, HttpStatusCode.OK, null, true);
        }
Example #24
0
        public void TestFilterFlagListId()
        {
            var employer = CreateEmployer(0);
            var jobAd1   = _jobAdsCommand.PostTestJobAd(employer);
            var jobAd2   = _jobAdsCommand.PostTestJobAd(employer);
            var member   = _membersCommand.CreateTestMember(1);

            // jobAd1 in folder.

            var flagList = _jobAdFlagListsQuery.GetFlagList(member);

            _memberJobAdListsCommand.AddJobAdToFlagList(member, flagList, jobAd1.Id);

            // Filter.

            TestFlaggedFilter(new[] { jobAd1.Id }, member, new[] { jobAd1.Id, jobAd2.Id });
        }
Example #25
0
        private JobAd CreateTestEmployerAndJobAd()
        {
            Employer jobPoster = _employerAccountsCommand.CreateTestEmployer("employer", _organisationsCommand.CreateTestOrganisation(0));

            return(_jobAdsCommand.PostTestJobAd(jobPoster));
        }
Example #26
0
 private JobAd CreateJobAd(IEmployer employer)
 {
     return(_jobAdsCommand.PostTestJobAd(employer));
 }
Example #27
0
        public void TestOverrideParseWithApplication()
        {
            var member    = CreateMember(0);
            var candidate = _candidatesQuery.GetCandidate(member.Id);

            _candidateResumesCommand.AddTestResume(candidate);

            // Confirm resume.

            candidate = _candidatesQuery.GetCandidate(member.Id);
            Assert.IsNotNull(candidate.ResumeId);
            var resume1 = _resumesQuery.GetResume(candidate.ResumeId.Value);

            Assert.IsNotNull(resume1);

            Assert.AreEqual(0, _candidateResumeFilesQuery.GetResumeFiles(member.Id).Count);
            Assert.IsNull(_candidateResumeFilesQuery.GetResumeFile(resume1.Id));

            // Apply for job ad with that resume.

            var employer    = CreateEmployer();
            var jobAd       = _jobAdsCommand.PostTestJobAd(employer);
            var application = new InternalApplication {
                ApplicantId = member.Id, ResumeId = resume1.Id
            };

            _jobAdApplicationSubmissionsCommand.CreateApplication(jobAd, application);
            _jobAdApplicationSubmissionsCommand.SubmitApplication(jobAd, application);

            LogIn(member);

            // Upload and parse.

            var fileReferenceId1 = Upload(TestResume.Complete, "Resume.doc");

            AssertJsonSuccess(Parse(fileReferenceId1));

            // Confirm resume.

            candidate = _candidatesQuery.GetCandidate(member.Id);
            Assert.IsNotNull(candidate.ResumeId);
            var resume2 = _resumesQuery.GetResume(candidate.ResumeId.Value);

            Assert.IsNotNull(resume2);
            Assert.AreEqual(resume1.Id, resume2.Id);

            // Show that the resume is associated with the uploaded file.

            var references = _candidateResumeFilesQuery.GetResumeFiles(member.Id);

            Assert.AreEqual(1, references.Count);
            var resumeFileReference1 = references[0];
            var resumeFileReference2 = _candidateResumeFilesQuery.GetResumeFile(member.Id, fileReferenceId1);
            var resumeFileReference3 = _candidateResumeFilesQuery.GetResumeFile(resume2.Id);

            Assert.AreEqual(fileReferenceId1, resumeFileReference1.FileReferenceId);
            Assert.AreEqual(fileReferenceId1, resumeFileReference2.FileReferenceId);
            Assert.AreEqual(fileReferenceId1, resumeFileReference3.FileReferenceId);
            Assert.AreEqual(resumeFileReference1.Id, resumeFileReference2.Id);
            Assert.AreEqual(resumeFileReference1.Id, resumeFileReference3.Id);

            // Upload and parse another resume.

            var fileReferenceId2 = Upload(TestResume.NoPhoneNumber, "Resume.doc");

            AssertJsonSuccess(Parse(fileReferenceId2));

            // Confirm resume.

            candidate = _candidatesQuery.GetCandidate(member.Id);
            Assert.IsNotNull(candidate.ResumeId);
            var resume3 = _resumesQuery.GetResume(candidate.ResumeId.Value);

            Assert.IsNotNull(resume3);
            Assert.AreEqual(resume1.Id, resume2.Id);
            Assert.AreEqual(resume1.Id, resume3.Id);

            // Show that the resume is associated with the new uploaded file.

            references = _candidateResumeFilesQuery.GetResumeFiles(member.Id);
            Assert.AreEqual(2, references.Count);
            resumeFileReference1 = (from r in references where r.FileReferenceId == fileReferenceId1 select r).Single();
            resumeFileReference2 = (from r in references where r.FileReferenceId == fileReferenceId2 select r).Single();

            resumeFileReference3 = _candidateResumeFilesQuery.GetResumeFile(member.Id, fileReferenceId1);
            var resumeFileReference4 = _candidateResumeFilesQuery.GetResumeFile(member.Id, fileReferenceId2);

            var resumeFileReference5 = _candidateResumeFilesQuery.GetResumeFile(resume3.Id);

            Assert.AreEqual(fileReferenceId1, resumeFileReference1.FileReferenceId);
            Assert.AreEqual(fileReferenceId2, resumeFileReference2.FileReferenceId);
            Assert.AreEqual(fileReferenceId1, resumeFileReference3.FileReferenceId);
            Assert.AreEqual(fileReferenceId2, resumeFileReference4.FileReferenceId);
            Assert.AreEqual(fileReferenceId2, resumeFileReference5.FileReferenceId);

            Assert.AreEqual(resumeFileReference1.Id, resumeFileReference3.Id);
            Assert.AreEqual(resumeFileReference2.Id, resumeFileReference4.Id);
            Assert.AreEqual(resumeFileReference2.Id, resumeFileReference5.Id);
        }