namespace Khaemhat.Web.Tests.Shell;
/// The repository the tests run from, to read sources, wiki pages and assets.
internal static class Repository
{
private static readonly Lazy RootPath = new(() =>
{
for (var folder = new DirectoryInfo(AppContext.BaseDirectory); folder is not null; folder = folder.Parent)
{
if (File.Exists(Path.Combine(folder.FullName, "Khaemhat.sln")))
{
return folder.FullName;
}
}
throw new InvalidOperationException("Khaemhat.sln not found above " + AppContext.BaseDirectory);
});
/// The folder holding Khaemhat.sln.
public static string Root => RootPath.Value;
/// Whether a file is under bin/ or obj/.
/// The file.
/// for build output.
public static bool IsBuildOutput(string path)
{
var parts = path.Replace('\\', '/').Split('/');
return parts.Contains("bin") || parts.Contains("obj");
}
}