Issue #1: scaffold gateway solution and projects

This commit is contained in:
Joseph Doherty
2026-04-26 15:49:05 -04:00
parent 81339633d9
commit a45f439029
18 changed files with 385 additions and 0 deletions
@@ -0,0 +1,64 @@
using System.Xml.Linq;
namespace MxGateway.Tests.ProjectStructure;
public sealed class GatewayProjectReferenceTests
{
[Fact]
public void GatewayProject_TargetsNet10()
{
XDocument project = LoadProject("MxGateway.Server");
Assert.Equal("net10.0", ElementValue(project, "TargetFramework"));
}
[Fact]
public void GatewayProject_DoesNotReferenceMxAccessCom()
{
XDocument project = LoadProject("MxGateway.Server");
IReadOnlyList<string> referenceNames = project
.Descendants()
.Where(element => element.Name.LocalName is "Reference" or "COMReference" or "COMFileReference" or "PackageReference")
.Select(element => (string?)element.Attribute("Include") ?? string.Empty)
.ToArray();
Assert.DoesNotContain(referenceNames, reference =>
reference.Contains("MxAccess", StringComparison.OrdinalIgnoreCase)
|| reference.Contains("ArchestrA.MXAccess", StringComparison.OrdinalIgnoreCase)
|| reference.Contains("LMXProxy", StringComparison.OrdinalIgnoreCase));
}
private static XDocument LoadProject(string projectName)
{
DirectoryInfo repositoryRoot = FindRepositoryRoot();
string projectPath = Path.Combine(repositoryRoot.FullName, projectName, $"{projectName}.csproj");
return XDocument.Load(projectPath);
}
private static string ElementValue(XDocument project, string elementName)
{
return project
.Descendants()
.Single(element => element.Name.LocalName == elementName)
.Value;
}
private static DirectoryInfo FindRepositoryRoot()
{
DirectoryInfo? current = new(AppContext.BaseDirectory);
while (current is not null)
{
if (File.Exists(Path.Combine(current.FullName, "MxGateway.sln")))
{
return current;
}
current = current.Parent;
}
throw new DirectoryNotFoundException("Could not locate src/MxGateway.sln from the test output directory.");
}
}