示例#1
0
 public void SetUp()
 {
     _userProfileService   = new Mock <IProviderUserProvider>();
     _logServiceMock       = new Mock <ILogService>();
     _providerUserMediator = new Mock <IProviderUserMediator>();
     _contactMessageServerViewModelValidator = new Mock <ContactMessageServerViewModelValidator>();
     _homeMediator = new HomeMediator(_logServiceMock.Object,
                                      _userProfileService.Object, _contactMessageServerViewModelValidator.Object, _providerUserMediator.Object);
 }
示例#2
0
        public void GetContactMessageViewModelWithoutCandidateId()
        {
            var homeMediator = new HomeMediator(_candidateServiceProviderMock.Object, _homeProviderMock.Object, _contactMessageServerViewModelValidatorMock.Object);

            var response = homeMediator.GetContactMessageViewModel(null);

            response.AssertCode(HomeMediatorCodes.GetContactMessageViewModel.Successful);
            response.ViewModel.Name.Should().BeNull();
            response.ViewModel.Email.Should().BeNull();
        }
示例#3
0
        public void SetUp()
        {
            _candidateServiceProviderMock = new Mock <ICandidateServiceProvider>();
            _logServiceMock = new Mock <ILogService>();
            _contactMessageServerViewModelValidator = new Mock <ContactMessageServerViewModelValidator>();
            _feedbackServerViewModelValidatorMock   = new Mock <FeedbackServerViewModelValidator>();

            _homeMediator = new HomeMediator(
                _logServiceMock.Object,
                _candidateServiceProviderMock.Object,
                _contactMessageServerViewModelValidator.Object,
                _feedbackServerViewModelValidatorMock.Object);
        }
示例#4
0
        public void GetContactMessageViewModelWithoError()
        {
            var homeMediator = new HomeMediator(_candidateServiceProviderMock.Object, _homeProviderMock.Object, _contactMessageServerViewModelValidatorMock.Object);
            var candidateId  = Guid.NewGuid();

            _candidateServiceProviderMock.Setup(csp => csp.GetCandidate(candidateId)).Throws <ArgumentException>();

            var response = homeMediator.GetContactMessageViewModel(candidateId);

            response.AssertCode(HomeMediatorCodes.GetContactMessageViewModel.Successful);
            response.ViewModel.Name.Should().BeNull();
            response.ViewModel.Email.Should().BeNull();
        }
示例#5
0
        public void SendContactMessageWithValidationErrors()
        {
            var homeMediator = new HomeMediator(_candidateServiceProviderMock.Object, _homeProviderMock.Object, _contactMessageServerViewModelValidatorMock.Object);
            var viewModel    = new ContactMessageViewModel
            {
                Details         = AString,
                Email           = AnEmail,
                Enquiry         = AString,
                Name            = AString,
                SelectedEnquiry = AString
            };

            _contactMessageServerViewModelValidatorMock.Setup(v => v.Validate(It.IsAny <ContactMessageViewModel>()))
            .Returns(new ValidationResult(new [] { new ValidationFailure("Name", "Error") }));

            _homeProviderMock.Setup(hp => hp.SendContactMessage(null, viewModel)).Returns(false);
            var response = homeMediator.SendContactMessage(null, viewModel);

            response.AssertValidationResult(HomeMediatorCodes.SendContactMessage.ValidationError, true);
        }
示例#6
0
        public void SendContactMessage()
        {
            var homeMediator = new HomeMediator(_candidateServiceProviderMock.Object, _homeProviderMock.Object, _contactMessageServerViewModelValidatorMock.Object);
            var viewModel    = new ContactMessageViewModel
            {
                Details         = AString,
                Email           = AnEmail,
                Enquiry         = AString,
                Name            = AString,
                SelectedEnquiry = AString
            };

            _contactMessageServerViewModelValidatorMock.Setup(v => v.Validate(It.IsAny <ContactMessageViewModel>()))
            .Returns(new ValidationResult());

            _homeProviderMock.Setup(hp => hp.SendContactMessage(null, viewModel)).Returns(true);
            var response = homeMediator.SendContactMessage(null, viewModel);

            response.AssertMessage(HomeMediatorCodes.SendContactMessage.SuccessfullySent,
                                   ApplicationPageMessages.SendContactMessageSucceeded, UserMessageLevel.Success, true);
        }
示例#7
0
        public void GetContactMessageViewModelWithCandidateId()
        {
            var          homeMediator       = new HomeMediator(_candidateServiceProviderMock.Object, _homeProviderMock.Object, _contactMessageServerViewModelValidatorMock.Object);
            var          candidateId        = Guid.NewGuid();
            const string candidateFirstName = "John";
            const string candidateLastName  = "Doe";
            const string emailAddress       = "*****@*****.**";

            _candidateServiceProviderMock.Setup(csp => csp.GetCandidate(candidateId)).Returns(new Candidate
            {
                RegistrationDetails = new RegistrationDetails
                {
                    FirstName    = candidateFirstName,
                    LastName     = candidateLastName,
                    EmailAddress = emailAddress
                }
            });

            var response = homeMediator.GetContactMessageViewModel(candidateId);

            response.AssertCode(HomeMediatorCodes.GetContactMessageViewModel.Successful);
            response.ViewModel.Name.Should().Be(string.Format("{0} {1}", candidateFirstName, candidateLastName));
            response.ViewModel.Email.Should().Be(emailAddress);
        }