public void ShouldMapSupport(bool isJavascript, bool requiresSupport, string support, string expectedSuport)
        {
            // Arrange.
            var candidateId      = Guid.NewGuid();
            var candidateService = new Mock <ICandidateService>();

            candidateService
            .Setup(cs => cs.GetCandidate(candidateId))
            .Returns(new CandidateBuilder(candidateId).Build);

            var viewModel = new SettingsViewModelBuilder()
                            .IsJavascript(isJavascript)
                            .Support(requiresSupport, support)
                            .Build();

            var provider = new AccountProviderBuilder().With(candidateService).Build();

            Candidate candidate;

            // Act.
            var result = provider.TrySaveSettings(candidateId, viewModel, out candidate);

            // Assert.
            result.Should().BeTrue();
            candidate.MonitoringInformation.Should().NotBeNull();
            candidate.ApplicationTemplate.AboutYou.Support.Should().Be(expectedSuport);
        }
        public void ShouldMapDisabilityStatus(int?disabilityStatus, DisabilityStatus?expectedDisabilityStatus)
        {
            // Arrange.
            var candidateId      = Guid.NewGuid();
            var candidateService = new Mock <ICandidateService>();

            candidateService
            .Setup(cs => cs.GetCandidate(candidateId))
            .Returns(new CandidateBuilder(candidateId).Build);

            var viewModel = new SettingsViewModelBuilder()
                            .PhoneNumber("0123456789")
                            .DisabilityStatus(disabilityStatus)
                            .Build();

            var provider = new AccountProviderBuilder().With(candidateService).Build();

            Candidate candidate;

            // Act.
            var result = provider.TrySaveSettings(candidateId, viewModel, out candidate);

            // Assert.
            result.Should().BeTrue();

            candidate.MonitoringInformation.Should().NotBeNull();
            candidate.MonitoringInformation.DisabilityStatus.Should().Be(expectedDisabilityStatus);
        }
        public void ShouldRequireMobileVerification(string newPhoneNumber, bool verifiedMobile, bool enableCommunicationViaText, bool mobileVerificationRequired)
        {
            // Arrange.
            const string mobileVerificationCode = "1234";

            var candidateId      = Guid.NewGuid();
            var candidateService = new Mock <ICandidateService>();

            const string currentPhoneNumber = "0123456789";

            candidateService.Setup(cs => cs.GetCandidate(candidateId)).Returns(new CandidateBuilder(candidateId).PhoneNumber(currentPhoneNumber).VerifiedMobile(verifiedMobile).Build);
            candidateService.Setup(cs => cs.SaveCandidate(It.IsAny <Candidate>())).Returns <Candidate>(c =>
            {
                if (c.MobileVerificationRequired())
                {
                    c.CommunicationPreferences.MobileVerificationCode = mobileVerificationCode;
                }
                return(c);
            });

            var viewModel = new SettingsViewModelBuilder().PhoneNumber(newPhoneNumber).EnableMarketingViaText(enableCommunicationViaText).Build();
            var provider  = new AccountProviderBuilder().With(candidateService).Build();

            Candidate candidate;

            // Act.
            var result = provider.TrySaveSettings(candidateId, viewModel, out candidate);

            // Assert.
            result.Should().BeTrue();

            candidate.RegistrationDetails.Should().NotBeNull();
            candidate.RegistrationDetails.PhoneNumber.Should().Be(newPhoneNumber);

            candidate.CommunicationPreferences.Should().NotBeNull();
            candidate.CommunicationPreferences.MarketingPreferences.Should().NotBeNull();
            candidate.CommunicationPreferences.MarketingPreferences.EnableText.Should().Be(enableCommunicationViaText);

            if (newPhoneNumber != currentPhoneNumber)
            {
                candidate.CommunicationPreferences.VerifiedMobile.Should().BeFalse();
            }
            else
            {
                candidate.CommunicationPreferences.VerifiedMobile.Should().Be(verifiedMobile);
            }

            if (mobileVerificationRequired)
            {
                candidate.MobileVerificationRequired().Should().BeTrue();
                candidate.CommunicationPreferences.MobileVerificationCode.Should().Be(mobileVerificationCode);
            }
            else
            {
                candidate.MobileVerificationRequired().Should().BeFalse();
                candidate.CommunicationPreferences.MobileVerificationCode.Should().BeNullOrEmpty();
            }
        }
