58 lines
1.8 KiB
C#
58 lines
1.8 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using w4c_workflows.Services;
|
|
using w4c_workflows.Services.Execution;
|
|
using Xunit;
|
|
|
|
namespace w4c_workflows.Tests;
|
|
|
|
public class RuntimeRegistryTests
|
|
{
|
|
private static IConfiguration Config => new ConfigurationBuilder().Build();
|
|
|
|
private static RuntimeRegistry NewRegistry()
|
|
{
|
|
IScriptExecutor[] executors =
|
|
{
|
|
new SubprocessScriptExecutor("shell", "sh", Config),
|
|
new SubprocessScriptExecutor("python", "python3", Config),
|
|
new SubprocessScriptExecutor("javascript", "node", Config),
|
|
new TypeScriptExecutor(Config),
|
|
new CSharpScriptExecutor(),
|
|
};
|
|
return new RuntimeRegistry(new LanguageRegistry(), executors);
|
|
}
|
|
|
|
[Fact]
|
|
public void Lists_all_six_languages_in_declared_order()
|
|
{
|
|
// W9 adds the 'agent' step type (executed via chatapi) to the registry.
|
|
Assert.Equal(
|
|
new[] { "shell", "javascript", "typescript", "csharp", "python", "agent" },
|
|
NewRegistry().All.Select(r => r.Id));
|
|
}
|
|
|
|
[Fact]
|
|
public void Resolves_every_subprocess_language_to_an_executor()
|
|
{
|
|
var registry = NewRegistry();
|
|
foreach (var id in new[] { "shell", "javascript", "typescript", "csharp", "python" })
|
|
Assert.NotNull(registry.Resolve(id));
|
|
// 'agent' is executor-backed by DI registration in Program.cs, not this manual array;
|
|
// its availability depends on the ChatApiUrl config being set.
|
|
}
|
|
|
|
[Fact]
|
|
public void Rejects_unknown_language()
|
|
{
|
|
Assert.Null(NewRegistry().Resolve("cobol"));
|
|
}
|
|
|
|
[Fact]
|
|
public void CSharp_runtime_is_always_available()
|
|
{
|
|
var csharp = NewRegistry().All.Single(r => r.Id == "csharp");
|
|
Assert.True(csharp.Available);
|
|
Assert.True(NewRegistry().IsAvailable("csharp"));
|
|
}
|
|
}
|