- 将流程改为 OMRON FINS + TCP 双扫码 + SFTP 文件校验 - 新增文件校验与扫码结果汇总实现,补充对应单测 - 同步更新流程设计文档、配置和系统设置页面文案
49 lines
1.3 KiB
C#
49 lines
1.3 KiB
C#
using AxiOmron.PcbCheck.Options;
|
|
using AxiOmron.PcbCheck.Services.Implementations;
|
|
using Xunit;
|
|
|
|
namespace AxiOmron.PcbCheck.Tests;
|
|
|
|
/// <summary>
|
|
/// 验证应用配置文件读写行为。
|
|
/// </summary>
|
|
public sealed class AppConfigServiceTests
|
|
{
|
|
/// <summary>
|
|
/// 配置文件使用字符串保存文件校验通道时,应能还原为枚举值。
|
|
/// </summary>
|
|
[Fact]
|
|
public void Load_ShouldDeserializeFileCheckProvider_WhenProviderIsString()
|
|
{
|
|
var service = new AppConfigService();
|
|
string configPath = service.GetConfigPath();
|
|
string? originalJson = File.Exists(configPath) ? File.ReadAllText(configPath) : null;
|
|
|
|
try
|
|
{
|
|
File.WriteAllText(configPath, """
|
|
{
|
|
"FileCheck": {
|
|
"Provider": "Sftp"
|
|
}
|
|
}
|
|
""");
|
|
|
|
AppConfig config = service.Load();
|
|
|
|
Assert.Equal(FileCheckProvider.Sftp, config.FileCheck.Provider);
|
|
}
|
|
finally
|
|
{
|
|
if (originalJson is null)
|
|
{
|
|
File.Delete(configPath);
|
|
}
|
|
else
|
|
{
|
|
File.WriteAllText(configPath, originalJson);
|
|
}
|
|
}
|
|
}
|
|
}
|