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

            var employer = CreateEmployer();

            // Create a member.

            var member = CreateMember();

            // Create a view with no access. Should still be sent with no problems (it is not up to the email to decide whether it can be sent or not).

            var view          = new ProfessionalView(member, 0, ProfessionalContactDegree.NotContacted, true, false);
            var communication = new ContactCandidateEmail(view, null, employer, Subject, SimpleContent);

            _emailsCommand.TrySend(communication);

            // Check.

            var email = _emailServer.AssertEmailSent();

            email.AssertAddresses(employer, Return, member);
            email.AssertSubject(Subject);
            email.AssertViewChecks(MediaTypeNames.Text.Html);
            email.AssertView(MediaTypeNames.Text.Html, GetBody(communication, member, GetContent(member, employer, SimpleContent)));
            email.AssertView(MediaTypeNames.Text.Plain, GetPlainBody(communication, GetPlainContent(member, employer, SimpleContent)));
            email.AssertNoAttachments();
            AssertCompatibleAddresses(email);
        }
        public void TestHtmlContent()
        {
            // Create an employer.

            var employer = CreateEmployer();

            // Create a member.

            var member = CreateMember();

            // Send.

            var view          = new ProfessionalView(member, null, ProfessionalContactDegree.Contacted, true, false);
            var communication = new ContactCandidateEmail(view, null, employer, Subject, HtmlContent);

            _emailsCommand.TrySend(communication);

            // Check.

            var email = _emailServer.AssertEmailSent();

            email.AssertAddresses(employer, Return, member);
            email.AssertSubject(Subject);
            //email.AssertViewChecks(MediaTypeNames.Text.Html);
            email.AssertView(MediaTypeNames.Text.Html, GetBody(communication, member, GetContent(member, employer, HtmlContent)));
            email.AssertView(MediaTypeNames.Text.Plain, GetPlainBody(communication, GetPlainContent(member, employer, PlainHtmlContent)));
            email.AssertNoAttachments();
            AssertCompatibleAddresses(email);
        }
        public void TestFinsia()
        {
            _activeCommunity = ActiveCommunity.Finsia;

            // Create an employer.

            var employer = CreateEmployer();

            // Create a member.

            var community = TestCommunity.Finsia.CreateTestCommunity(_communitiesCommand, _verticalsCommand, _contentEngine);
            var member    = CreateMember(community);

            var view          = new ProfessionalView(member, null, ProfessionalContactDegree.Contacted, true, false);
            var communication = new ContactCandidateEmail(view, NewEmployerEmail, employer, Subject, SimpleContent);

            _emailsCommand.TrySend(communication);

            // Check.

            var email = _emailServer.AssertEmailSent();

            email.AssertAddresses(new EmailRecipient(NewEmployerEmail, employer.FullName), Return, member);
            email.AssertSubject(Subject);
            email.AssertViewChecks(MediaTypeNames.Text.Html);
            email.AssertView(MediaTypeNames.Text.Html, GetBody(communication, member, GetContent(member, employer, SimpleContent)));
            email.AssertNoAttachments();
            AssertCompatibleAddresses(email);
        }
        public void TestAutoPeople()
        {
            // Create an employer.

            var employer = CreateEmployer();

            // Create a member.

            var member = CreateMember();

            // Send in the context of Autopeople. Should still be a standard email because the member is not a member of Autopeople.

            Community community = TestCommunity.Autopeople.CreateTestCommunity(_communitiesCommand, _verticalsCommand, _contentEngine);

            ActivityContext.Current.Community.Set(community);

            var view          = new ProfessionalView(member, null, ProfessionalContactDegree.Contacted, true, false);
            var communication = new ContactCandidateEmail(view, NewEmployerEmail, employer, Subject, SimpleContent);

            _emailsCommand.TrySend(communication);

            // Check.

            var email = _emailServer.AssertEmailSent();

            email.AssertAddresses(new EmailRecipient(NewEmployerEmail, employer.FullName), Return, member);
            email.AssertSubject(Subject);
            email.AssertViewChecks(MediaTypeNames.Text.Html);
            email.AssertView(MediaTypeNames.Text.Html, GetBody(communication, member, GetContent(member, employer, SimpleContent)));
            email.AssertView(MediaTypeNames.Text.Plain, GetPlainBody(communication, GetPlainContent(member, employer, SimpleContent)));
            email.AssertNoAttachments();
            AssertCompatibleAddresses(email);
        }
示例#5
0
        private ContactCandidateEmail CreateContactCandidateEmail(string emailAddress)
        {
            var view  = new ProfessionalView(_memberUser, null, ProfessionalContactDegree.Contacted, true, false);
            var email = new ContactCandidateEmail(view, null, _employerUser, "This is the subject",
                                                  "Blah\nBlah blah\nBlah blah blah\nBlah blah blah blah\nBlah blah blah blah blah");

            _memberUser.EmailAddresses = new List <EmailAddress> {
                new EmailAddress {
                    Address = emailAddress
                }
            };
            email.To = _memberUser;
            return(email);
        }
示例#6
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);
            }
        }