Esempio n. 4
0
        public void MobileVerificationRequired(string newPhoneNumber, bool verifiedMobile, bool allowSmsComms, bool mobileVerificationRequired)
        {
            const string mobileVerificationCode = "1234";
            var          candidateId            = Guid.NewGuid();
            var          candidateService       = new Mock <ICandidateService>();
            const string phoneNumber            = "0123456789";

            candidateService.Setup(cs => cs.GetCandidate(candidateId)).Returns(new CandidateBuilder(candidateId).PhoneNumber(phoneNumber).VerifiedMobile(verifiedMobile).Build);
            candidateService.Setup(cs => cs.SaveCandidate(It.IsAny <Candidate>())).Returns <Candidate>(c =>
            {
                if (c.MobileVerificationRequired())
                {
                    c.CommunicationPreferences.MobileVerificationCode = mobileVerificationCode;
                }
                return(c);
            });
            var viewModel = new SettingsViewModelBuilder().PhoneNumber(newPhoneNumber).AllowSmsComms(allowSmsComms).Build();
            var provider  = new AccountProviderBuilder().With(candidateService).Build();

            Candidate candidate;
            var       result = provider.TrySaveSettings(candidateId, viewModel, out candidate);

            result.Should().BeTrue();
            candidate.RegistrationDetails.Should().NotBeNull();
            candidate.RegistrationDetails.PhoneNumber.Should().Be(newPhoneNumber);
            candidate.CommunicationPreferences.Should().NotBeNull();
            candidate.CommunicationPreferences.AllowMobile.Should().Be(allowSmsComms);

            if (newPhoneNumber != phoneNumber)
            {
                candidate.CommunicationPreferences.VerifiedMobile.Should().BeFalse();
            }
            else
            {
                candidate.CommunicationPreferences.VerifiedMobile.Should().Be(verifiedMobile);
            }

            if (mobileVerificationRequired)
            {
                candidate.MobileVerificationRequired().Should().BeTrue();
                candidate.CommunicationPreferences.MobileVerificationCode.Should().Be(mobileVerificationCode);
            }
            else
            {
                candidate.MobileVerificationRequired().Should().BeFalse();
                candidate.CommunicationPreferences.MobileVerificationCode.Should().BeNullOrEmpty();
            }
        }
Esempio n. 5
0
        public void MarketingMappingTest(bool allowEmailMarketing, bool allowSmsMarketing)
        {
            var candidateId      = Guid.NewGuid();
            var candidateService = new Mock <ICandidateService>();

            candidateService.Setup(cs => cs.GetCandidate(candidateId)).Returns(new CandidateBuilder(candidateId).Build);
            var viewModel = new SettingsViewModelBuilder().AllowEmailMarketing(allowEmailMarketing).AllowSmsMarketing(allowSmsMarketing).Build();
            var provider  = new AccountProviderBuilder().With(candidateService).Build();

            Candidate candidate;
            var       result = provider.TrySaveSettings(candidateId, viewModel, out candidate);

            result.Should().BeTrue();
            candidate.RegistrationDetails.Should().NotBeNull();
            candidate.CommunicationPreferences.Should().NotBeNull();
            candidate.CommunicationPreferences.AllowEmailMarketing.Should().Be(allowEmailMarketing);
            candidate.CommunicationPreferences.AllowMobileMarketing.Should().Be(allowSmsMarketing);
        }
