public void Create_UserHasInsufficientSecurityClearance_DomainValidationExceptionThrown() { var userAccountRepositoryStub = MockRepository.GenerateStub <IUserAccountRepository>(); _userManagementService = UserManagementServiceFactory.Create(userAccountRepositoryStub, TestUserContext.Create("*****@*****.**", "Test User", "Operations Manager", UserRole.Member)); CreateUser(Guid.NewGuid(), "Name", "*****@*****.**", "password", "Job Title", UserRole.Member); Assert.IsTrue(_domainValidationException.ResultContainsMessage(JobSystem.Resources.UserAccounts.Messages.InsufficientSecurityClearance)); }
public void Create_SuccessfullyCreateUser_UserCreated() { var userRepositoryMock = MockRepository.GenerateMock <IUserAccountRepository>(); userRepositoryMock.Expect(x => x.Create(null)).IgnoreArguments(); _userManagementService = UserManagementServiceFactory.Create(userRepositoryMock); _userManagementService.Create(Guid.NewGuid(), "Name", "*****@*****.**", "password", "Job Title", UserRole.Member); userRepositoryMock.VerifyAllExpectations(); }
public void Edit_JobTitleGreaterThan256Characters_DomainValidationExceptionThrown() { var id = Guid.NewGuid(); var user = _userManagementService.Create(id, "Chris", "*****@*****.**", "p'ssw0rd", "Job Title", UserRole.Member); var userAccountRepositoryStub = MockRepository.GenerateStub <IUserAccountRepository>(); userAccountRepositoryStub.Stub(x => x.GetById(id)).Return(user); _userManagementService = UserManagementServiceFactory.Create(userAccountRepositoryStub); _userManagementService.Edit(id, "Chris", "*****@*****.**", GreaterThan256Characters, UserRole.Member | UserRole.JobApprover); }
public void Edit_InvalidIdSupplied_ArgumentExceptionThrown() { var id = Guid.NewGuid(); var user = _userManagementService.Create(id, "Chris", "*****@*****.**", "p'ssw0rd", "Job Title", UserRole.Member); var userAccountRepositoryStub = MockRepository.GenerateStub <IUserAccountRepository>(); userAccountRepositoryStub.Stub(x => x.GetById(id)).Return(user); _userManagementService = UserManagementServiceFactory.Create(userAccountRepositoryStub); _userManagementService.Edit(Guid.NewGuid(), "Chris - edited", "*****@*****.**", "Job Title", UserRole.Member | UserRole.JobApprover); }
public void Login_ValidUserWithNoPasswordSupplied_DomainValidationExceptionThrown() { var userAccountRepositoryStub = MockRepository.GenerateStub <IUserAccountRepository>(); userAccountRepositoryStub.Stub(x => x.GetByEmail("*****@*****.**", false)).Return(new UserAccount() { EmailAddress = "*****@*****.**" }); _userManagementService = UserManagementServiceFactory.Create(userAccountRepositoryStub); _userManagementService.Login("*****@*****.**", String.Empty); }
public void Edit_UserHasInsufficientSecurityClearance_DomainValidationExceptionThrown() { var id = Guid.NewGuid(); var user = _userManagementService.Create(id, "Chris", "*****@*****.**", "p'ssw0rd", "Job Title", UserRole.Member); var userAccountRepositoryStub = MockRepository.GenerateStub <IUserAccountRepository>(); userAccountRepositoryStub.Stub(x => x.GetById(id)).Return(user); _userManagementService = UserManagementServiceFactory.Create(userAccountRepositoryStub, TestUserContext.Create("*****@*****.**", "Test User", "Operations Manager", UserRole.Member)); EditUser(id, "Name", "*****@*****.**", "password", "Job Title", UserRole.Member); Assert.IsTrue(_domainValidationException.ResultContainsMessage(JobSystem.Resources.UserAccounts.Messages.InsufficientSecurityClearanceEdit)); }
public void Create_EmailNotUnique_DomainValidationExceptionThrown() { var userAccountRepositoryStub = MockRepository.GenerateStub <IUserAccountRepository>(); userAccountRepositoryStub.Stub(x => x.GetByEmail("*****@*****.**", true)).Return(new UserAccount() { EmailAddress = "*****@*****.**" }); _userManagementService = UserManagementServiceFactory.Create(userAccountRepositoryStub); CreateUser(Guid.NewGuid(), "Name", "*****@*****.**", "password", "Job Title", UserRole.Member); Assert.IsTrue(_domainValidationException.ResultContainsMessage(String.Format(JobSystem.Resources.UserAccounts.Messages.DuplicateEmailTemplate, "*****@*****.**"))); }
public void Login_ValidUserWithValidPasswordSupplied_LoginSuccess() { var emailAddress = "*****@*****.**"; var user = _userManagementService.Create(Guid.NewGuid(), "Chris", emailAddress, "p'ssw0rd", "Job Title", UserRole.Member); var userAccountRepositoryStub = MockRepository.GenerateStub <IUserAccountRepository>(); userAccountRepositoryStub.Stub(x => x.GetByEmail(emailAddress, false)).Return(user); _userManagementService = UserManagementServiceFactory.Create(userAccountRepositoryStub); var loggedIn = _userManagementService.Login(emailAddress, "p'ssw0rd"); Assert.IsTrue(loggedIn); }
public void Edit_SuccessfullyEditUser_UserEdited() { var id = Guid.NewGuid(); var user = _userManagementService.Create(id, "Chris", "*****@*****.**", "p'ssw0rd", "Job Title", UserRole.Member); var userAccountRepositoryMock = MockRepository.GenerateMock <IUserAccountRepository>(); userAccountRepositoryMock.Stub(x => x.GetById(id)).Return(user); userAccountRepositoryMock.Expect(x => x.Update(null)).IgnoreArguments(); _userManagementService = UserManagementServiceFactory.Create(userAccountRepositoryMock); _userManagementService.Edit(id, "Chris - edited", "*****@*****.**", "Job Title - edited", UserRole.Member | UserRole.JobApprover); userAccountRepositoryMock.VerifyAllExpectations(); }
public void Edit_NonUniqueEmailSupplied_DomainValidationExceptionThrown() { var id = Guid.NewGuid(); var user = _userManagementService.Create(id, "Chris", "*****@*****.**", "p'ssw0rd", "Job Title", UserRole.Member); var user2 = _userManagementService.Create(Guid.NewGuid(), "Chris2", "*****@*****.**", "p'ssw0rd", "Job Title", UserRole.Member); var userAccountRepositoryStub = MockRepository.GenerateStub <IUserAccountRepository>(); userAccountRepositoryStub.Stub(x => x.GetById(id)).Return(user); userAccountRepositoryStub.Stub(x => x.GetByEmail("*****@*****.**", true)).Return(user2); _userManagementService = UserManagementServiceFactory.Create(userAccountRepositoryStub); _userManagementService.Edit(id, "Chris", "*****@*****.**", "Job Title", UserRole.Member | UserRole.JobApprover); }
public UserManagementAPIController() { UserManagementServiceFactory umsFactory = new UserManagementServiceFactory(); _userManagementService = umsFactory.GetUserManagementService(); }
public void Setup() { _userManagementService = UserManagementServiceFactory.Create(); }