核心功能: - 公告状态机(草稿/已发布/已撤销)支持发布、撤销和重新发布 - 发布者范围区分平台级和租户级公告 - 目标受众定向推送(全部租户/指定角色/指定用户) - 平台管理、租户管理和应用端查询API - 已读/未读管理和未读统计 技术实现: - CQRS+DDD架构,清晰的领域边界和事件驱动 - 查询性能优化:数据库端排序和限制,估算策略减少内存占用 - 并发控制:修复RowVersion配置(IsRowVersion→IsConcurrencyToken) - 完整的FluentValidation验证器和输入保护 测试验证: - 36个测试全部通过(27单元+9集成) - 性能测试达标(1000条数据<5秒) - 代码质量评级A(优秀) 文档: - 完整的ADR、API文档和迁移指南 - 交付报告和技术债务记录
47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
using Microsoft.Data.Sqlite;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using TakeoutSaaS.Infrastructure.App.Persistence;
|
|
|
|
namespace TakeoutSaaS.Integration.Tests.Fixtures;
|
|
|
|
public sealed class SqliteTestDatabase : IDisposable
|
|
{
|
|
private readonly SqliteConnection _connection;
|
|
private bool _initialized;
|
|
|
|
public SqliteTestDatabase()
|
|
{
|
|
_connection = new SqliteConnection("Filename=:memory:");
|
|
_connection.Open();
|
|
Options = new DbContextOptionsBuilder<TakeoutAppDbContext>()
|
|
.UseSqlite(_connection)
|
|
.EnableSensitiveDataLogging()
|
|
.Options;
|
|
}
|
|
|
|
public DbContextOptions<TakeoutAppDbContext> Options { get; }
|
|
|
|
public TakeoutAppDbContext CreateContext(long tenantId, long userId = 0)
|
|
{
|
|
EnsureCreated();
|
|
return new TakeoutAppDbContext(Options, new TestTenantProvider(tenantId), new TestCurrentUserAccessor(userId));
|
|
}
|
|
|
|
public void EnsureCreated()
|
|
{
|
|
if (_initialized)
|
|
{
|
|
return;
|
|
}
|
|
|
|
using var context = new TakeoutAppDbContext(Options, new TestTenantProvider(1));
|
|
context.Database.EnsureCreated();
|
|
_initialized = true;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_connection.Dispose();
|
|
}
|
|
}
|