Files
TeslaSuite/Console/tests/TeslaConsole.DiffTests/PublicApiSurfaceTests.cs
T
CydandClaude Opus 4.8 78bf297824 Bump version to 4.11.4.1; show version in Agent tray menu
- Console AssemblyVersion/AssemblyFileVersion 4.11.3.37076 -> 4.11.4.1. The
  recovered console is no longer a byte-faithful copy of the original baseline;
  it is the modernized 4.11.4.x line.
- Launcher Service + Agent Version -> 4.11.4.1 (unified suite version). The Agent
  tray menu header now shows the running version ("Tesla Launcher Agent  v4.11.4.1").
- Differential tests: the identity guard now expects the original at 4.11.3.37076
  and the recovered at 4.11.4.1 (not identical); the public-member surface check
  strips Version= stamps before comparing, since generic-argument signatures embed
  the assembly version (we compare type names, not versions). 73 tests green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-30 10:02:39 -05:00

66 lines
3.1 KiB
C#

using System.Linq;
using System.Text.RegularExpressions;
using Xunit;
namespace TeslaConsole.DiffTests
{
/// <summary>
/// Structural equivalence: every public type and public member exposed by the
/// original TeslaConsole.exe must also be exposed, with the same signature, by the
/// recovered build. This is a strong "same program" contract that catches any
/// dropped, renamed, or re-signatured member introduced during reconstruction.
///
/// The enumeration runs inside each assembly's own AppDomain (see DifferentialFixture)
/// because the two files share identical assembly identity and cannot coexist in one
/// domain. Compiler-generated members are excluded — the README notes those legitimately
/// differ between a decompilation and the lost original sources.
/// </summary>
public class PublicApiSurfaceTests : IClassFixture<DifferentialFixture>
{
private readonly DifferentialFixture _fx;
public PublicApiSurfaceTests(DifferentialFixture fx) => _fx = fx;
[Fact]
public void Recovered_Exposes_All_Original_Public_Types()
{
var original = _fx.Original.GetPublicTypeNames();
var recovered = _fx.Recovered.GetPublicTypeNames();
// Sanity: the original actually yielded a non-trivial surface to compare.
Assert.True(original.Length > 20,
"Only " + original.Length + " public types enumerated from the original; " +
"dependency resolution likely failed.");
var missing = original.Except(recovered).OrderBy(s => s).ToArray();
Assert.True(missing.Length == 0,
"Public types present in the original but missing from the recovered build:\n " +
string.Join("\n ", missing));
}
// The recovered build is intentionally a newer assembly version than the
// original baseline. A member signature that references a TeslaConsole type as a
// generic argument embeds that type's assembly-qualified name — including the
// version — so strip Version= stamps before comparing. We compare type NAMES,
// not versions.
private static string StripVersion(string sig)
=> Regex.Replace(sig, @", Version=\d+\.\d+\.\d+\.\d+", "");
[Fact]
public void Recovered_Exposes_All_Original_Public_Members()
{
var original = _fx.Original.GetPublicMemberSignatures().Select(StripVersion).ToArray();
var recovered = _fx.Recovered.GetPublicMemberSignatures().Select(StripVersion).ToArray();
Assert.True(original.Length > 100,
"Only " + original.Length + " public members enumerated from the original; " +
"dependency resolution likely failed.");
var missing = original.Except(recovered).OrderBy(s => s).ToArray();
Assert.True(missing.Length == 0,
missing.Length + " public member(s) present in the original but missing from the recovered build:\n " +
string.Join("\n ", missing.Take(80)));
}
}
}