Esempio n. 1
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);
     _userManagementService.Create(Guid.NewGuid(), "Name", "*****@*****.**", "password", "Job Title");
 }
Esempio n. 2
0
 public void Edit_EmailGreaterThan256Characters_DomainValidationExceptionThrown()
 {
     var id = Guid.NewGuid();
     var user = _userManagementService.Create(id, "Chris", "*****@*****.**", "p'ssw0rd", "Job Title");
     var userAccountRepositoryStub = MockRepository.GenerateStub<IUserAccountRepository>();
     userAccountRepositoryStub.Stub(x => x.GetById(id)).Return(user);
     _userManagementService = UserManagementServiceFactory.Create(userAccountRepositoryStub);
     _userManagementService.Edit(id, "Chris", String.Format("chris@{0}", GreaterThan256Characters), "Job Title");
 }
Esempio n. 3
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");
     userRepositoryMock.VerifyAllExpectations();
 }
Esempio n. 4
0
 public void Login_ValidUserWithValidPasswordSupplied_LoginSuccess()
 {
     var emailAddress = "*****@*****.**";
     var user = _userManagementService.Create(Guid.NewGuid(), "Chris", emailAddress, "p'ssw0rd", "Job Title");
     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. 5
0
 public void Setup()
 {
     _userManagementService = UserManagementServiceFactory.Create();
 }
Esempio n. 6
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. 7
0
 public void Edit_SuccessfullyEditUser_UserEdited()
 {
     var id = Guid.NewGuid();
     var user = _userManagementService.Create(id, "Chris", "*****@*****.**", "p'ssw0rd", "Job Title");
     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");
     userAccountRepositoryMock.VerifyAllExpectations();
 }
Esempio n. 8
0
 public void Edit_NonUniqueEmailSupplied_DomainValidationExceptionThrown()
 {
     var id = Guid.NewGuid();
     var user = _userManagementService.Create(id, "Chris", "*****@*****.**", "p'ssw0rd", "Job Title");
     var user2 = _userManagementService.Create(Guid.NewGuid(), "Chris2", "*****@*****.**", "p'ssw0rd", "Job Title");
     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");
 }
Esempio n. 9
0
 public void Edit_InvalidIdSupplied_ArgumentExceptionThrown()
 {
     var id = Guid.NewGuid();
     var user = _userManagementService.Create(id, "Chris", "*****@*****.**", "p'ssw0rd", "Job Title");
     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");
 }
 public UserManagementController(UserManagementService userManagementService)
 {
     _userManagementService = userManagementService;
 }