feat(tests): 完成ArchitectureConfigurationTests测试用例开发

- 创建ArchitectureConfigurationTests.cs文件,包含12个测试用例
- 覆盖默认配置初始化、自定义配置替换、接口实现验证等场景
- 测试日志属性和架构属性的各种配置情况
- 验证实例间属性不共享的安全性
- [skip ci]
更新测试覆盖率从41%提升至42%,完成240个测试用例
This commit is contained in:
GeWuYou 2026-01-16 11:01:15 +08:00
parent de53fe5413
commit 82e3bd1ec2
2 changed files with 159 additions and 9 deletions

View File

@ -1,7 +1,8 @@
# GFramework.Core 模块测试覆盖详细清单
> **生成日期**: 2026-01-16
> **当前版本**: Core测试覆盖率 ~41%
> **最后更新**: 2026-01-16
> **当前版本**: Core测试覆盖率 ~42%
> **目标**: 提升Core模块测试覆盖率至 85%+
---
@ -57,11 +58,13 @@
**预计测试数**: 8-10 个
**实际测试数**: 12 个
**优先级**: 🔴 高
**创建路径**: `GFramework.Core.Tests/architecture/ArchitectureConfigurationTests.cs`
**状态**: ❌ 待创建
**状态**: ✅ 已创建
---
@ -754,9 +757,10 @@
## 🎯 目标达成路径
### 当前状态
- **现有测试数**: 228 个
- **测试覆盖率**: ~41%
- **缺失测试**: 180-236 个
- **现有测试数**: 240 个
- **测试覆盖率**: ~42%
- **缺失测试**: 168-224 个
- **已完成文件**: 1/26 (ArchitectureConfigurationTests.cs)
### 第一批完成后
- **预计测试数**: 228 + 53-67 = 281-295 个
@ -803,16 +807,17 @@
| 日期 | 操作 | 说明 |
|-----|------|------|
| 2026-01-16 | 初始创建 | 生成完整测试覆盖清单 |
| 2026-01-16 | 完成 ArchitectureConfigurationTests.cs | 创建了12个测试用例涵盖默认配置、自定义配置、接口实现验证等功能 |
| | | |
---
## 📌 待确认事项
- [ ] 确认优先级划分是否合理
- [ ] 确认执行计划是否可行
- [ ] 确认测试用例数量估算是否准确
- [ ] 确认测试隔离策略是否完整
- [x] 确认优先级划分是否合理
- [x] 确认执行计划是否可行
- [x] 确认测试用例数量估算是否准确
- [x] 确认测试隔离策略是否完整
---

View File

@ -0,0 +1,145 @@
using GFramework.Core.Abstractions.architecture;
using GFramework.Core.Abstractions.logging;
using GFramework.Core.Abstractions.properties;
using GFramework.Core.architecture;
using GFramework.Core.logging;
using NUnit.Framework;
namespace GFramework.Core.Tests.architecture;
[TestFixture]
public class ArchitectureConfigurationTests
{
private ArchitectureConfiguration? _configuration;
[SetUp]
public void SetUp()
{
_configuration = new ArchitectureConfiguration();
}
[Test]
public void Constructor_Should_Initialize_LoggerProperties_With_Default_Values()
{
Assert.That(_configuration, Is.Not.Null);
Assert.That(_configuration!.LoggerProperties, Is.Not.Null);
}
[Test]
public void LoggerProperties_Should_Use_ConsoleLoggerFactoryProvider_By_Default()
{
Assert.That(_configuration!.LoggerProperties.LoggerFactoryProvider,
Is.InstanceOf<ConsoleLoggerFactoryProvider>());
}
[Test]
public void LoggerProperties_Should_Use_Info_LogLevel_By_Default()
{
var consoleProvider = _configuration!.LoggerProperties.LoggerFactoryProvider
as ConsoleLoggerFactoryProvider;
Assert.That(consoleProvider, Is.Not.Null);
Assert.That(consoleProvider!.MinLevel, Is.EqualTo(LogLevel.Info));
}
[Test]
public void ArchitectureProperties_Should_Have_AllowLateRegistration_Set_To_False_By_Default()
{
Assert.That(_configuration!.ArchitectureProperties.AllowLateRegistration,
Is.False);
}
[Test]
public void ArchitectureProperties_Should_Have_StrictPhaseValidation_Set_To_True_By_Default()
{
Assert.That(_configuration!.ArchitectureProperties.StrictPhaseValidation,
Is.True);
}
[Test]
public void LoggerProperties_Should_Be_Replaced_With_Custom_Configuration()
{
var customProvider = new ConsoleLoggerFactoryProvider { MinLevel = LogLevel.Debug };
var customLoggerProperties = new LoggerProperties
{
LoggerFactoryProvider = customProvider
};
_configuration!.LoggerProperties = customLoggerProperties;
Assert.That(_configuration.LoggerProperties, Is.SameAs(customLoggerProperties));
Assert.That(_configuration.LoggerProperties.LoggerFactoryProvider,
Is.InstanceOf<ConsoleLoggerFactoryProvider>());
var currentProvider = _configuration.LoggerProperties.LoggerFactoryProvider
as ConsoleLoggerFactoryProvider;
Assert.That(currentProvider!.MinLevel, Is.EqualTo(LogLevel.Debug));
}
[Test]
public void ArchitectureProperties_Should_Be_Replaced_With_Custom_Configuration()
{
var customProperties = new ArchitectureProperties
{
AllowLateRegistration = true,
StrictPhaseValidation = false
};
_configuration!.ArchitectureProperties = customProperties;
Assert.That(_configuration.ArchitectureProperties, Is.SameAs(customProperties));
Assert.That(_configuration.ArchitectureProperties.AllowLateRegistration,
Is.True);
Assert.That(_configuration.ArchitectureProperties.StrictPhaseValidation,
Is.False);
}
[Test]
public void LoggerProperties_Should_Be_Modifiable_Independently()
{
var originalProvider = _configuration!.LoggerProperties.LoggerFactoryProvider
as ConsoleLoggerFactoryProvider;
originalProvider!.MinLevel = LogLevel.Debug;
var modifiedProvider = _configuration.LoggerProperties.LoggerFactoryProvider
as ConsoleLoggerFactoryProvider;
Assert.That(modifiedProvider!.MinLevel, Is.EqualTo(LogLevel.Debug));
}
[Test]
public void ArchitectureProperties_Should_Be_Modifiable_Independently()
{
_configuration!.ArchitectureProperties.AllowLateRegistration = true;
_configuration.ArchitectureProperties.StrictPhaseValidation = false;
Assert.That(_configuration.ArchitectureProperties.AllowLateRegistration,
Is.True);
Assert.That(_configuration.ArchitectureProperties.StrictPhaseValidation,
Is.False);
}
[Test]
public void ArchitectureConfiguration_Should_Implement_IArchitectureConfiguration_Interface()
{
Assert.That(_configuration, Is.InstanceOf<IArchitectureConfiguration>());
}
[Test]
public void New_Instance_Should_Not_Share_LoggerProperties_With_Other_Instance()
{
var config1 = new ArchitectureConfiguration();
var config2 = new ArchitectureConfiguration();
Assert.That(config1.LoggerProperties, Is.Not.SameAs(config2.LoggerProperties));
}
[Test]
public void New_Instance_Should_Not_Share_ArchitectureProperties_With_Other_Instance()
{
var config1 = new ArchitectureConfiguration();
var config2 = new ArchitectureConfiguration();
Assert.That(config1.ArchitectureProperties,
Is.Not.SameAs(config2.ArchitectureProperties));
}
}