Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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));
        }
Esempio n. 7
0
        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, "*****@*****.**")));
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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();
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
 public void Setup()
 {
     _userManagementService = UserManagementServiceFactory.Create();
 }