namespace Elsa.Bpmn.Interchange.IntegrationTests.Support; /// /// Reads a fixture from the Assets directory shipped alongside this test project — the one place every test /// that needs a BPMN document body goes through, rather than each duplicating its own call. /// internal static class BpmnAssetReader { /// Reads a fixture from the Assets directory shipped alongside this test project. /// A plain file name (no directory segments) of a fixture under Assets. /// /// is rooted or contains a path segment, which could otherwise resolve outside the /// Assets directory. The guard below makes this defence-in-depth rather than the only thing standing /// between the code and a wrong path: — used instead of /// below — does not discard earlier segments when a later one /// looks rooted. /// public static string Read(string fileName) { if (Path.IsPathRooted(fileName) || fileName.Split('/', '\\').Length > 1) throw new ArgumentException($"'{fileName}' must be a plain file name, not a rooted or nested path.", nameof(fileName)); return File.ReadAllText(Path.Join(AppContext.BaseDirectory, "Assets", fileName)); } }