Пример #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);
        }
Пример #2
0
        public void TestUserContactDto()
        {
            UserContactDto userContactDto1 = new UserContactDto("*****@*****.**", "Straße-des-1.", "1", "01111", "Ort 1", Country.DE, "Unternehmen 1", "http://www.1.de", "0123/456789", "0123/4567890", "0151/123456");
            UserContactDto userContactDto2 = new UserContactDto("*****@*****.**", "Straße-des-2.", "2", "02222", "Ort 2", Country.AT, "Unternehmen 2", "http://www.2.de", "0223/456789", "0223/4567890", "0251/123456");

            DtoAssert.TestEqualsAndGetHashCode(userContactDto1, userContactDto2);
        }
Пример #3
0
        public void TestUserDataDto()
        {
            UserDataDto userDataDto      = new UserDataDto(null, null, null, null);
            UserDataDto otherUserDataDto = new UserDataDto("Vorname", "Nachname", new DateTime(2000, 01, 01), "UserName");

            DtoAssert.TestEqualsAndGetHashCode(userDataDto, otherUserDataDto);
        }
Пример #4
0
        public void TestProposedUserDataDto()
        {
            ProposedUserDataDto userDataDto      = new ProposedUserDataDto(null, null, null, Salutation.Mister, null);
            ProposedUserDataDto otherUserDataDto = new ProposedUserDataDto("Vorname", "Nachname", "Titel", Salutation.Miss, new DateTime(1970, 07, 07));

            DtoAssert.TestEqualsAndGetHashCode(userDataDto, otherUserDataDto);
        }
Пример #5
0
        public void TestEqualsAndGetHashCodeFromDto()
        {
            // given:
            UserGroupDto firstDto  = new UserGroupDto("Keine", "der Name 1", -10);
            UserGroupDto secondDto = new UserGroupDto(null, "der name 2", -20);

            // when, then:
            DtoAssert.TestEqualsAndGetHashCode(firstDto, secondDto);
        }
Пример #6
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);
        }
Пример #7
0
        public void TestUserPermissionsDto()
        {
            UserPermissionDto userPermissionDto1 = new UserPermissionDto(new List <string>()
            {
                Roles.Administrator
            }, true);
            UserPermissionDto userPermissionDto2 = new UserPermissionDto(new List <string>()
            {
                Roles.Member
            }, false);

            DtoAssert.TestEqualsAndGetHashCode(userPermissionDto1, userPermissionDto2);
        }
Пример #8
0
        public void TestDto()
        {
            // given:
            User user      = new User();
            User otherUser = new User();

            // when:
            EntityCreatedDto entityCreatedDto      = new EntityCreatedDto(user, new DateTime(2017, 1, 1));
            EntityCreatedDto otherEntityCreatedDto = new EntityCreatedDto(otherUser, new DateTime(2017, 1, 11));

            // then:
            DtoAssert.TestEqualsAndGetHashCode(entityCreatedDto, otherEntityCreatedDto);
        }
Пример #9
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());
        }
Пример #10
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());
        }
Пример #11
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());
        }
Пример #12
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);
        }
Пример #13
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);
        }
Пример #14
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);
        }