public void TestUpdateUserProfileProperties() { // given: User user = UserCreator.Create(); User userToUpdate = UserDao.Get(user.Id); UserContactDto userContactDto = UserCreator.CreateUserContactDto("*****@*****.**", "Nürnberger Ei", "0", "01067", "Dresden", Country.DE, "Nürnberger Eieruhren GmbH", "http://www.nuernberger-eier.de", "phone", "privat", "mobile"); UserDataDto userDataDto = UserCreator.CreateUserDataDto("neuerVorname", "neuerNachname", new DateTime(1990, 01, 03), "UserName"); UserPaymentDto userPaymentDto = new UserPaymentDto("paypal", true); UserNotificationOptionsDto notificationsDto = UserNotificationOptionsDto.AllOn; User changedBy = UserCreator.Create(); EntityChangedDto entityChangedDto = new EntityChangedDto(changedBy, new DateTime(2017, 01, 01, 01, 01, 01)); // when: userToUpdate.Update(userContactDto, userDataDto, userPaymentDto, notificationsDto, entityChangedDto); UserDao.FlushAndClear(); User actualUser = UserDao.Get(userToUpdate.Id); // then: DtoAssert.AreEqual(userContactDto, actualUser.GetUserContactDto()); DtoAssert.AreEqual(userDataDto, actualUser.GetUserDataDto()); actualUser.ChangedBy.Should().Be(entityChangedDto.ChangedBy); actualUser.ChangedAt.Should().Be(entityChangedDto.ChangedAt); }
public void TestUpdateUserAllProperties() { // given: User user = UserCreator.Create(); User userToUpdate = UserDao.Get(user.Id); UserContactDto userContactDto = UserCreator.CreateUserContactDto("*****@*****.**", "Nürnberger Ei", "0", "01067", "Dresden", Country.DE, "Nürnberger Eieruhren GmbH", "http://www.nuernberger-eier.de", "phone", "privat", "mobile"); string username = "******"; UserDataDto userDataDto = UserCreator.CreateUserDataDto("neuerVorname", "neuerNachname", null, username); User changedBy = UserCreator.Create(); EntityChangedDto entityChangedDto = new EntityChangedDto(changedBy, new DateTime(2017, 01, 01, 01, 01, 01)); UserPermissionDto userPermissionDto = new UserPermissionDto(new List <string> { Roles.Administrator }, true); UserNotificationOptionsDto notificationsDto = UserNotificationOptionsDto.AllOn; string passwordHash = "newPasswordhash"; List <Document> documents = new List <Document> { DocumentCreator.Create() }; UserPaymentDto userPaymentDto = new UserPaymentDto("", false); // when: userToUpdate.Update(passwordHash, userContactDto, userDataDto, userPaymentDto, notificationsDto, userPermissionDto, documents, entityChangedDto); UserDao.FlushAndClear(); User actualUser = UserDao.Get(userToUpdate.Id); // then: DtoAssert.AreEqual(userContactDto, actualUser.GetUserContactDto()); DtoAssert.AreEqual(userDataDto, actualUser.GetUserDataDto()); DtoAssert.AreEqual(notificationsDto, actualUser.GetNotificationOptions()); DtoAssert.AreEqual(userPermissionDto, actualUser.GetUserPermissionDto()); actualUser.ChangedBy.Should().Be(entityChangedDto.ChangedBy); actualUser.ChangedAt.Should().Be(entityChangedDto.ChangedAt); actualUser.UserName.Should().Be(username); actualUser.PasswordHash.Should().Be(passwordHash); actualUser.Documents.ShouldBeEquivalentTo(documents); }
public void TestCreateAndLoadUser() { // when: UserContactDto updateUserContactDto = UserCreator.CreateUserContactDto("*****@*****.**", "Teststraße", "?", "01234", "Teststadt", Country.DE, "Testunternehmen", "http://www.url.test", "phone", "privat", "mobile"); UserDataDto updateUserDataDto = UserCreator.CreateUserDataDto("Vorname", "Nachname", new DateTime(1984, 04, 26), "UserName"); UserPermissionDto updateUserPermissionDto = UserCreator.CreateUserPermissionDto(new List <string>() { Roles.Administrator }, true); UserPaymentDto userPaymentDto = UserCreator.CreateUserPaymentDto("PayPal", true); EntityCreatedDto creationDto = new EntityCreatedDto(UserCreator.Create(), new DateTime(2016, 12, 12, 15, 30, 0)); User user = UserService.Create("passwordHash", updateUserContactDto, updateUserDataDto, userPaymentDto, updateUserPermissionDto, creationDto); User actualUser = UserService.GetByBusinessId(user.BusinessId); // then: Assert.AreEqual(user, actualUser); DtoAssert.AreEqual(updateUserContactDto, actualUser.GetUserContactDto()); DtoAssert.AreEqual(updateUserDataDto, actualUser.GetUserDataDto()); DtoAssert.AreEqual(updateUserPermissionDto, actualUser.GetUserPermissionDto()); actualUser.CreatedBy.Should().Be(creationDto.CreatedBy); actualUser.CreatedAt.Should().Be(creationDto.CreatedAt); }