Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        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());
        }
Example #4
0
        public void TestCreateAndLoadUserGroup()
        {
            //given:
            User         user         = UserCreator.Create();
            UserGroupDto userGroupDto = new UserGroupDto("keine", "Gruppe 1", -10);
            Dictionary <User, UserGroupMembershipType> intitalUsers = new Dictionary <User, UserGroupMembershipType>();

            intitalUsers.Add(user, UserGroupMembershipType.Administrator);

            //when:
            UserGroup userGroup       = UserGroupService.Create(userGroupDto, intitalUsers, user);
            UserGroup actualUserGroup = UserGroupService.GetAll().First(x => x.BusinessId == userGroup.BusinessId);

            //then:
            Assert.AreEqual(userGroup, actualUserGroup);
            DtoAssert.AreEqual(userGroupDto, actualUserGroup.GetDto());
        }
Example #5
0
        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());
        }
Example #6
0
        public void TestUpdateUserProfile()
        {
            // given:
            User                       userToUpdate     = UserCreator.Create();
            UserContactDto             userContactDto   = new UserContactDto("*****@*****.**", "Straße", "1", "01234", "Stadt", Country.DE, "Unternehmen", "http://www.test.url", "phone", "privat", "mobile");
            UserDataDto                userDataDto      = new UserDataDto("neuerVorname", "neuerNachname", new DateTime(1950, 05, 05), "UserName");
            UserPaymentDto             userPaymentDto   = new UserPaymentDto("PayPal", true);
            EntityChangedDto           changeDto        = new EntityChangedDto(UserCreator.Create(), new DateTime(2017, 01, 01, 01, 02, 03));
            UserNotificationOptionsDto notificationsDto = UserNotificationOptionsDto.AllOff;

            // when:
            UserService.Update(userToUpdate, userContactDto, userDataDto, userPaymentDto, notificationsDto, changeDto);
            UserService.UserDao.FlushAndClear();
            User actualUser = UserService.GetById(userToUpdate.Id);

            // then:
            DtoAssert.AreEqual(userContactDto, actualUser.GetUserContactDto());
            DtoAssert.AreEqual(userDataDto, actualUser.GetUserDataDto());
            DtoAssert.AreEqual(notificationsDto, actualUser.GetNotificationOptions());

            actualUser.ChangedBy.Should().Be(changeDto.ChangedBy);
            actualUser.ChangedAt.Should().Be(changeDto.ChangedAt);
        }
Example #7
0
        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);
        }
Example #8
0
        public void TestUpdateUser()
        {
            // given:

            Service.UserService userService = new UserService();
            userService.UserDao = ContextRegistry.GetContext().GetObject <IUserDao>();

            Document document1    = DocumentCreator.Create();
            Document document2    = DocumentCreator.Create();
            Document document3    = DocumentCreator.Create();
            User     userToUpdate = UserCreator.Create(documents: new [] { document1, document2 });


            UploadedFile uploadedFile = new UploadedFile(new FileInfo("C:\\Temp\\passbild.png"));

            Mock <IDocumentRepository> fileServiceMock = new Mock <IDocumentRepository>();

            fileServiceMock.Setup(s => s.Create(uploadedFile)).Returns(document3);
            userService.DocumentRepository = fileServiceMock.Object;

            // when:
            // UserLoginDto userLoginDto = UserUtil.CreateUserLoginDto("neuernutzer", "anderesPasswort", false);
            UserContactDto userContactDto = new UserContactDto("*****@*****.**",
                                                               "Straße",
                                                               "1",
                                                               "01234",
                                                               "Stadt",
                                                               Country.DE,
                                                               "Unternehmen",
                                                               "http://www.test.url",
                                                               "phone",
                                                               "privat",
                                                               "mobile");
            const string      NEW_USERNAME      = "******";
            const string      NEW_PASSWORDHASH  = "andererPasswortHash";
            UserDataDto       userDataDto       = new UserDataDto("neuerVorname", "neuerNachname", new DateTime(2000, 02, 02), NEW_USERNAME);
            UserPaymentDto    userPaymentDto    = new UserPaymentDto("PayPal", true);
            UserPermissionDto userPermissionDto = UserCreator.CreateUserPermissionDto(new List <string>()
            {
                Roles.Administrator
            }, false);
            EntityChangedDto changeDto = new EntityChangedDto(UserCreator.Create(), new DateTime(2017, 01, 01, 01, 02, 03));

            UserNotificationOptionsDto userNotificationsDto = UserNotificationOptionsDto.AllOff;

            userService.Update(userToUpdate,
                               NEW_PASSWORDHASH,
                               userContactDto,
                               userDataDto,
                               userPaymentDto,
                               userNotificationsDto,
                               userPermissionDto,
                               new List <UploadedFile>()
            {
                uploadedFile
            },
                               new List <Document> {
                document2
            },
                               changeDto);
            userService.UserDao.FlushAndClear();

            User actualUser = UserService.GetById(userToUpdate.Id);

            // then:
            Assert.AreEqual(NEW_USERNAME, actualUser.UserName, "Der Nutzername wurde nicht korrekt übernommen.");
            Assert.AreEqual(NEW_PASSWORDHASH, actualUser.PasswordHash, "Das Passwort wurde nicht korrekt übernommen.");
            DtoAssert.AreEqual(userContactDto, actualUser.GetUserContactDto());
            DtoAssert.AreEqual(userDataDto, actualUser.GetUserDataDto());
            DtoAssert.AreEqual(userNotificationsDto, actualUser.GetNotificationOptions());
            DtoAssert.AreEqual(userPermissionDto, actualUser.GetUserPermissionDto());

            actualUser.Documents.Should().BeEquivalentTo(document1, document3);

            actualUser.ChangedBy.Should().Be(changeDto.ChangedBy);
            actualUser.ChangedAt.Should().Be(changeDto.ChangedAt);
        }