using w4c_workflows.Models; using w4c_workflows.Models.Nodes; using w4c_workflows.Services.Nodes; using YamlDotNet.Serialization; using YamlDotNet.Serialization.NamingConventions; namespace w4c_workflows.Tests; /// Shared helpers for node graph tests: YAML parsing and small catalogs. internal static class NodeTestData { private static readonly IDeserializer Yaml = new DeserializerBuilder() .WithNamingConvention(CamelCaseNamingConvention.Instance) .WithAttemptingUnquotedStringTypeDeserialization() .IgnoreUnmatchedProperties() .Build(); public static WorkflowDefinition Parse(string yaml) => Yaml.Deserialize(yaml) ?? new(); public static NodeBlueprintCatalog CoreCatalog() => new(NodeBlueprintCatalog.LoadEmbedded()); public static NodeBlueprint NodeBlueprint( string type, double version = 1, IReadOnlyList? outputs = null, IReadOnlyList? parameters = null, string runMode = NodeRunMode.EachItem) => new() { Type = type, Version = version, DisplayName = type, Outputs = outputs?.ToList() ?? new List { NodePort.Main }, Parameters = parameters?.ToList() ?? new List(), RunMode = runMode, }; public static NodeBlueprintCatalog Catalog(params NodeBlueprint[] extra) { var blueprints = NodeBlueprintCatalog.LoadEmbedded().ToList(); blueprints.AddRange(extra); return new NodeBlueprintCatalog(blueprints); } }