private Group CreateTestGroup(RockContext rockContext, ElevatedSecurityLevel elevatedSecurityLevel) { var groupGuid = Guid.NewGuid(); var groupTypeGuid = Guid.NewGuid(); var group = new Group { Name = $"Test Group {groupGuid}", IsSecurityRole = true, Guid = groupGuid, ElevatedSecurityLevel = elevatedSecurityLevel, GroupType = new GroupType { Name = $"Test Group Type {groupTypeGuid}", Guid = groupTypeGuid, }, }; var groupService = new GroupService(rockContext); groupService.Add(group); rockContext.SaveChanges(); var groupTypeRole = new GroupTypeRole { Name = "Test Role", GroupTypeId = group.GroupTypeId }; var groupTypeRoleService = new GroupTypeRoleService(rockContext); groupTypeRoleService.Add(groupTypeRole); rockContext.SaveChanges(); return(group); }