38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
namespace BuildFlow.Architecture.Tests;
|
||
|
||
using Xunit;
|
||
|
||
/// <summary>
|
||
/// 工作流持久化任务和 Host 调度边界的源码架构测试。
|
||
/// </summary>
|
||
public class WorkflowJobArchitectureTests
|
||
{
|
||
[Fact]
|
||
public void ProcessEngineShouldNotUseProcessLocalTimerTasks()
|
||
{
|
||
var source = ReadSource("src/modules/workflow/Application/Engine/ProcessEngine.cs");
|
||
|
||
Assert.DoesNotContain("Task.Run", source);
|
||
Assert.DoesNotContain("timer:{", source);
|
||
}
|
||
|
||
private static string ReadSource(string relativePath)
|
||
{
|
||
return File.ReadAllText(Path.Combine(
|
||
FindRepoRoot().FullName,
|
||
relativePath.Replace('/', Path.DirectorySeparatorChar)));
|
||
}
|
||
|
||
private static DirectoryInfo FindRepoRoot()
|
||
{
|
||
var current = new DirectoryInfo(AppContext.BaseDirectory);
|
||
while (current is not null)
|
||
{
|
||
if (File.Exists(Path.Combine(current.FullName, "BuildFlow.slnx"))) return current;
|
||
current = current.Parent;
|
||
}
|
||
|
||
throw new InvalidOperationException("无法定位 BuildFlow.slnx,无法验证工作流任务架构边界。");
|
||
}
|
||
}
|