- 为平台测试添加EntityFrameworkCore和Xunit引用 - 实现PlatformTestDb创建带审计字段自动填充的测试数据库 - 添加DictionaryConfiguration支持配置值获取测试 - 实现完整的密码强度验证规则 - 添加RAG问答全链路端到端测试 - 创建多个Stub服务用于解耦外部依赖测试 - 实现测试专用的当前用户上下文
36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using BuildFlow.Domain.Interfaces;
|
|
|
|
namespace BuildFlow.Rag.Tests.Stub;
|
|
|
|
/// <summary>
|
|
/// Stub IFileStorageClient:Upload 记录调用,Download 返回内存流。
|
|
/// 绕过真实对象存储(RustFS/MinIO)。
|
|
/// </summary>
|
|
public sealed class StubFileStorageClient : IFileStorageClient
|
|
{
|
|
/// <summary>记录所有上传调用 (bucket, objectKey, size)。</summary>
|
|
public List<(string Bucket, string ObjectKey, long Size)> Uploads { get; } = [];
|
|
|
|
/// <summary>Download 返回的内容(UTF-8 字节)。默认空数组。</summary>
|
|
public byte[] DownloadContent { get; init; } = [];
|
|
|
|
public Task UploadAsync(
|
|
string bucket,
|
|
string objectKey,
|
|
Stream content,
|
|
string contentType,
|
|
string? authToken,
|
|
CancellationToken ct = default)
|
|
{
|
|
Uploads.Add((bucket, objectKey, content.Length));
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
public Task<Stream> DownloadAsync(
|
|
string bucket,
|
|
string objectKey,
|
|
string? authToken,
|
|
CancellationToken ct = default)
|
|
=> Task.FromResult<Stream>(new MemoryStream(DownloadContent));
|
|
}
|