Files
Hua.Todo/test/Hua.Todo.Host.Tests/CloudSync/CloudSyncEndpointRegistrationTests.cs
ShaoHua 4fe0b5a963 feat: 完成云同步、语音控制与多平台扩展基础架构搭建
本次提交完成了项目核心基础架构升级:
1. 新增动态API中间件与权限控制系统,支持匿名/鉴权接口分离
2. 搭建云同步服务体系,包含认证、任务同步、安全策略等核心模块
3. 实现语音控制全链路,从STT/意图解析到命令执行
4. 新增任务类型、附件实体与相关仓储接口
5. 重构前端配置与代理规则,统一后端端口为5057
6. 新增多平台测试项目与CI脚本优化
7. 完善项目文档与代码注释规范

移除了旧版迁移文件与冗余代理配置,调整项目结构适配跨平台部署需求。
2026-06-21 03:26:04 +08:00

83 lines
2.5 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Hua.Todo.Application.Common;
using Hua.Todo.Application.Repositories;
using Hua.Todo.Application.Services.CloudSync.Services;
using Hua.Todo.HttpApi.AspNetCore.CloudSync.Services;
using Xunit;
namespace Hua.Todo.Host.Tests.CloudSync;
/// <summary>
/// 云同步核心服务 DI 注册集成测试。
/// 模拟 Host 的完整 DI 链路:AddApplicationServices + AddCloudSyncServer
/// 验证所有关键服务可被正确解析。
/// </summary>
public class CloudSyncEndpointRegistrationTests : IDisposable
{
private readonly SqliteConnection _connection;
private readonly ServiceProvider _provider;
public CloudSyncEndpointRegistrationTests()
{
// 使用共享缓存的 SQLite 内存数据库
_connection = new SqliteConnection("Data Source=CloudSyncRegTests;Mode=Memory;Cache=Shared");
_connection.Open();
var services = new ServiceCollection();
services.AddLogging();
// 模拟 Host 的完整 DI 链路
services.AddApplicationServices("Data Source=CloudSyncRegTests;Mode=Memory;Cache=Shared");
services.AddCloudSyncServer();
_provider = services.BuildServiceProvider();
// 确保数据库表已创建
using var scope = _provider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<TodoDbContext>();
db.Database.EnsureCreated();
}
[Fact]
public void ResolveCloudProbeService_ShouldSucceed()
{
var service = _provider.GetRequiredService<CloudProbeService>();
Assert.NotNull(service);
}
[Fact]
public void ResolveCloudAuthService_ShouldSucceed()
{
var service = _provider.GetRequiredService<CloudAuthService>();
Assert.NotNull(service);
}
[Fact]
public void ResolveCloudTaskSyncService_ShouldSucceed()
{
var service = _provider.GetRequiredService<CloudTaskSyncService>();
Assert.NotNull(service);
}
[Fact]
public void ResolveSecurityPolicyService_ShouldSucceed()
{
var service = _provider.GetRequiredService<SecurityPolicyService>();
Assert.NotNull(service);
}
[Fact]
public void ResolveCloudAdminService_ShouldSucceed()
{
var service = _provider.GetRequiredService<CloudAdminService>();
Assert.NotNull(service);
}
public void Dispose()
{
_provider.Dispose();
_connection.Dispose();
}
}