- 为平台测试添加EntityFrameworkCore和Xunit引用 - 实现PlatformTestDb创建带审计字段自动填充的测试数据库 - 添加DictionaryConfiguration支持配置值获取测试 - 实现完整的密码强度验证规则 - 添加RAG问答全链路端到端测试 - 创建多个Stub服务用于解耦外部依赖测试 - 实现测试专用的当前用户上下文
37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using BuildFlow.Domain.Interfaces;
|
|
|
|
namespace BuildFlow.Rag.Tests.Stub;
|
|
|
|
/// <summary>
|
|
/// Stub IDocumentExtractorFactory + IDocumentExtractor:返回固定提取文本。
|
|
/// 绕过真实文档解析(PDF/Word/Html)。
|
|
/// </summary>
|
|
public sealed class StubDocumentExtractor : IDocumentExtractor
|
|
{
|
|
/// <summary>提取返回的固定文本。</summary>
|
|
public string ExtractedContent { get; init; } = "BuildFlow 使用 PostgreSQL + pgvector 作为向量数据库。.NET 10 模块化单体架构。";
|
|
|
|
/// <summary>提取返回的标题。</summary>
|
|
public string ExtractedTitle { get; init; } = "测试文档";
|
|
|
|
public IReadOnlyCollection<string> SupportedExtensions { get; init; } = ["md", "txt", "pdf", "docx"];
|
|
|
|
public Task<ExtractedDocument> ExtractAsync(string filePath, CancellationToken ct = default)
|
|
=> Task.FromResult(new ExtractedDocument
|
|
{
|
|
Content = ExtractedContent,
|
|
Title = ExtractedTitle,
|
|
SourcePath = filePath
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 工厂:统一返回 StubDocumentExtractor。
|
|
/// </summary>
|
|
public sealed class StubDocumentExtractorFactory : IDocumentExtractorFactory
|
|
{
|
|
public StubDocumentExtractor InnerExtractor { get; } = new();
|
|
|
|
public IDocumentExtractor GetExtractor(string fileNameOrExtension) => InnerExtractor;
|
|
}
|