Exemple #1
0
        public void TestJobApplicationEmailLinks()
        {
            // Create a member.

            var member    = _memberAccountsCommand.CreateTestMember(0);
            var candidate = _candidatesCommand.GetCandidate(member.Id);

            // Create an employer.

            var employer       = _employerAccountsCommand.CreateTestEmployer(0, _organisationsCommand.CreateTestOrganisation(0));
            var jobAd          = employer.CreateTestJobAd();
            var jobApplication = new InternalApplication {
                PositionId = jobAd.Id, ApplicantId = candidate.Id, CoverLetterText = CoverLetter
            };

            // Send the email.

            var communication = new JobApplicationEmail(member, jobApplication, jobAd, null, null);

            _emailsCommand.TrySend(communication);

            // Check the email.

            var email = _emailServer.AssertEmailSent();
            var links = email.GetHtmlView().GetLinks();

            Assert.AreEqual(3, links.Count);

            var definition = typeof(JobApplicationEmail).Name;

            AssertLink(definition, EmployerHomeUrl, links[0]);
            AssertLink(definition, GetCandidateUrl(member), links[1]);
            AssertLink(definition, _contactUsUrl, links[2]);

            // Check the tracking pixel.

            var link = email.GetHtmlView().GetImageLinks().Last();

            AssertTrackingLink(link);
        }
        public void TestMultipleSecondaryEmail()
        {
            // Create a member.

            var member    = CreateMember();
            var candidate = _candidatesCommand.GetCandidate(member.Id);

            // Create an employer.

            var employer = CreateEmployer();
            var jobAd    = employer.CreateTestJobAd();

            jobAd.ContactDetails.SecondaryEmailAddresses = SecondaryEmail + "," + TertiaryEmail;
            var jobApplication = new InternalApplication {
                PositionId = jobAd.Id, ApplicantId = candidate.Id, CoverLetterText = CoverLetter
            };

            // Send the email.

            var communication = new JobApplicationEmail(member, jobApplication, jobAd, null, null);

            _emailsCommand.TrySend(communication);

            // Check.

            var email = _emailServer.AssertEmailSent();

            email.AssertAddresses(member, Return, new EmailRecipient(jobAd.ContactDetails.EmailAddress), new[] { new EmailRecipient(SecondaryEmail), new EmailRecipient(TertiaryEmail) }, null);
            email.AssertSubject(GetSubject(jobAd));
            email.AssertHtmlViewChecks();
            email.AssertHtmlView(GetBody(communication, new UnregisteredEmployer {
                EmailAddress = new EmailAddress {
                    Address = jobAd.ContactDetails.EmailAddress
                }
            }, GetContent(communication, member, jobAd, CoverLetter)));
            email.AssertNoAttachments();
            AssertCompatibleAddresses(email);
        }