Esempio n. 6
0
        public void CommunicationMappingTest(string phoneNumber, bool verifiedMobile, bool allowEmailComms, bool allowSmsComms)
        {
            var candidateId      = Guid.NewGuid();
            var candidateService = new Mock <ICandidateService>();

            candidateService.Setup(cs => cs.GetCandidate(candidateId)).Returns(new CandidateBuilder(candidateId).PhoneNumber(phoneNumber).VerifiedMobile(verifiedMobile).Build);
            var viewModel = new SettingsViewModelBuilder().PhoneNumber(phoneNumber).AllowEmailComms(allowEmailComms).AllowSmsComms(allowSmsComms).Build();
            var provider  = new AccountProviderBuilder().With(candidateService).Build();

            Candidate candidate;
            var       result = provider.TrySaveSettings(candidateId, viewModel, out candidate);

            result.Should().BeTrue();
            candidate.RegistrationDetails.Should().NotBeNull();
            candidate.RegistrationDetails.PhoneNumber.Should().Be(phoneNumber);
            candidate.CommunicationPreferences.Should().NotBeNull();
            candidate.CommunicationPreferences.AllowEmail.Should().Be(allowEmailComms);
            candidate.CommunicationPreferences.AllowMobile.Should().Be(allowSmsComms);
            candidate.CommunicationPreferences.VerifiedMobile.Should().Be(verifiedMobile);
        }
        public void ShouldMapCommunicationPreferences(string phoneNumber, CommunicationChannels communicationChannel, bool verifiedMobile)
        {
            // Arrange.
            var candidateId      = Guid.NewGuid();
            var candidateService = new Mock <ICandidateService>();

            candidateService.Setup(cs => cs.GetCandidate(candidateId)).Returns(new CandidateBuilder(candidateId).PhoneNumber(phoneNumber).VerifiedMobile(verifiedMobile).Build);

            var viewModel = new SettingsViewModelBuilder()
                            .PhoneNumber(phoneNumber)
                            .EnableApplicationStatusChangeAlertsViaEmail(communicationChannel == CommunicationChannels.Email)
                            .EnableApplicationStatusChangeAlertsViaText(communicationChannel == CommunicationChannels.Sms)
                            .EnableExpiringApplicationAlertsViaEmail(communicationChannel == CommunicationChannels.Email)
                            .EnableExpiringApplicationAlertsViaText(communicationChannel == CommunicationChannels.Sms)
                            .EnableMarketingViaEmail(communicationChannel == CommunicationChannels.Email)
                            .EnableMarketingViaText(communicationChannel == CommunicationChannels.Sms)
                            .EnableSavedSearchAlertsViaEmail(communicationChannel == CommunicationChannels.Email)
                            .EnableSavedSearchAlertsViaText(communicationChannel == CommunicationChannels.Sms)
                            .Build();

            var provider = new AccountProviderBuilder().With(candidateService).Build();

            Candidate candidate;

            // Act.
            var result = provider.TrySaveSettings(candidateId, viewModel, out candidate);

            // Assert.
            result.Should().BeTrue();

            candidate.RegistrationDetails.Should().NotBeNull();
            candidate.RegistrationDetails.PhoneNumber.Should().Be(phoneNumber);

            candidate.CommunicationPreferences.Should().NotBeNull();

            {
                var preferences = candidate.CommunicationPreferences.ApplicationStatusChangePreferences;

                preferences.Should().NotBeNull();
                preferences.EnableEmail.Should().Be(communicationChannel == CommunicationChannels.Email);
                preferences.EnableText.Should().Be(communicationChannel == CommunicationChannels.Sms);
            }

            {
                var preferences = candidate.CommunicationPreferences.ExpiringApplicationPreferences;

                preferences.Should().NotBeNull();
                preferences.EnableEmail.Should().Be(communicationChannel == CommunicationChannels.Email);
                preferences.EnableText.Should().Be(communicationChannel == CommunicationChannels.Sms);
            }

            {
                var preferences = candidate.CommunicationPreferences.MarketingPreferences;

                preferences.Should().NotBeNull();
                preferences.EnableEmail.Should().Be(communicationChannel == CommunicationChannels.Email);
                preferences.EnableText.Should().Be(communicationChannel == CommunicationChannels.Sms);
            }

            {
                var preferences = candidate.CommunicationPreferences.SavedSearchPreferences;

                preferences.Should().NotBeNull();
                preferences.EnableEmail.Should().Be(communicationChannel == CommunicationChannels.Email);
                preferences.EnableText.Should().Be(communicationChannel == CommunicationChannels.Sms);
            }

            candidate.CommunicationPreferences.VerifiedMobile.Should().Be(verifiedMobile);
        }