public void WhenIRegisterANewUserWithUsernameAndPassword(string p0, string p1) { Reg = new RegistrationBusinessLogic(); Assert.IsTrue(Reg.invoke()); Assert.IsTrue(Reg.generate_request("register", "Post")); Assert.IsTrue(Reg.Provide_parameter(p0, p1)); }
public void BeforeEach() { // mock data var dbContext = AutoFacHelpers.CreateInMemoryTestDatabase(UserOrganisationHelper.CreateRegistrations()); mockDataRepo = new SqlRepository(dbContext); mockLogRecordLogger = new Mock <IRegistrationLogger>(); // service under test testRegistrationBusinessLogic = new RegistrationBusinessLogic(mockDataRepo, mockLogRecordLogger.Object); }
public async Task <ModelStateDictionary> CloseAccountAsync(User userToRetire, string currentPassword, User actionByUser) { var errorState = new ModelStateDictionary(); // ensure the user has entered their password var checkPasswordResult = await UserRepository.CheckPasswordAsync(userToRetire, currentPassword); if (checkPasswordResult == false) { errorState.AddModelError(nameof(ChangePasswordViewModel.CurrentPassword), "Could not verify your current password"); return(errorState); } //Save the list of registered organisations var userOrgs = userToRetire.UserOrganisations.Select(uo => uo.Organisation).Distinct().ToList(); // aggregated save await UserRepository.BeginTransactionAsync( async() => { try { // update retired user registrations await RegistrationBusinessLogic.RemoveRetiredUserRegistrationsAsync(userToRetire, actionByUser); // retire user await UserRepository.RetireUserAsync(userToRetire); // commit UserRepository.CommitTransaction(); } catch (Exception ex) { UserRepository.RollbackTransaction(); Logger.LogWarning( ex, "Failed to retire user {UserId}. Action by user {ActionByUserId}", userToRetire.UserId, actionByUser.UserId); throw; } }); if (!userToRetire.EmailAddress.StartsWithI(_sharedBusinessLogic.SharedOptions.TestPrefix)) { // Create the close account notification to user var sendEmails = new List <Task>(); var testEmail = !_sharedBusinessLogic.SharedOptions.IsProduction(); sendEmails.Add( SendEmailService.SendAccountClosedNotificationAsync(userToRetire.EmailAddress, testEmail)); //Create the notification to GEO for each newly orphaned organisation userOrgs.Where(org => _organisationBusinessLogic.GetOrganisationIsOrphan(org)) .ForEach(org => sendEmails.Add( SendEmailService.SendGEOOrphanOrganisationNotificationAsync(org.OrganisationName, testEmail))); //Send all the notifications in parallel await Task.WhenAll(sendEmails); } return(errorState); }
public void WhenUserSendsARequestsOn(string p0) { Reg = new RegistrationBusinessLogic(); Assert.IsTrue(Reg.invoke()); Assert.IsTrue(Reg.generate_request(p0, "Get")); }