public void TestUpdate() { // given: UserGroup userGroupToUpdate = UserGroupCreator.Create(); string expectedAdditionalInformations = "Keine"; string expectedName = "die firma"; int expectedAcceptedBalance = -20; UserGroupDto userGroupDtoForUpdate = new UserGroupDto(expectedAdditionalInformations, expectedName, expectedAcceptedBalance); User changedBy = UserCreator.Create("changed by"); DateTime changedAt = new DateTime(2016, 12, 22); EntityChangedDto entityChangedDto = new EntityChangedDto(changedBy, changedAt); // when: userGroupToUpdate.Update(userGroupDtoForUpdate, entityChangedDto); UserGroupDao.FlushAndClear(); UserGroup actualBrokerPool = UserGroupDao.Get(userGroupToUpdate.Id); // then: actualBrokerPool.GetDto().ShouldBeEquivalentTo(userGroupDtoForUpdate); actualBrokerPool.AdditionalInformations.ShouldBeEquivalentTo(expectedAdditionalInformations); actualBrokerPool.BalanceOverdraftLimit.ShouldBeEquivalentTo(expectedAcceptedBalance); actualBrokerPool.ChangedAt.Should().Be(changedAt); actualBrokerPool.ChangedBy.Should().Be(changedBy); actualBrokerPool.Name.ShouldBeEquivalentTo(expectedName); }
public void TestAreUsersAssigned() { // given: UserGroup userGroup = UserGroupCreator.Create(); User user = UserCreator.Create("ein nutzer"); UserGroupDao.Save(new UserGroupMembership(userGroup, user, UserGroupMembershipType.Member, new EntityCreatedDto(user, DateTime.Now))); // when: bool actualAreUsersAssigned = UserGroupDao.AreUsersAssigned(userGroup); // then: actualAreUsersAssigned.Should().BeTrue(); }
public void TestRequestMembership() { User user1 = UserCreator.Create(); UserGroup userGroup = UserGroupCreator.Create(); UserGroupService.RequestMembership(userGroup, user1, ""); List <UserGroupMembership> users = UserGroupService.FindMembershipsByUser(PageRequest.All, user1, new List <UserGroupMembershipType> { UserGroupMembershipType.Request }).ToList(); UserGroupMembership membership = users.FirstOrDefault(); Assert.AreEqual(1, users.Count); Assert.AreEqual(UserGroupMembershipType.Request, membership.MembershipType); }
public void TestInvite() { //given User user = UserCreator.Create(); User user2 = UserCreator.Create(); UserGroup userGroup = UserGroupCreator.Create(); UserGroupService.Invite(userGroup, user2, user, ""); UserGroupMembership invitations = UserGroupService.FindMembershipsByUser(PageRequest.All, user2, new List <UserGroupMembershipType> { UserGroupMembershipType.Invited }) .FirstOrDefault(); Assert.AreEqual(UserGroupMembershipType.Invited, invitations.MembershipType); }
public void TestAddMembers() { //given: User user1 = UserCreator.Create(); User user2 = UserCreator.Create(); UserGroup userGroup = UserGroupCreator.Create("", "Gruppe 1"); Dictionary <User, UserGroupMembershipType> users = new Dictionary <User, UserGroupMembershipType>(); users.Add(user1, UserGroupMembershipType.Administrator); users.Add(user2, UserGroupMembershipType.Member); //when: IList <UserGroupMembership> userGroupMemberships = UserGroupService.AddMembers(userGroup, users, user1); //Then: Assert.AreEqual(2, userGroupMemberships.Count); }
public void TestAreUsersAssigned() { //given User user1 = UserCreator.Create(); UserGroup userGroup = UserGroupCreator.Create("", "Gruppe1"); UserGroup userGroup2 = UserGroupCreator.Create(); Dictionary <User, UserGroupMembershipType> users = new Dictionary <User, UserGroupMembershipType>(); users.Add(user1, UserGroupMembershipType.Administrator); //when: UserGroupService.AddMembers(userGroup, users, user1); //then: Assert.IsTrue(UserGroupService.AreUsersAssigned(userGroup)); Assert.IsFalse(UserGroupService.AreUsersAssigned(userGroup2)); }
public void TestFindMembershipByUser() { //given: User user1 = UserCreator.Create(); User user2 = UserCreator.Create(); User user3 = UserCreator.Create(); UserGroup userGroup1 = UserGroupCreator.Create(); UserGroup userGroup2 = UserGroupCreator.Create(); Dictionary <User, UserGroupMembershipType> users1 = new Dictionary <User, UserGroupMembershipType>(); users1.Add(user1, UserGroupMembershipType.Administrator); users1.Add(user2, UserGroupMembershipType.Member); users1.Add(user3, UserGroupMembershipType.Invited); Dictionary <User, UserGroupMembershipType> users2 = new Dictionary <User, UserGroupMembershipType>(); users2.Add(user2, UserGroupMembershipType.Administrator); users2.Add(user3, UserGroupMembershipType.Request); UserGroupService.AddMembers(userGroup1, users1, user1); UserGroupService.AddMembers(userGroup2, users2, user2); //when: List <UserGroupMembership> user1Memberships = UserGroupService.FindMembershipsByUser(PageRequest.All, user1).ToList(); List <UserGroupMembership> user2Memberships = UserGroupService.FindMembershipsByUser(PageRequest.All, user2, new List <UserGroupMembershipType> { UserGroupMembershipType.Member }).ToList(); List <UserGroupMembership> user3Memberships = UserGroupService.FindMembershipsByUser(PageRequest.All, user3, new List <UserGroupMembershipType> { UserGroupMembershipType.Request, UserGroupMembershipType.Invited }).ToList(); //then: Assert.AreEqual(1, user1Memberships.Count); Assert.AreEqual(1, user2Memberships.Count); Assert.AreEqual(2, user3Memberships.Count); }
public void TestIsUserSolvent2() { //given: User user = UserCreator.Create(); User user2 = UserCreator.Create(); UserGroup userGroup = UserGroupCreator.Create("", "Gruppe 1", null); Dictionary <User, UserGroupMembershipType> inititalUsers = new Dictionary <User, UserGroupMembershipType>(); inititalUsers.Add(user, UserGroupMembershipType.Administrator); inititalUsers.Add(user2, UserGroupMembershipType.Member); IList <UserGroupMembership> userGroupMemberships = UserGroupService.AddMembers(userGroup, inititalUsers, user); UserGroupMembership userGroupMembership = UserGroupService.FindMembershipsByUser(PageRequest.All, user).FirstOrDefault(); UserGroupMembership user2GroupMembership = UserGroupService.FindMembershipsByUser(PageRequest.All, user2).FirstOrDefault(); //when: userGroupMembership.Account.Book(-30); user2GroupMembership.Account.Book(-10); //then: Assert.IsTrue(UserGroupService.IsUserSolvent(userGroupMembership)); Assert.IsTrue(UserGroupService.IsUserSolvent(user2GroupMembership)); }