예제 #1
0
        public async Task Validate_when_user_is_admin_of_group()
        {
            // Arrange
            string userSub = Guid.NewGuid().ToString();
            var    user    = new User
            {
                FirstName = "Integration",
                LastName  = "Test",
                Sub       = userSub
            };

            var group = new Domain.Entities.Group {
                Admin = user, Name = "A group"
            };

            var userToGroup = new UserToGroup {
                User = user, Group = group
            };

            await _dbContext.Users.AddAsync(user);

            await _dbContext.Groups.AddAsync(group);

            await _dbContext.UsersToGroups.AddAsync(userToGroup);

            await _dbContext.SaveChangesAsync();

            var sut = new GetGroupMembersValidator(_dbContext);

            // Act
            bool isValid = await sut.IsValidAsync(new GetGroupMembers(userSub, group.Id));

            // Assert
            isValid.ShouldBeTrue();
        }
예제 #2
0
        public async Task Invalidate_request_when_no_user_found_by_sub(string sub)
        {
            // Arrange
            var sut = new GetGroupMembersValidator(_dbContext);

            // Act
            bool isValid = await sut.IsValidAsync(new GetGroupMembers(sub, Guid.NewGuid()));

            // Assert
            isValid.ShouldBeFalse();
        }
예제 #3
0
        public async Task Invalidate_when_group_does_not_exists()
        {
            // Arrange
            string userSub = Guid.NewGuid().ToString();
            var    user    = new User
            {
                FirstName = "Integration",
                LastName  = "Test",
                Sub       = userSub
            };

            await _dbContext.Users.AddAsync(user);

            await _dbContext.SaveChangesAsync();

            var sut = new GetGroupMembersValidator(_dbContext);

            // Act
            bool isValid = await sut.IsValidAsync(new GetGroupMembers(userSub, Guid.NewGuid()));

            // Assert
            isValid.ShouldBeFalse();
        }