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");
 }
 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");
 }
 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();
 }
 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);
 }
 public void Setup()
 {
     _userManagementService = UserManagementServiceFactory.Create();
 }
 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_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();
 }
 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");
 }
 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;
 }