- 添加HNSW向量索引提升检索性能 - 实现Hybrid检索模式支持向量和关键词双路召回 - 采用RRF算法融合多路召回结果 - 支持ParentChild分块模式的上下文回填 - 优化向量写入采用批量SQL操作提升性能 - 添加RAG PostgreSQL连接字符串配置 - 更新部署脚本增加PGVector集成测试 - 修正表名引用从document_chunks到b_document_chunks - 重构RagRetrievalService实现完整的检索流程 - 增加重排策略支持关键词和LLM重排 - 修改服务器部署地址配置
48 lines
1.9 KiB
C#
48 lines
1.9 KiB
C#
using BuildFlow.Shared.Domain.Errors;
|
||
using BuildFlow.Shared.Domain.Exceptions;
|
||
using FluentAssertions;
|
||
using IM.Application.Chat.Handlers;
|
||
using IM.Application.Chat.Queries;
|
||
using IM.Domain.Enums;
|
||
using IM.Infrastructure.Persistence;
|
||
using Xunit;
|
||
|
||
namespace BuildFlow.IM.Tests.Chat;
|
||
|
||
/// <summary>
|
||
/// GetConversationParticipantIdsQueryHandler:成员返回参与者 ID 列表;请求者非参与者拒绝(Forbidden)。
|
||
/// </summary>
|
||
public class GetConversationParticipantIdsQueryHandlerTests
|
||
{
|
||
private static readonly Guid UserId = Guid.Parse("22222222-2222-2222-2222-222222222222");
|
||
private static readonly Guid Other = Guid.Parse("33333333-3333-3333-3333-333333333333");
|
||
private static readonly Guid ConvId = Guid.Parse("11111111-1111-1111-1111-111111111111");
|
||
|
||
[Fact]
|
||
public async Task Returns_participant_ids_for_member()
|
||
{
|
||
await using var db = IMTestDb.Create();
|
||
db.Conversations.Add(ImTestData.BuildConversation(ConvId, ConversationTypeEnum.Private, (UserId, 0), (Other, 0)));
|
||
await db.SaveChangesAsync();
|
||
|
||
var handler = new GetConversationParticipantIdsQueryHandler(db);
|
||
var result = await handler.Handle(new GetConversationParticipantIdsQuery(ConvId, UserId), CancellationToken.None);
|
||
|
||
result.Should().BeEquivalentTo(new[] { UserId, Other });
|
||
}
|
||
|
||
[Fact]
|
||
public async Task Throws_forbidden_when_requester_not_participant()
|
||
{
|
||
await using var db = IMTestDb.Create();
|
||
db.Conversations.Add(ImTestData.BuildConversation(ConvId, ConversationTypeEnum.Private, (Other, 0)));
|
||
await db.SaveChangesAsync();
|
||
|
||
var handler = new GetConversationParticipantIdsQueryHandler(db);
|
||
var act = async () => await handler.Handle(new GetConversationParticipantIdsQuery(ConvId, UserId), CancellationToken.None);
|
||
|
||
var ex = await act.Should().ThrowAsync<UnauthorizedException>();
|
||
ex.Which.Code.Should().Be(ErrorCode.Forbidden);
|
||
}
|
||
}
|