public void SaveSuccessTest() { var settingsViewModel = new SettingsViewModel { Address = new AddressViewModel { AddressLine1 = "Add1", AddressLine2 = "Add2", AddressLine3 = "Add3", AddressLine4 = "Add4", Postcode = "N7 8LS" }, DateOfBirth = new DateViewModel { Day = DateTime.Now.Day, Month = DateTime.Now.Month, Year = DateTime.Now.Year }, PhoneNumber = "079824524523", Firstname = "FN", Lastname = "LN" }; var candidateServiceProviderMock = new Mock <ICandidateServiceProvider>(); candidateServiceProviderMock.Setup(x => x.GetCandidate(It.IsAny <Guid>())).Returns(new Candidate()); var candidate = new Candidate(); 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.Code.Should().Be(AccountMediatorCodes.Settings.Success); response.ViewModel.Should().Be(settingsViewModel); }
public void ErrorTest() { var candidate = new Candidate { RegistrationDetails = new RegistrationDetails { AcceptedTermsAndConditionsVersion = "1" } }; var candidateServiceProviderMock = new Mock <ICandidateServiceProvider>(); candidateServiceProviderMock.Setup(x => x.GetCandidate(It.IsAny <Guid>())).Returns(candidate); var configurationServiceMock = new Mock <IConfigurationService>(); configurationServiceMock.Setup(x => x.Get <CommonWebConfiguration>()) .Returns(new CommonWebConfiguration() { TermsAndConditionsVersion = "1.1" }); candidateServiceProviderMock.Setup(x => x.AcceptTermsAndConditions(It.IsAny <Guid>(), It.IsAny <string>())).Returns(false); var accountMediator = new AccountMediatorBuilder().With(candidateServiceProviderMock).With(configurationServiceMock).Build(); var response = accountMediator.AcceptTermsAndConditions(Guid.NewGuid()); response.Code.Should().Be(AccountMediatorCodes.AcceptTermsAndConditions.ErrorAccepting); }
public void VerifyMobileTest(VerifyMobileState verifyMobileState, string accountMediatorCode, string pageMessage, UserMessageLevel userMessageLevel) { //Arrange //const VerifyMobileState verifyMobileState = VerifyMobileState.Ok; var verifyMobileViewModel = new VerifyMobileViewModelBuilder().PhoneNumber(MobileNumber).VerifyMobileState(verifyMobileState).MobileVerificationCode(ValidVerificationCode).Build(); var verifyMobileViewModelServerValidatorMock = new Mock <VerifyMobileViewModelServerValidator>(); verifyMobileViewModelServerValidatorMock.Setup(x => x.Validate(It.IsAny <VerifyMobileViewModel>())).Returns(new ValidationResult()); var accountProviderMock = new Mock <IAccountProvider>(); accountProviderMock.Setup(x => x.VerifyMobile(It.IsAny <Guid>(), It.IsAny <VerifyMobileViewModel>())).Returns(verifyMobileViewModel); var accountMediator = new AccountMediatorBuilder().With(accountProviderMock.Object).With(verifyMobileViewModelServerValidatorMock).Build(); //Act var response = accountMediator.VerifyMobile(Guid.NewGuid(), new VerifyMobileViewModel() { PhoneNumber = MobileNumber, VerifyMobileCode = ValidVerificationCode }); //Assert response.Code.Should().Be(accountMediatorCode); response.Message.Text.Should().Be(pageMessage); response.Message.Level.Should().Be(userMessageLevel); }
public void SaveErrorTest() { var settingsViewModel = new SettingsViewModel { Address = new AddressViewModel { AddressLine1 = "Add1", AddressLine2 = "Add2", AddressLine3 = "Add3", AddressLine4 = "Add4", Postcode = "N7 8LS" }, DateOfBirth = new DateViewModel { Day = DateTime.UtcNow.Day, Month = DateTime.UtcNow.Month, Year = DateTime.UtcNow.Year }, PhoneNumber = "079824524523", Firstname = "FN", Lastname = "LN" }; // ReSharper disable once RedundantAssignment var candidate = new Candidate(); var accountProviderMock = new Mock <IAccountProvider>(); accountProviderMock.Setup(x => x.TrySaveSettings(It.IsAny <Guid>(), It.IsAny <SettingsViewModel>(), out candidate)).Returns(false); var accountMediator = new AccountMediatorBuilder().With(accountProviderMock.Object).Build(); var response = accountMediator.SaveSettings(Guid.NewGuid(), settingsViewModel); response.Code.Should().Be(AccountMediatorCodes.Settings.SaveError); response.ViewModel.Should().Be(settingsViewModel); response.Message.Text.Should().Be(AccountPageMessages.SettingsUpdateFailed); response.Message.Level.Should().Be(UserMessageLevel.Warning); }
public void SaveSuccessTest() { var settingsViewModel = new SettingsViewModel { Address = new AddressViewModel { AddressLine1 = "Add1", AddressLine2 = "Add2", AddressLine3 = "Add3", AddressLine4 = "Add4", Postcode = "N7 8LS" }, DateOfBirth = new DateViewModel { Day = DateTime.UtcNow.Day, Month = DateTime.UtcNow.Month, Year = DateTime.UtcNow.Year }, PhoneNumber = "079824524523", Firstname = "FN", Lastname = "LN", EnableApplicationStatusChangeAlertsViaEmail = true }; // 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.Code.Should().Be(AccountMediatorCodes.Settings.Success); response.ViewModel.Should().Be(settingsViewModel); }
public void ValidationErrorTest() { //Arrange const VerifyMobileState verifyMobileState = VerifyMobileState.VerifyMobileCodeInvalid; var v = new ValidationResult(); v.Errors.Add(new ValidationFailure("VerifyMobileCode", "Length should be less than 4 digits")); var verifyMobileViewModel = new VerifyMobileViewModelBuilder().PhoneNumber(MobileNumber).VerifyMobileState(verifyMobileState).MobileVerificationCode(InvalidVerificationCode).Build(); //todo: nice to have to convert into a builder class var verifyMobileViewModelServerValidatorMock = new Mock <VerifyMobileViewModelServerValidator>(); verifyMobileViewModelServerValidatorMock.Setup(x => x.Validate(It.IsAny <VerifyMobileViewModel>())).Returns(v); var accountProviderMock = new Mock <IAccountProvider>(); accountProviderMock.Setup(x => x.VerifyMobile(It.IsAny <Guid>(), It.IsAny <VerifyMobileViewModel>())).Returns(verifyMobileViewModel); var accountMediator = new AccountMediatorBuilder().With(accountProviderMock.Object).With(verifyMobileViewModelServerValidatorMock).Build(); //Act var response = accountMediator.VerifyMobile(Guid.NewGuid(), new VerifyMobileViewModel() { PhoneNumber = MobileNumber, VerifyMobileCode = ValidVerificationCode }); //Assert response.Code.Should().Be(AccountMediatorCodes.VerifyMobile.ValidationError); response.ValidationResult.Should().NotBeNull(); }
public void SuccessTest() { var accountProviderMock = new Mock <IAccountProvider>(); accountProviderMock.Setup(x => x.GetSettingsViewModel(It.IsAny <Guid>())).Returns(new SettingsViewModel()); var accountMediator = new AccountMediatorBuilder().With(accountProviderMock.Object).Build(); var response = accountMediator.Settings(Guid.NewGuid(), SettingsViewModel.SettingsMode.YourAccount); response.AssertCodeAndMessage(AccountMediatorCodes.Settings.Success); }
public void SuccessTest() { var accountProviderMock = new Mock <IAccountProvider>(); accountProviderMock.Setup(x => x.SetUserAccountDeletionPending(It.IsAny <Guid>())).Returns(true); var accountMediator = new AccountMediatorBuilder().With(accountProviderMock.Object).Build(); var response = accountMediator.SetAccountStatusToDelete(Guid.NewGuid()); response.AssertCodeAndMessage(AccountMediatorCodes.Settings.Success); }
public void SaveValidationErrorTest() { var settingsViewModel = new SettingsViewModel(); var accountMediator = new AccountMediatorBuilder().Build(); var response = accountMediator.SaveSettings(Guid.NewGuid(), settingsViewModel); response.Code.Should().Be(AccountMediatorCodes.Settings.ValidationError); response.ViewModel.Should().Be(settingsViewModel); response.ValidationResult.Should().NotBeNull(); }
public void SuccessfullyDismissedTest() { var accountProviderMock = new Mock <IAccountProvider>(); accountProviderMock.Setup(x => x.DismissTraineeshipPrompts(It.IsAny <Guid>())).Returns(true); var accountMediator = new AccountMediatorBuilder().With(accountProviderMock.Object).Build(); var response = accountMediator.DismissTraineeshipPrompts(Guid.NewGuid()); response.Should().NotBeNull(); response.Code.Should().Be(AccountMediatorCodes.DismissTraineeshipPrompts.SuccessfullyDismissed); }
public void ErrorTest() { var applicationView = new ApprenticeshipApplicationViewModelBuilder().HasError("Has error").Build(); var apprenticeshipApplicationProviderMock = new Mock<IApprenticeshipApplicationProvider>(); apprenticeshipApplicationProviderMock.Setup(x => x.ArchiveApplication(It.IsAny<Guid>(), It.IsAny<int>())).Returns(applicationView); var accountMediator = new AccountMediatorBuilder().With(apprenticeshipApplicationProviderMock).Build(); var response = accountMediator.Archive(Guid.NewGuid(), 1); response.Code.Should().Be(AccountMediatorCodes.Archive.ErrorArchiving); response.Message.Text.Should().Be("Has error"); response.Message.Level.Should().Be(UserMessageLevel.Warning); }
public void SuccessTest() { var applicationView = new ApprenticeshipApplicationViewModelBuilder().Build(); var apprenticeshipApplicationProviderMock = new Mock<IApprenticeshipApplicationProvider>(); apprenticeshipApplicationProviderMock.Setup(x => x.ArchiveApplication(It.IsAny<Guid>(), It.IsAny<int>())).Returns(applicationView); var accountMediator = new AccountMediatorBuilder().With(apprenticeshipApplicationProviderMock).Build(); var response = accountMediator.Archive(Guid.NewGuid(), 1); response.Code.Should().Be(AccountMediatorCodes.Archive.SuccessfullyArchived); response.Message.Text.Should().Be(MyApplicationsPageMessages.ApplicationArchived); response.Message.Level.Should().Be(UserMessageLevel.Success); }
public void ExceptionTest() { var candidateServiceProviderMock = new Mock <ICandidateServiceProvider>(); candidateServiceProviderMock.Setup(x => x.GetCandidate(It.IsAny <Guid>())).Throws <Exception>(); var configurationManagerMock = new Mock <IConfigurationManager>(); configurationManagerMock.Setup(x => x.GetAppSetting <string>("TermsAndConditionsVersion")).Returns("1.1"); var accountMediator = new AccountMediatorBuilder().With(candidateServiceProviderMock).With(configurationManagerMock).Build(); var response = accountMediator.AcceptTermsAndConditions(Guid.NewGuid()); response.Code.Should().Be(AccountMediatorCodes.AcceptTermsAndConditions.ErrorAccepting); }
public void ErrorDismissingTest() { var accountProviderMock = new Mock <IAccountProvider>(); accountProviderMock.Setup(x => x.DismissTraineeshipPrompts(It.IsAny <Guid>())).Returns(false); var accountMediator = new AccountMediatorBuilder().With(accountProviderMock.Object).Build(); var response = accountMediator.DismissTraineeshipPrompts(Guid.NewGuid()); response.Should().NotBeNull(); response.Code.Should().Be(AccountMediatorCodes.DismissTraineeshipPrompts.ErrorDismissing); response.Message.Text.Should().Be(MyApplicationsPageMessages.DismissTraineeshipPromptsFailed); response.Message.Level.Should().Be(UserMessageLevel.Error); }
public void SuccessTest() { var applicationView = new ApprenticeshipApplicationViewModel(); var apprenticeshipApplicationProviderMock = new Mock <IApprenticeshipApplicationProvider>(); apprenticeshipApplicationProviderMock.Setup(x => x.UnarchiveApplication(It.IsAny <Guid>(), It.IsAny <int>())).Returns(applicationView); var accountMediator = new AccountMediatorBuilder().With(apprenticeshipApplicationProviderMock).Build(); var response = accountMediator.Track(Guid.NewGuid(), 1); response.Code.Should().Be(AccountMediatorCodes.Track.SuccessfullyTracked); response.Message.Should().BeNull(); }
public void VacancyNotFoundTest() { var apprenticeshipVacancyDetailProvider = new Mock <IApprenticeshipVacancyDetailProvider>(); apprenticeshipVacancyDetailProvider.Setup(x => x.GetVacancyDetailViewModel(It.IsAny <Guid>(), It.IsAny <int>())).Returns(default(VacancyDetailViewModel)); var accountMediator = new AccountMediatorBuilder().With(apprenticeshipVacancyDetailProvider).Build(); var response = accountMediator.ApprenticeshipVacancyDetails(Guid.NewGuid(), 42); response.Code.Should().Be(AccountMediatorCodes.VacancyDetails.Unavailable); response.Message.Should().NotBeNull(); response.Message.Text.Should().Be(MyApplicationsPageMessages.ApprenticeshipNoLongerAvailable); response.Message.Level.Should().Be(UserMessageLevel.Warning); }
public void SaveValidationErrorTest() { var settingsViewModel = new SettingsViewModel(); var accountProvider = new Mock <IAccountProvider>(); accountProvider.Setup(x => x.GetSettingsViewModel(It.IsAny <Guid>())).Returns(new SettingsViewModel()); var accountMediator = new AccountMediatorBuilder().With(accountProvider.Object).Build(); var response = accountMediator.SaveSettings(Guid.NewGuid(), settingsViewModel); response.Code.Should().Be(AccountMediatorCodes.Settings.ValidationError); response.ViewModel.Should().Be(settingsViewModel); response.ValidationResult.Should().NotBeNull(); }
public void SuccessTest() { var emptyMyApplicationsView = new MyApplicationsViewModel(new List <MyApprenticeshipApplicationViewModel>(), new List <MyTraineeshipApplicationViewModel>(), new TraineeshipFeatureViewModel(), null); var apprenticeshipApplicationProviderMock = new Mock <IApprenticeshipApplicationProvider>(); apprenticeshipApplicationProviderMock.Setup(x => x.GetMyApplications(It.IsAny <Guid>())).Returns(emptyMyApplicationsView); var accountMediator = new AccountMediatorBuilder().With(apprenticeshipApplicationProviderMock).Build(); var response = accountMediator.Index(Guid.NewGuid(), "deletedVacancyId", "deletedVacancyTitle"); response.Code.Should().Be(AccountMediatorCodes.Index.Success); response.ViewModel.Should().Be(emptyMyApplicationsView); response.ViewModel.DeletedVacancyId.Should().Be("deletedVacancyId"); response.ViewModel.DeletedVacancyTitle.Should().Be("deletedVacancyTitle"); }
public void SaveValidationErrorTest() { var settingsViewModel = new SettingsViewModel(); var deleteAccountSettingsViewModel = new DeleteAccountSettingsViewModel(); var accountProvider = new Mock <IAccountProvider>(); accountProvider.Setup(x => x.GetSettingsViewModel(It.IsAny <Guid>())).Returns(new SettingsViewModel()); var accountMediator = new AccountMediatorBuilder().With(accountProvider.Object).Build(); deleteAccountSettingsViewModel.EmailAddress = settingsViewModel.EmailAddress; deleteAccountSettingsViewModel.Password = settingsViewModel.Password; var response = accountMediator.VerifyAccountSettings(Guid.NewGuid(), deleteAccountSettingsViewModel); response.Code.Should().Be(AccountMediatorCodes.ValidateUserAccountBeforeDelete.ValidationError); response.ValidationResult.Should().NotBeNull(); }
public void DeleteAlreadyDeleted() { var applicationView = new ApprenticeshipApplicationViewModel { ViewModelMessage = "Has error" }; var apprenticeshipApplicationProviderMock = new Mock <IApprenticeshipApplicationProvider>(); apprenticeshipApplicationProviderMock.Setup(x => x.GetApplicationViewModel(It.IsAny <Guid>(), It.IsAny <int>())).Returns(applicationView); var accountMediator = new AccountMediatorBuilder().With(apprenticeshipApplicationProviderMock).Build(); var response = accountMediator.Delete(Guid.NewGuid(), 1); response.Code.Should().Be(AccountMediatorCodes.Delete.AlreadyDeleted); response.Message.Text.Should().Be(MyApplicationsPageMessages.ApplicationDeleted); response.Message.Level.Should().Be(UserMessageLevel.Warning); }
public void ResendUpdateEmailAddressCodeHasError() { var accountProviderMock = new Mock <IAccountProvider>(); accountProviderMock.Setup(x => x.ResendUpdateEmailAddressCode(It.IsAny <Guid>())) .Returns(new VerifyUpdatedEmailViewModel("Error")); var accountMediator = new AccountMediatorBuilder().With(accountProviderMock.Object).Build(); var response = accountMediator.ResendUpdateEmailAddressCode(Guid.NewGuid()); response.Code.Should().Be(AccountMediatorCodes.ResendUpdateEmailAddressCode.HasError); response.ViewModel.Should().NotBeNull(); response.Message.Should().NotBeNull(); response.Message.Text.Should().Be(UpdateEmailAddressMessages.UpdateEmailAddressError); response.Message.Level.Should().Be(UserMessageLevel.Error); }
public void VacancyStatusLiveTest() { var vacancyDetailViewModel = new TraineeshipVacancyDetailViewModel { VacancyStatus = VacancyStatuses.Live }; var traineeshipVacancyProvider = new Mock <ITraineeshipVacancyProvider>(); traineeshipVacancyProvider.Setup(x => x.GetVacancyDetailViewModel(It.IsAny <Guid>(), It.IsAny <int>())).Returns(vacancyDetailViewModel); var accountMediator = new AccountMediatorBuilder().With(traineeshipVacancyProvider).Build(); var response = accountMediator.TraineeshipVacancyDetails(Guid.NewGuid(), 42); response.Code.Should().Be(AccountMediatorCodes.VacancyDetails.Available); response.Message.Should().BeNull(); }
public void VacancyStatusExpiredTest() { var vacancyDetailViewModel = new VacancyDetailViewModel { VacancyStatus = VacancyStatuses.Expired }; var apprenticeshipVacancyDetailProvider = new Mock <IApprenticeshipVacancyDetailProvider>(); apprenticeshipVacancyDetailProvider.Setup(x => x.GetVacancyDetailViewModel(It.IsAny <Guid>(), It.IsAny <int>())).Returns(vacancyDetailViewModel); var accountMediator = new AccountMediatorBuilder().With(apprenticeshipVacancyDetailProvider).Build(); var response = accountMediator.ApprenticeshipVacancyDetails(Guid.NewGuid(), 42); response.Code.Should().Be(AccountMediatorCodes.VacancyDetails.Available); response.Message.Should().BeNull(); }
public void VerifyUpdatedEmailAddressHasError() { var verifyUpdatedEmailViewModel = new VerifyUpdatedEmailViewModel { PendingUsernameCode = "ABC123", VerifyPassword = "******", ViewModelMessage = "Error" }; var accountProviderMock = new Mock <IAccountProvider>(); accountProviderMock.Setup(x => x.VerifyUpdatedEmailAddress(It.IsAny <Guid>(), It.IsAny <VerifyUpdatedEmailViewModel>())).Returns(verifyUpdatedEmailViewModel); var accountMediator = new AccountMediatorBuilder().With(accountProviderMock.Object).Build(); var response = accountMediator.VerifyUpdatedEmailAddress(Guid.NewGuid(), verifyUpdatedEmailViewModel); response.Code.Should().Be(AccountMediatorCodes.VerifyUpdatedEmailAddress.HasError); response.ViewModel.Should().Be(verifyUpdatedEmailViewModel); response.Message.Should().NotBeNull(); response.Message.Text.Should().Be(UpdateEmailAddressMessages.UpdateEmailAddressError); response.Message.Level.Should().Be(UserMessageLevel.Error); }
public void VerifyUpdatedEmailAddressFailedValidation() { var verifyUpdatedEmailViewModel = new VerifyUpdatedEmailViewModel { PendingUsernameCode = "ABC123", VerifyPassword = "" }; var accountProviderMock = new Mock <IAccountProvider>(); accountProviderMock.Setup(x => x.VerifyUpdatedEmailAddress(It.IsAny <Guid>(), It.IsAny <VerifyUpdatedEmailViewModel>())).Returns(verifyUpdatedEmailViewModel); var accountMediator = new AccountMediatorBuilder().With(accountProviderMock.Object).Build(); var response = accountMediator.VerifyUpdatedEmailAddress(Guid.NewGuid(), verifyUpdatedEmailViewModel); response.Code.Should().Be(AccountMediatorCodes.VerifyUpdatedEmailAddress.ValidationError); response.ViewModel.Should().Be(verifyUpdatedEmailViewModel); response.ValidationResult.Errors.Should().NotBeNull(); response.ValidationResult.Errors.Count.Should().Be(3); response.Message.Should().BeNull(); }
public void DeleteErrorDeleting() { var successApplicationView = new ApprenticeshipApplicationViewModel(); var errorApplicationView = new ApprenticeshipApplicationViewModel { ViewModelMessage = "Error deleting" }; var apprenticeshipApplicationProviderMock = new Mock <IApprenticeshipApplicationProvider>(); apprenticeshipApplicationProviderMock.Setup(x => x.GetApplicationViewModel(It.IsAny <Guid>(), It.IsAny <int>())).Returns(successApplicationView); apprenticeshipApplicationProviderMock.Setup(x => x.DeleteApplication(It.IsAny <Guid>(), It.IsAny <int>())).Returns(errorApplicationView); var accountMediator = new AccountMediatorBuilder().With(apprenticeshipApplicationProviderMock).Build(); var response = accountMediator.Delete(Guid.NewGuid(), 1); response.Code.Should().Be(AccountMediatorCodes.Delete.ErrorDeleting); response.Message.Text.Should().Be("Error deleting"); response.Message.Level.Should().Be(UserMessageLevel.Warning); }
public void VacancyStatusUnavailableTest() { var vacancyDetailViewModel = new TraineeshipVacancyDetailViewModel { VacancyStatus = VacancyStatuses.Unavailable }; var traineeshipVacancyProvider = new Mock <ITraineeshipVacancyProvider>(); traineeshipVacancyProvider.Setup(x => x.GetVacancyDetailViewModel(It.IsAny <Guid>(), It.IsAny <int>())).Returns(vacancyDetailViewModel); var accountMediator = new AccountMediatorBuilder().With(traineeshipVacancyProvider).Build(); var response = accountMediator.TraineeshipVacancyDetails(Guid.NewGuid(), 42); response.Code.Should().Be(AccountMediatorCodes.VacancyDetails.Unavailable); response.Message.Should().NotBeNull(); response.Message.Text.Should().Be(MyApplicationsPageMessages.ApprenticeshipNoLongerAvailable); response.Message.Level.Should().Be(UserMessageLevel.Warning); }
public void ErrorTest() { var vacancyDetailViewModel = new VacancyDetailViewModel { ViewModelMessage = "Has error" }; var apprenticeshipVacancyDetailProvider = new Mock <IApprenticeshipVacancyDetailProvider>(); apprenticeshipVacancyDetailProvider.Setup(x => x.GetVacancyDetailViewModel(It.IsAny <Guid>(), It.IsAny <int>())).Returns(vacancyDetailViewModel); var accountMediator = new AccountMediatorBuilder().With(apprenticeshipVacancyDetailProvider).Build(); var response = accountMediator.ApprenticeshipVacancyDetails(Guid.NewGuid(), 42); response.Code.Should().Be(AccountMediatorCodes.VacancyDetails.Error); response.Message.Should().NotBeNull(); response.Message.Text.Should().Be(vacancyDetailViewModel.ViewModelMessage); response.Message.Level.Should().Be(UserMessageLevel.Error); }
public void Ok() { // Arrange. var candidateId = Guid.NewGuid(); var savedSearchId = Guid.NewGuid(); var candidateService = new Mock <ICandidateServiceProvider>(); candidateService.Setup(cs => cs.DeleteSavedSearch(candidateId, savedSearchId)) .Returns(new SavedSearchViewModel()); var mediator = new AccountMediatorBuilder().With(candidateService).Build(); // Act. var response = mediator.DeleteSavedSearch(candidateId, savedSearchId); // Assert. response.AssertCode(AccountMediatorCodes.DeleteSavedSearch.Ok, true); candidateService.Verify(cs => cs.DeleteSavedSearch(candidateId, savedSearchId), Times.Once); }
public void UpdateEmailAddressHasError() { var emailViewModel = new EmailViewModel() { EmailAddress = "*****@*****.**", UpdateStatus = UpdateEmailStatus.Error, ViewModelMessage = UpdateEmailStatus.Error.ToString() }; var accountProviderMock = new Mock <IAccountProvider>(); accountProviderMock.Setup(x => x.UpdateEmailAddress(It.IsAny <Guid>(), It.IsAny <EmailViewModel>())).Returns(emailViewModel); var accountMediator = new AccountMediatorBuilder().With(accountProviderMock.Object).Build(); var response = accountMediator.UpdateEmailAddress(Guid.NewGuid(), emailViewModel); response.Code.Should().Be(AccountMediatorCodes.UpdateEmailAddress.HasError); response.ViewModel.Should().Be(emailViewModel); response.Message.Text.Should().Be(UpdateEmailAddressMessages.UpdateEmailAddressError); response.Message.Level.Should().Be(UserMessageLevel.Error); }