- 添加HNSW向量索引提升检索性能 - 实现Hybrid检索模式支持向量和关键词双路召回 - 采用RRF算法融合多路召回结果 - 支持ParentChild分块模式的上下文回填 - 优化向量写入采用批量SQL操作提升性能 - 添加RAG PostgreSQL连接字符串配置 - 更新部署脚本增加PGVector集成测试 - 修正表名引用从document_chunks到b_document_chunks - 重构RagRetrievalService实现完整的检索流程 - 增加重排策略支持关键词和LLM重排 - 修改服务器部署地址配置
46 lines
1.7 KiB
C#
46 lines
1.7 KiB
C#
using BuildFlow.Shared.Domain.Errors;
|
||
using BuildFlow.Shared.Domain.Exceptions;
|
||
using FluentAssertions;
|
||
using IM.Application.Chat.Commands;
|
||
using IM.Application.Chat.Handlers;
|
||
using IM.Domain.Enums;
|
||
using IM.Infrastructure.Persistence;
|
||
using Microsoft.EntityFrameworkCore;
|
||
using Xunit;
|
||
|
||
namespace BuildFlow.IM.Tests.Chat;
|
||
|
||
/// <summary>
|
||
/// SetConversationMutedCommandHandler:成功置免打扰 / 参与者不存在抛 NotFound。
|
||
/// </summary>
|
||
public class SetConversationMutedCommandHandlerTests
|
||
{
|
||
private static readonly Guid UserId = Guid.Parse("22222222-2222-2222-2222-222222222222");
|
||
private static readonly Guid ConvId = Guid.Parse("11111111-1111-1111-1111-111111111111");
|
||
|
||
[Fact]
|
||
public async Task Sets_muted_for_participant()
|
||
{
|
||
await using var db = IMTestDb.Create();
|
||
db.Conversations.Add(ImTestData.BuildConversation(ConvId, ConversationTypeEnum.Private, (UserId, 0)));
|
||
await db.SaveChangesAsync();
|
||
|
||
var handler = new SetConversationMutedCommandHandler(db);
|
||
await handler.Handle(new SetConversationMutedCommand(ConvId, UserId, true), CancellationToken.None);
|
||
|
||
var p = await db.ConversationParticipants.FirstAsync(x => x.ConversationId == ConvId && x.UserId == UserId);
|
||
p.IsMuted.Should().BeTrue();
|
||
}
|
||
|
||
[Fact]
|
||
public async Task Throws_not_found_when_participant_missing()
|
||
{
|
||
await using var db = IMTestDb.Create();
|
||
var handler = new SetConversationMutedCommandHandler(db);
|
||
var act = async () => await handler.Handle(new SetConversationMutedCommand(ConvId, UserId, true), CancellationToken.None);
|
||
|
||
var ex = await act.Should().ThrowAsync<NotFoundException>();
|
||
ex.Which.Code.Should().Be(ErrorCode.NotFound);
|
||
}
|
||
}
|