public void TestGetUserByBusinessId() { // given: ProposedUser user = ProposedUserCreator.CreateProposedUser(); // when: ProposedUser actualUser = ProposedUserDao.GetByBusinessId(user.BusinessId); // then: Assert.AreEqual(user, actualUser); }
public void TestGetUserByUserName() { // given: ProposedUser user = ProposedUserCreator.CreateProposedUser(); // when: ProposedUser actualUser = ProposedUserDao.FindByUserName(user.UserName); // then: Assert.AreEqual(user, actualUser); }
public void Update(ProposedUser user, string username, ProposedUserDataDto proposedUserDataDto, ProposedUserContactDto proposedUserContactDto, EntityChangedDto entityChangedDto) { Require.NotNull(user, "user"); Require.NotNullOrWhiteSpace(username, "username"); Require.NotNull(proposedUserDataDto, "proposedUserDataDto"); Require.NotNull(proposedUserContactDto, "proposedUserContactDto"); Require.NotNull(entityChangedDto, "entityChangedDto"); user.Update(username, proposedUserDataDto, proposedUserContactDto, entityChangedDto); }
public ProposedUser Create(string userName, ProposedUserDataDto proposedUserDataDto, ProposedUserContactDto proposedUserContactDto, EntityCreatedDto entityCreatedDto) { Require.NotNullOrWhiteSpace(userName, nameof(userName)); Require.NotNull(proposedUserDataDto, nameof(proposedUserDataDto)); Require.NotNull(proposedUserContactDto, nameof(proposedUserContactDto)); Require.NotNull(entityCreatedDto, nameof(entityCreatedDto)); ProposedUser user = new ProposedUser(userName, proposedUserDataDto, proposedUserContactDto, entityCreatedDto); return(ProposedUserDao.Save(user)); }
public void TestDeleteUser() { //given: ProposedUser user = ProposedUserCreator.CreateProposedUser(); // when: ProposedUser actualUser = ProposedUserDao.Get(user.Id); ProposedUserDao.Delete(actualUser); ProposedUserDao.FlushAndClear(); // then: Exception Assert.Throws <ObjectNotFoundException>(() => ProposedUserDao.Get(user.Id)); }
public ProposedUser Create(string username, ProposedUserDataDto proposedUserDataDto, ProposedUserContactDto proposedUserContactDto, EntityCreatedDto entityChangedDto, bool persist = true) { ProposedUser user = new ProposedUser(username, proposedUserDataDto, proposedUserContactDto, entityChangedDto); if (persist) { ProposedUserDao.Save(user); ProposedUserDao.Flush(); } return(user); }
public ProposedUser CreateProposedUser(string username = null, string email = "*****@*****.**", string lastname = NACHNAME_CONST, Salutation salutation = Salutation.Mister, string title = null, string firstname = VORNAME_CONST, DateTime?birthday = null, string street = STREET_CONST, string streetNumber = STREET_NUMBER_CONST, string postalCode = POSTALCODE_CONST, string city = CITY_CONST, Country countryTwoLetterIsoCode = COUNTRY_CONST, string company = COMPANY_CONST, string url = URL_CONST, string phone = null, string phonePrivate = null, string mobile = null, string fax = null, User createdBy = null, bool persist = true) { if (username == null) { username = GetRandomString(10); } if (firstname == VORNAME_CONST) { firstname = firstname + GetRandomString(4); } ProposedUserDataDto proposedUserDataDto = CreateProposedUserDataDto(firstname, lastname, salutation, title, birthday); ProposedUserContactDto proposedUserContactDto = CreateProposedUserContactDto(email, company, street, streetNumber, postalCode, city, countryTwoLetterIsoCode, url, phone, phonePrivate, mobile, fax); if (createdBy == null) { createdBy = UserCreator.Create(); } EntityCreatedDto entityCreatedDto = new EntityCreatedDto(createdBy, DateTime.Now); ProposedUser user = Create(username, proposedUserDataDto, proposedUserContactDto, entityCreatedDto, persist); return(user); }
public void TestCreateAndLoadProposedUser() { // when: ProposedUserContactDto updatedProposedUserContactDto = ProposedUserCreator.CreateProposedUserContactDto("*****@*****.**", "Testunternehmen", "Teststraße", "?", "01234", "Teststadt", Country.DE, "http://www.url.test", "phone", "privat", "mobile", "fax"); ProposedUserDataDto updatedProposedUserDataDto = ProposedUserCreator.CreateProposedUserDataDto("Vorname", "Nachname", Salutation.Mister, "Titel", new DateTime(1980, 01, 02)); EntityCreatedDto creationDto = new EntityCreatedDto(UserCreator.Create(), new DateTime(2016, 12, 12, 15, 30, 0)); ProposedUser user = ProposedUserService.Create("testNutzer", updatedProposedUserDataDto, updatedProposedUserContactDto, creationDto); ProposedUser actualUser = ProposedUserService.GetByBusinessId(user.BusinessId); // then: Assert.AreEqual(user, actualUser); DtoAssert.AreEqual(updatedProposedUserDataDto, actualUser.GetUserDataDto()); DtoAssert.AreEqual(updatedProposedUserContactDto, actualUser.GetUserContactDto()); }
public void TestUpdateProposedUser() { ProposedUser user = ProposedUserCreator.CreateProposedUser(); ProposedUser userToUpdate = ProposedUserDao.Get(user.Id); ProposedUserDataDto proposedUserDataDto = ProposedUserCreator.CreateProposedUserDataDto("neuerVorname", "neuerNachname", Salutation.Mister, "titel", new DateTime(1990, 09, 09)); ProposedUserContactDto proposedUserContactDto = ProposedUserCreator.CreateProposedUserContactDto("*****@*****.**", "Nürnberger Eieruhren GmbH", "Nürnberger Ei", "0", "01067", "Dresden", Country.DE, "http://www.nuernberger-eier.de", "phone", "privat", "mobile", "fax"); userToUpdate.Update(userToUpdate.UserName, proposedUserDataDto, proposedUserContactDto, new EntityChangedDto(UserCreator.Create(), DateTime.Now)); ProposedUserDao.FlushAndClear(); ProposedUser actualUser = ProposedUserDao.Get(userToUpdate.Id); DtoAssert.AreEqual(proposedUserDataDto, actualUser.GetUserDataDto()); DtoAssert.AreEqual(proposedUserContactDto, actualUser.GetUserContactDto()); }
public void TestSaveAndLoad() { // given : UserGroup userGroup = UserGroupCreator.Create(); ProposedUserDataDto proposedUserDataDto = new ProposedUserDataDto("Beantragter", "Nutzer", "Prof. Dr.", Salutation.Mister, new DateTime(2000, 2, 20)); ProposedUserContactDto proposedUserContactDto = new ProposedUserContactDto("*****@*****.**", "Straße", "1", "01234", "Stadt", Country.DE, "queo", "http://www.queo.de", "0123-456789", "0123-0123456", "0151-123456"); EntityCreatedDto entityCreatedDto = new EntityCreatedDto(UserCreator.Create(), new DateTime(2017, 01, 01, 01, 01, 01)); ProposedUser user = new ProposedUser("proposedUser", proposedUserDataDto, proposedUserContactDto, entityCreatedDto); // when: ProposedUserDao.Save(user); ProposedUserDao.FlushAndClear(); ProposedUser actualUser = ProposedUserDao.Get(user.Id); // then: Assert.AreEqual(user, actualUser); actualUser.GetUserContactDto().Should().Be(proposedUserContactDto); actualUser.GetUserDataDto().Should().Be(proposedUserDataDto); actualUser.CreatedAt.Should().Be(entityCreatedDto.CreatedAt); actualUser.CreatedBy.Should().Be(entityCreatedDto.CreatedBy); actualUser.ChangedBy.Should().BeNull(); actualUser.ChangedAt.Should().NotHaveValue(); }
public void Delete(ProposedUser user) { Require.NotNull(user, nameof(user)); ProposedUserDao.Delete(user); }
public ActionResult Create(UserCreateCommand userCreateCommand, User currentUser, ProposedUser proposedUser) { Require.NotNull(userCreateCommand, "userCreateCommand"); if (ModelState.IsValid) { IdentityResult identityResult = UserManager.PasswordValidator.ValidateAsync(userCreateCommand.Password).Result; if (identityResult.Succeeded) { string passwordHash = UserManager.PasswordHasher.HashPassword(userCreateCommand.Password); UserService.Create(passwordHash, userCreateCommand.UserContactDto, userCreateCommand.UserDataDto, userCreateCommand.UserPaymentDto, userCreateCommand.UserPermissionDto, new EntityCreatedDto(currentUser, DateTime.Now)); if (proposedUser != null) { ProposedUserService.Delete(proposedUser); } return(RedirectToAction("Index", "UserAdministration")); } AddErrors(identityResult); } UserCreateViewModel userCreateViewModel = new UserCreateViewModel(Roles.AllRoles, userCreateCommand, UserGroupService.GetAll(), proposedUser); return(View(userCreateViewModel)); }