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 US519_AC2_AC3_MarketingPreferences(bool allowEmailMarketing, bool allowSmsMarketing) { var viewModel = new SettingsViewModelBuilder().SmsEnabled(true).AllowEmailMarketing(allowEmailMarketing).AllowSmsMarketing(allowSmsMarketing).Build(); var result = new SettingsViewBuilder().With(viewModel).Render(); var allowEmailMarketingCheckBox = result.GetElementbyId("AllowEmailMarketing"); var allowSmsMarketingCheckBox = result.GetElementbyId("AllowSmsMarketing"); allowEmailMarketingCheckBox.Should().NotBeNull(); allowSmsMarketingCheckBox.Should().NotBeNull(); allowEmailMarketingCheckBox.ParentNode.InnerText.Should().Be("Email"); allowSmsMarketingCheckBox.ParentNode.InnerText.Should().Be("Text"); if (allowEmailMarketing) { allowEmailMarketingCheckBox.Attributes["checked"].Should().NotBeNull(); } else { allowEmailMarketingCheckBox.Attributes["checked"].Should().BeNull(); } if (allowSmsMarketing) { allowSmsMarketingCheckBox.Attributes["checked"].Should().NotBeNull(); } else { allowSmsMarketingCheckBox.Attributes["checked"].Should().BeNull(); } }
public void US616_AC2_AC3_CommunicationPreferences(bool allowEmailComms, bool allowSmsComms) { var viewModel = new SettingsViewModelBuilder().SmsEnabled(true).AllowEmailComms(allowEmailComms).AllowSmsComms(allowSmsComms).Build(); var result = new SettingsViewBuilder().With(viewModel).Render(); var allowEmailCommsCheckBox = result.GetElementbyId("AllowEmailComms"); var allowSmsCommsCheckBox = result.GetElementbyId("AllowSmsComms"); allowEmailCommsCheckBox.Should().NotBeNull(); allowSmsCommsCheckBox.Should().NotBeNull(); allowEmailCommsCheckBox.ParentNode.InnerText.Should().Be("Email"); allowSmsCommsCheckBox.ParentNode.InnerText.Should().Be("Text"); if (allowEmailComms) { allowEmailCommsCheckBox.Attributes["checked"].Should().NotBeNull(); } else { allowEmailCommsCheckBox.Attributes["checked"].Should().BeNull(); } if (allowSmsComms) { allowSmsCommsCheckBox.Attributes["checked"].Should().NotBeNull(); } else { allowSmsCommsCheckBox.Attributes["checked"].Should().BeNull(); } }
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 OneSavedSearch(string apprenticeshipLevel, bool alertEnabled) { const string name = "Within 5 miles of CV1 2WT"; const string searchUrl = "/apprenticeships?Location=CV1%202WT&LocationType=NonNational&ApprenticeshipLevel=All&SearchField=All&SearchMode=Keyword&Hash=0&WithinDistance=5&SortType=Relevancy&PageNumber=1&SearchAction=Search&ResultsPerPage=5"; var savedSearchViewModels = new Fixture().Build <SavedSearchViewModel>() .With(s => s.Name, name) .With(s => s.SearchUrl, new Url(searchUrl)) .With(s => s.AlertsEnabled, alertEnabled) .With(s => s.ApprenticeshipLevel, apprenticeshipLevel) .With(s => s.SubCategoriesFullNames, string.Empty) .CreateMany(1).ToList(); var viewModel = new SettingsViewModelBuilder().WithSavedSearchViewModels(savedSearchViewModels).Build(); var result = new SettingsViewBuilder().With(viewModel).Render(); var savedSearchDiv = result.GetElementbyId("savedSearch"); savedSearchDiv.Should().NotBeNull(); var savedSearchesHeading = result.GetElementbyId("savedSearchHeading"); savedSearchesHeading.Should().NotBeNull(); var noSavedSearchesText = result.GetElementbyId("noSavedSearchesText"); noSavedSearchesText.Should().NotBeNull(); noSavedSearchesText.GetAttributeValue("style", string.Empty).Should().Be("display: none"); var savedSearchesDiv = result.GetElementbyId("savedSearches"); savedSearchesDiv.Should().NotBeNull(); var savedSearchElement = savedSearchesDiv.ChildNodes.First(n => n.Name == "div"); savedSearchElement.Should().NotBeNull(); var link = savedSearchElement.ChildNodes.First(n => n.Name == "a"); link.GetAttributeValue("href", string.Empty).Should().Be(searchUrl); link.InnerText.Should().Be(name); //Last alert span should not be present var lastAlertSpanPresent = savedSearchElement.ChildNodes.All(n => n.Name != "span"); lastAlertSpanPresent.Should().BeFalse(); var savedSearchPropertyList = savedSearchElement.ChildNodes.First(n => n.Name == "ul"); var savedSearchProperties = savedSearchPropertyList.ChildNodes.Where(n => n.Name == "li").ToList(); var shouldShowLevel = apprenticeshipLevel != "All"; savedSearchProperties.Count.Should().Be(shouldShowLevel ? 3 : 2); if (shouldShowLevel) { savedSearchProperties[0].InnerText.Should().Be(string.Format("Apprenticeship level: {0}", apprenticeshipLevel)); } savedSearchProperties.Last().ChildNodes.First(n => n.Name == "a").InnerText.Should().Contain("Delete saved search"); }
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(); } }
public void DeleteAccountContainer() { var viewModel = new SettingsViewModelBuilder().Build(); var result = new SettingsViewBuilder().With(viewModel).Render(); var savedSearchesHeading = result.GetElementbyId("deleteAccountHeading"); savedSearchesHeading.Should().NotBeNull(); savedSearchesHeading.InnerText.Should().Contain("Delete your account"); }
public void US616_EmailRadioButtonsRemoved() { var viewModel = new SettingsViewModelBuilder().SmsEnabled(true).Build(); var result = new SettingsViewBuilder().With(viewModel).Render(); var allowEmailCommsRadioButtonYes = result.GetElementbyId("AllowEmailComms-yes"); var allowEmailCommsRadioButtonNo = result.GetElementbyId("AllowEmailComms-no"); allowEmailCommsRadioButtonYes.Should().BeNull(); allowEmailCommsRadioButtonNo.Should().BeNull(); }
public void ShouldRenderTextCommunicationPreferences( bool enableApplicationStatusChangeAlertsViaText, bool enableExpiringApplicationAlertsViaText, bool enableMarketingViaText) { var viewModel = new SettingsViewModelBuilder() .SmsEnabled(true) .EnableApplicationStatusChangeAlertsViaText(enableApplicationStatusChangeAlertsViaText) .EnableExpiringApplicationAlertsViaText(enableExpiringApplicationAlertsViaText) .EnableMarketingViaText(enableMarketingViaText) .Build(); var result = new SettingsViewBuilder().With(viewModel).Render(); var enableApplicationStatusChangeAlertsViaTextCheckbox = result.GetElementbyId("EnableApplicationStatusChangeAlertsViaText"); var enableExpiringApplicationAlertsViaTextCheckbox = result.GetElementbyId("EnableExpiringApplicationAlertsViaText"); var enableMarketingViaTextCheckbox = result.GetElementbyId("EnableMarketingViaText"); enableApplicationStatusChangeAlertsViaTextCheckbox.Should().NotBeNull(); enableExpiringApplicationAlertsViaTextCheckbox.Should().NotBeNull(); enableMarketingViaTextCheckbox.Should().NotBeNull(); enableApplicationStatusChangeAlertsViaTextCheckbox.ParentNode.InnerText.Should().Be(string.Empty); enableExpiringApplicationAlertsViaTextCheckbox.ParentNode.InnerText.Should().Be(string.Empty); enableMarketingViaTextCheckbox.ParentNode.InnerText.Should().Be(string.Empty); if (enableApplicationStatusChangeAlertsViaText) { enableApplicationStatusChangeAlertsViaTextCheckbox.Attributes["checked"].Should().NotBeNull(); } else { enableApplicationStatusChangeAlertsViaTextCheckbox.Attributes["checked"].Should().BeNull(); } if (enableExpiringApplicationAlertsViaText) { enableExpiringApplicationAlertsViaTextCheckbox.Attributes["checked"].Should().NotBeNull(); } else { enableExpiringApplicationAlertsViaTextCheckbox.Attributes["checked"].Should().BeNull(); } if (enableMarketingViaText) { enableMarketingViaTextCheckbox.Attributes["checked"].Should().NotBeNull(); } else { enableMarketingViaTextCheckbox.Attributes["checked"].Should().BeNull(); } }
public void SavedSearchContainer() { var viewModel = new SettingsViewModelBuilder().Build(); var result = new SettingsViewBuilder().With(viewModel).Render(); var savedSearchDiv = result.GetElementbyId("savedSearch"); savedSearchDiv.Should().NotBeNull(); var savedSearchesHeading = result.GetElementbyId("savedSearchHeading"); savedSearchesHeading.Should().NotBeNull(); savedSearchesHeading.InnerText.Should().Contain("Saved searches"); }
public void MultipleSavedSearches(int savedSearchCount) { var savedSearchViewModels = new Fixture().Build <SavedSearchViewModel>().CreateMany(savedSearchCount).ToList(); var viewModel = new SettingsViewModelBuilder().WithSavedSearchViewModels(savedSearchViewModels).Build(); var result = new SettingsViewBuilder().With(viewModel).Render(); var savedSearchesDiv = result.GetElementbyId("savedSearches"); savedSearchesDiv.Should().NotBeNull(); var savedSearchElements = savedSearchesDiv.ChildNodes.Where(n => n.Name == "div").ToList(); savedSearchElements.Count.Should().Be(savedSearchCount); }
public void US616_AC4_PhoneNumberRequired(bool allowEmailComms, bool allowSmsComms, string phoneNumber, bool expectValid) { var viewModel = new SettingsViewModelBuilder().PhoneNumber(phoneNumber).AllowEmailComms(allowEmailComms).AllowSmsComms(allowSmsComms).Build(); var validator = new SettingsViewModelServerValidator(); if (expectValid) { validator.ShouldNotHaveValidationErrorFor(vm => vm.PhoneNumber, viewModel); } else { validator.ShouldHaveValidationErrorFor(vm => vm.PhoneNumber, viewModel); } }
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(); } }
public void ShowFindTraineeshipLink(bool shouldShow) { var viewModel = new SettingsViewModelBuilder().ShowTraineeshipsLink(shouldShow).ShowTraineeshipsPrompt(false).Build(); var result = new SettingsViewBuilder().With(viewModel).Render(); var findTraineeshipLink = result.GetElementbyId("find-traineeship-link"); if (shouldShow) { findTraineeshipLink.Should().NotBeNull(); } else { findTraineeshipLink.Should().BeNull(); } }
public void US616_AC4_PhoneVerifiedIndication(bool verifiedMobile) { var viewModel = new SettingsViewModelBuilder().VerifiedMobile(verifiedMobile).Build(); var result = new SettingsViewBuilder().With(viewModel).Render(); var allowEmailCommsCheckBox = result.GetElementbyId("verifyContainer"); if (verifiedMobile) { allowEmailCommsCheckBox.Should().NotBeNull(); allowEmailCommsCheckBox.ChildNodes["span"].InnerText.Should().Be("Verified"); } else { allowEmailCommsCheckBox.Should().BeNull(); } }
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); }
public void ShouldRequirePhoneNumber(int?length, bool expectValid) { // Arrange. var phoneNumber = length.HasValue ? new string('0', length.Value) : null; var viewModel = new SettingsViewModelBuilder().PhoneNumber(phoneNumber).Build(); // Act. var validator = new SettingsViewModelClientValidator(); // Assert. if (expectValid) { validator.ShouldNotHaveValidationErrorFor(vm => vm.PhoneNumber, viewModel); } else { validator.ShouldHaveValidationErrorFor(vm => vm.PhoneNumber, viewModel); } }
public void ShouldRequireLastName(int?length, bool expectValid) { // Arrange. var lastName = length.HasValue ? new string('X', length.Value) : null; var viewModel = new SettingsViewModelBuilder().Lastname(lastName).Build(); // Act. var validator = new SettingsViewModelClientValidator(); // Assert. if (expectValid) { validator.ShouldNotHaveValidationErrorFor(vm => vm.Lastname, viewModel); } else { validator.ShouldHaveValidationErrorFor(vm => vm.Lastname, viewModel); } }
public void SaveSearchesSettingsSuccessWithWarning() { var savedSearchViewModels = new Fixture().Build <SavedSearchViewModel>().With(s => s.AlertsEnabled, false).CreateMany(1).ToList(); var settingsViewModel = new SettingsViewModelBuilder().EnableSavedSearchAlertsViaEmail(true).EnableSavedSearchAlertsViaText(true).WithSavedSearchViewModels(savedSearchViewModels).Build(); settingsViewModel.Mode = SettingsViewModel.SettingsMode.SavedSearches; // ReSharper disable once RedundantAssignment var candidate = new Candidate(); candidate.DisableAllOptionalCommunications(); var accountProviderMock = new Mock <IAccountProvider>(); accountProviderMock.Setup(x => x.TrySaveSettings(It.IsAny <Guid>(), It.IsAny <SettingsViewModel>(), out candidate)).Returns(true); var accountMediator = new AccountMediatorBuilder().With(accountProviderMock.Object).Build(); var response = accountMediator.SaveSettings(Guid.NewGuid(), settingsViewModel); response.AssertMessage(AccountMediatorCodes.Settings.SuccessWithWarning, AccountPageMessages.SettingsUpdatedSavedSearchesAlertWarning, UserMessageLevel.Info, true); }
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 SaveNotificationsSettingsSuccessWithWarning() { var settingsViewModel = new SettingsViewModelBuilder().Build(); settingsViewModel.Mode = SettingsViewModel.SettingsMode.YourAccount; var candidateServiceProviderMock = new Mock <ICandidateServiceProvider>(); // ReSharper disable once RedundantAssignment var candidate = new Candidate(); candidate.DisableAllOptionalCommunications(); var accountProviderMock = new Mock <IAccountProvider>(); accountProviderMock.Setup(x => x.TrySaveSettings(It.IsAny <Guid>(), It.IsAny <SettingsViewModel>(), out candidate)).Returns(true); var accountMediator = new AccountMediatorBuilder().With(candidateServiceProviderMock).With(accountProviderMock.Object).Build(); var response = accountMediator.SaveSettings(Guid.NewGuid(), settingsViewModel); response.AssertMessage(AccountMediatorCodes.Settings.SuccessWithWarning, AccountPageMessages.SettingsUpdatedNotificationsAlertWarning, UserMessageLevel.Info, true); }
public void OneSavedSearchWithDateProcessed() { var savedSearchViewModels = new Fixture().Build <SavedSearchViewModel>() .With(s => s.DateProcessed, DateTime.UtcNow) .CreateMany(1).ToList(); var viewModel = new SettingsViewModelBuilder().WithSavedSearchViewModels(savedSearchViewModels).Build(); var result = new SettingsViewBuilder().With(viewModel).Render(); var savedSearchesDiv = result.GetElementbyId("savedSearches"); savedSearchesDiv.Should().NotBeNull(); var savedSearchElement = savedSearchesDiv.ChildNodes.First(n => n.Name == "div"); savedSearchElement.Should().NotBeNull(); var lastAlertSpan = savedSearchElement.ChildNodes.First(n => n.Name == "span"); lastAlertSpan.InnerText.Should().Be("(Last alert: today)"); }
public void NoSavedSearches() { var viewModel = new SettingsViewModelBuilder().Build(); var result = new SettingsViewBuilder().With(viewModel).Render(); var savedSearchDiv = result.GetElementbyId("savedSearch"); savedSearchDiv.Should().NotBeNull(); var savedSearchesHeading = result.GetElementbyId("savedSearchHeading"); savedSearchesHeading.Should().NotBeNull(); var noSavedSearchesText = result.GetElementbyId("noSavedSearchesText"); noSavedSearchesText.Should().NotBeNull(); noSavedSearchesText.Attributes.Any(a => a.Name == "style").Should().BeFalse(); noSavedSearchesText.InnerText.Should().Contain("You currently don't have any active saved searches"); var savedSearchesDiv = result.GetElementbyId("savedSearches"); savedSearchesDiv.Should().BeNull(); }
public void MobileVerificationRequiredMarketing(string newPhoneNumber, bool verifiedMobile, bool allowSmsMarketing, string expectedCode) { var candidateId = Guid.NewGuid(); var candidate = new CandidateBuilder(candidateId).PhoneNumber("0123456789").VerifiedMobile(verifiedMobile).Build(); var candidateService = new Mock <ICandidateService>(); candidateService.Setup(cs => cs.GetCandidate(candidateId)).Returns(candidate); var viewModel = new SettingsViewModelBuilder().PhoneNumber(newPhoneNumber).AllowSmsMarketing(allowSmsMarketing).Build(); var accountProvider = new AccountProviderBuilder().With(candidateService).Build(); var mediator = new AccountMediatorBuilder().With(accountProvider).Build(); var result = mediator.SaveSettings(candidateId, viewModel); if (expectedCode == AccountMediatorCodes.Settings.MobileVerificationRequired) { result.AssertMessage(expectedCode, AccountPageMessages.MobileVerificationRequired, UserMessageLevel.Success, true); } else { result.AssertCode(expectedCode); } }
public void SmsEnabledFeatureToggle(bool smsEnabled) { var viewModel = new SettingsViewModelBuilder().SmsEnabled(smsEnabled).Build(); var result = new SettingsViewBuilder().With(viewModel).Render(); var allowEmailMarketingCheckBox = result.GetElementbyId("AllowEmailMarketing"); var allowSmsMarketingCheckBox = result.GetElementbyId("AllowSmsMarketing"); allowEmailMarketingCheckBox.Should().NotBeNull(); allowEmailMarketingCheckBox.ParentNode.InnerText.Should().Be("Email"); if (smsEnabled) { allowSmsMarketingCheckBox.Should().NotBeNull(); allowSmsMarketingCheckBox.ParentNode.InnerText.Should().Be("Text"); } else { allowSmsMarketingCheckBox.Should().BeNull(); } }
public void MobileVerificationRequiredCommunications(string newPhoneNumber, bool verifiedMobile, bool enableAnyTextCommunication, string expectedCode) { var candidateId = Guid.NewGuid(); var candidate = new CandidateBuilder(candidateId).PhoneNumber("0123456789").VerifiedMobile(verifiedMobile).Build(); var candidateService = new Mock <ICandidateService>(); candidateService.Setup(cs => cs.GetCandidate(candidateId)).Returns(candidate); var viewModel = new SettingsViewModelBuilder().PhoneNumber(newPhoneNumber).EnableAnyTextCommunication(enableAnyTextCommunication).EnableApplicationStatusChangeAlertsViaEmail(true).Build(); var accountProvider = new AccountProviderBuilder().With(candidateService).Build(); var mediator = new AccountMediatorBuilder().With(accountProvider).Build(); var result = mediator.SaveSettings(candidateId, viewModel); if (expectedCode == AccountMediatorCodes.Settings.MobileVerificationRequired) { result.AssertMessage(expectedCode, AccountPageMessages.MobileVerificationRequired, UserMessageLevel.Success, true); } else { result.AssertCodeAndMessage(expectedCode); } }
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); }