public void TestOverrideEmployerEmail()
        {
            // Create an employer.

            var employer = CreateEmployer();

            // Create a member.

            var member = CreateMember();

            // Send.

            var view          = _employerMemberViewsQuery.GetEmployerMemberView(employer, member);
            var templateEmail = new EmployerContactCandidateConfirmationEmail(NewEmployerEmail, employer, member.Id, view.GetDisplayText(true), Subject, Content);

            _emailsCommand.TrySend(templateEmail);

            // Check.

            var email = _emailServer.AssertEmailSent();

            email.AssertAddresses(Return, Return, new EmailRecipient(NewEmployerEmail, employer.FullName));
            email.AssertSubject(GetSubject());
            email.AssertHtmlViewChecks();
            email.AssertHtmlView(GetBody(templateEmail, employer, GetContent(templateEmail, member, employer, Content)));
            email.AssertNoAttachments();
            AssertCompatibleAddresses(email);
        }
Exemplo n.º 2
0
        void IMessagesHandler.OnMessageSent(Guid fromId, Guid toId, Guid?representativeId, MemberMessage message)
        {
            var member   = _membersQuery.GetMember(toId);
            var employer = _employersQuery.GetEmployer(fromId);

            IList <FileReference> fileReferences = null;

            if (message.AttachmentIds != null && message.AttachmentIds.Count > 0)
            {
                var messageAttachments = _employerMemberContactsQuery.GetMessageAttachments(employer, message.AttachmentIds);
                fileReferences = _filesQuery.GetFileReferences(from a in messageAttachments select a.FileReferenceId, new Range());
            }

            // Create the email to send to the member and send it.

            TemplateEmail email;

            if (representativeId == null)
            {
                email = new ContactCandidateEmail(member, message.From, employer, message.Subject, GetMemberBody(message.Body, member));
            }
            else
            {
                var representative = _membersQuery.GetMember(representativeId.Value);
                email = new RepresentativeContactCandidateEmail(representative, message.From, employer, member, message.Subject, GetMemberBody(message.Body, member));
            }

            AddAttachments(email, fileReferences);
            _emailsCommand.TrySend(email);

            // Create the email to the employer and send it.

            if (message.SendCopy)
            {
                // Need the view.

                var view = _employerMemberViewsQuery.GetProfessionalView(employer, member);
                var confirmationEmail = new EmployerContactCandidateConfirmationEmail(message.From, employer, member.Id, view.GetFullNameDisplayText(), message.Subject, GetEmployerBody(message.Body, view));
                AddAttachments(confirmationEmail, fileReferences);
                _emailsCommand.TrySend(confirmationEmail);
            }
        }
        public void TestAutopeople()
        {
            // Create an employer.

            var employer = CreateEmployer();

            // Create a member.

            var member = CreateMember();

            // Send in the context of Autopeople.

            var vertical = TestVertical.Autopeople.CreateTestVertical(_verticalsCommand, _contentEngine);

            try
            {
                ActivityContext.Current.Set(vertical);

                var view          = _employerMemberViewsQuery.GetEmployerMemberView(employer, member);
                var templateEmail = new EmployerContactCandidateConfirmationEmail(null, employer, member.Id, view.GetDisplayText(true), Subject, Content);
                _emailsCommand.TrySend(templateEmail);

                // Check.

                var email = _emailServer.AssertEmailSent();
                email.AssertAddresses(Return, Return, employer);
                email.AssertSubject(GetSubject());
                email.AssertHtmlViewChecks();
                email.AssertHtmlView(GetBody(templateEmail, member, employer, Content));
                email.AssertNoAttachments();
                AssertCompatibleAddresses(email);
            }
            finally
            {
                ActivityContext.Current.Reset();
            }
        }