// SPDX-License-Identifier: GPL-3.0-only // Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE using System.Reflection; using FluentAssertions; using FrameLedger.Shared; namespace FrameLedger.Infrastructure.Tests; /// /// D73: the release line is the RELEASE_LINE file, stamped into the assemblies by Directory.Build.props and /// read back by . On main the file says main and on the alpha branch /// alpha, so these tests hold on both: what they pin is that the three agree, not which line this is. /// public sealed class BuildLineTests { private static string RepoRoot() { for (DirectoryInfo? dir = new(AppContext.BaseDirectory); dir is not null; dir = dir.Parent) { if (File.Exists(Path.Combine(dir.FullName, "FrameLedger.slnx"))) { return dir.FullName; } } throw new InvalidOperationException("the repository root (FrameLedger.slnx) is not above " + AppContext.BaseDirectory); } [Theory] [InlineData("main", false)] [InlineData("alpha", true)] [InlineData(null, false)] [InlineData("", false)] [InlineData("Alpha", false)] [InlineData("beta", false)] public void OnlyTheExactWordAlphaIsTheAlphaLine(string? stamped, bool alpha) { BuildLine line = BuildLine.Parse(stamped); line.IsAlpha.Should().Be(alpha); line.Should().BeSameAs(alpha ? BuildLine.Alpha : BuildLine.Main); } [Fact] public void TheBuildCarriesTheLineTheRepositoryNames() { string file = File.ReadAllText(Path.Combine(RepoRoot(), "RELEASE_LINE")).Trim(); string? stamped = typeof(BuildLine).Assembly.GetCustomAttributes() .FirstOrDefault(static a => string.Equals(a.Key, BuildLine.MetadataKey, StringComparison.Ordinal))?.Value; file.Should().BeOneOf("main", "alpha"); stamped.Should().Be(file, "Directory.Build.props stamps RELEASE_LINE into every assembly"); BuildLine.Current.Name.Should().Be(file); } }