Files
lmxopcua/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/AdminUiSource.cs
T

26 lines
1.2 KiB
C#

using Shouldly;
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests;
/// <summary>
/// Reads an AdminUI source file for a source-scan pin alongside rendered component tests.
/// Source scans prove wiring exists; actual browser checks cover native behavior.
/// </summary>
internal static class AdminUiSource
{
/// <summary>Reads a file under <c>src/Server/ZB.MOM.WW.OtOpcUa.AdminUI</c>.</summary>
/// <param name="relativeSegments">Path segments below the AdminUI project directory.</param>
/// <returns>The file text.</returns>
public static string Read(params string[] relativeSegments)
{
var dir = new DirectoryInfo(Path.GetDirectoryName(SourceFile())!);
while (dir is not null && !File.Exists(Path.Combine(dir.FullName, "ZB.MOM.WW.OtOpcUa.slnx")))
dir = dir.Parent;
dir.ShouldNotBeNull("could not locate the repository root (no ZB.MOM.WW.OtOpcUa.slnx above the test source)");
var parts = new[] { dir!.FullName, "src", "Server", "ZB.MOM.WW.OtOpcUa.AdminUI" }.Concat(relativeSegments).ToArray();
return File.ReadAllText(Path.Combine(parts));
}
private static string SourceFile([System.Runtime.CompilerServices.CallerFilePath] string sourceFile = "") => sourceFile;
}