using Shouldly;
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests;
///
/// Reads an AdminUI source file for a source-scan pin. The repo has no bUnit, so Razor wiring that a
/// unit test cannot render is pinned by scanning the markup; it proves the wiring exists, not that it
/// renders correctly (the docker-dev live pass covers that).
///
internal static class AdminUiSource
{
/// Reads a file under src/Server/ZB.MOM.WW.OtOpcUa.AdminUI.
/// Path segments below the AdminUI project directory.
/// The file text.
public static string Read(params string[] relativeSegments)
{
var dir = new DirectoryInfo(AppContext.BaseDirectory);
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 binary)");
var parts = new[] { dir!.FullName, "src", "Server", "ZB.MOM.WW.OtOpcUa.AdminUI" }.Concat(relativeSegments).ToArray();
return File.ReadAllText(Path.Combine(parts));
}
}