Files
TeslaSuite/Console/tests/TeslaConsole.DiffTests/CatalogTests.cs
T
CydandClaude Fable 5 3fd637c58a Add vPOD: a virtual pod / game-client stand-in for testing the consoles
vPOD impersonates a Tesla game client (rpl4opt.exe / btl4.exe) so the Red
Planet and BattleTech operator consoles can be exercised without real cockpit
hardware. New net48 WinForms project under Console\vPOD:

- MungaPodServer: the server half of the Munga control protocol (TCP 1501).
  The vendored MungaSocket is client-only, so this reimplements the identical
  framing ([16-byte header][12-byte base + body], dispatched by
  ClientID+MessageID) for the listening side, reusing the vendored message
  classes' WriteTo/BinaryReader serialization.
- PodSimulator: the ApplicationState machine driven by the console's messages -
  answers StateQuery, reassembles the streamed egg and acknowledges it, and
  walks WaitingForEgg -> LoadingMission -> WaitingForLaunch -> RunningMission
  and back on Run/Stop/Abort/Suspend/Resume.
- VPodForm: live display of listening/connection status, the colour-coded
  ApplicationState, an egg viewer (fields + summary), and a newest-first
  protocol log. A Red Planet / BattleTech toggle changes which ApplicationID
  the pod reports, live, so one vPOD stands in for either game.
- PodArguments: parses the real client's launch flags (-net/-app/-lc/-mr/
  -host/-res).

Deployable from Manage Site -> Install Product: a catalog product in
RedPlanet\Apps.xml (Game Client / Live Camera / Mission Review entries) plus
pack.ps1, which builds dist\vPOD.zip laying out vPOD\vPOD.exe for the launcher
to extract to C:\Games\vPOD. CatalogTests updated to 5 products / 11 entries
with the four vPOD entry assertions (88/88 pass). TeslaConsole.csproj excludes
vPOD\** from its **/*.cs glob; the project is added to the solution.

Verified end-to-end over real TCP: a console-role client using the vendored
MungaSocket drives connect -> WaitingForEgg -> stream egg -> (ack) ->
WaitingForLaunch -> Run -> RunningMission -> Stop -> WaitingForEgg, with vPOD
reporting the correct state at each step. MungaGame (what the console's game
windows use) is a thin wrapper over MungaSocket, so this exercises the exact
wire behaviour.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-08 09:34:53 -05:00

131 lines
6.2 KiB
C#

using System.IO;
using Xunit;
namespace TeslaConsole.DiffTests
{
/// <summary>
/// Characterization tests for the data-driven product catalog (AppRegistry + RedPlanet\Apps.xml).
/// These assert the catalog reproduces the EXACT LaunchData the previously-hardcoded
/// SiteManagement code produced, so the refactor is behavior-preserving. Catalog logic is new
/// (absent from the original exe), so these run against the recovered build only.
/// </summary>
public class CatalogTests : IClassFixture<DifferentialFixture>
{
private readonly DifferentialFixture _fx;
private readonly string _catalog;
public CatalogTests(DifferentialFixture fx)
{
_fx = fx;
_catalog = AssemblyPaths.RecoveredCatalog;
Assert.True(File.Exists(_catalog), "Catalog not found next to the build: " + _catalog);
}
private string Entry(string launchKey, string w = "", string h = "")
=> _fx.Recovered.Run("CatalogEntry", new[] { _catalog, launchKey, w, h });
[Fact]
public void Catalog_Has_Five_Products_And_Eleven_Entries()
=> Assert.Equal("products=5;entries=11",
_fx.Recovered.Run("CatalogSummary", new[] { _catalog }));
[Fact]
public void RioJoy_Matches_Expected()
=> Assert.Equal(
@"RIOJoy|fe83e212-45df-48f9-848e-0b3cee0692a3|C:\Games\RIOJoy\app\RioJoy.Tray.exe||C:\Games\RIOJoy\app|True",
Entry("FE83E212-45DF-48F9-848E-0B3CEE0692A3"));
// Each expected string is "DisplayName|LaunchKey|Exe|Args|WorkingDirectory|AutoRestart"
// and matches exactly what the old hardcoded PodInfo_InstallProductCompleted emitted.
[Fact]
public void RedPlanet_GameClient_Matches_Original()
=> Assert.Equal(
@"Red Planet 4.11|7d241b1f-ab6d-4e08-9c20-12294e743d94|C:\Games\RP411\rpl4opt.exe|-net 1501|C:\Games\RP411|True",
Entry("7D241B1F-AB6D-4e08-9C20-12294E743D94"));
[Fact]
public void RedPlanet_GameClient_With_Resolution_Matches_Original()
=> Assert.Equal(
@"Red Planet 4.11|7d241b1f-ab6d-4e08-9c20-12294e743d94|C:\Games\RP411\rpl4opt.exe|-net 1501 -res 1024 768|C:\Games\RP411|True",
Entry("7D241B1F-AB6D-4e08-9C20-12294E743D94", "1024", "768"));
[Fact]
public void RedPlanet_LiveCamera_Matches_Original()
=> Assert.Equal(
@"Red Planet 4.11 LC|57a0b3c2-d5cf-46d6-abed-a8f4a26ab086|C:\Games\RP411\rpl4opt.exe|-net 1501 -lc|C:\Games\RP411|True",
Entry("57A0B3C2-D5CF-46d6-ABED-A8F4A26AB086"));
[Fact]
public void RedPlanet_LiveCamera_With_Resolution_Matches_Original()
=> Assert.Equal(
@"Red Planet 4.11 LC|57a0b3c2-d5cf-46d6-abed-a8f4a26ab086|C:\Games\RP411\rpl4opt.exe|-net 1501 -res 1024 768 -lc|C:\Games\RP411|True",
Entry("57A0B3C2-D5CF-46d6-ABED-A8F4A26AB086", "1024", "768"));
[Fact]
public void RedPlanet_MissionReview_Matches_Original()
=> Assert.Equal(
@"Red Planet 4.11 MR|8f71d5c2-38e4-413c-8e22-88cad08774d2|C:\Games\RP411\rpl4opt.exe|-net 1501 -mr|C:\Games\RP411|True",
Entry("8F71D5C2-38E4-413c-8E22-88CAD08774D2"));
[Fact]
public void Firestorm_Matches_Original()
=> Assert.Equal(
@"BattleTech Firestorm|cc8500ed-a653-45a7-bef8-c332d30371a6|C:\Games\MW4\launcher.exe||C:\Games\MW4|True",
Entry("CC8500ED-A653-45a7-BEF8-C332D30371A6"));
// BattleTech 4.11 is a new product (no original counterpart); these pin the
// catalog entries the console registers on BT pods.
[Fact]
public void BattleTech_GameClient_Matches_Expected()
=> Assert.Equal(
@"BattleTech 4.11|f4c957fd-72f7-4c5f-8971-28095007e8df|C:\Games\BT411\btl4.exe|-net 1501|C:\Games\BT411|True",
Entry("F4C957FD-72F7-4C5F-8971-28095007E8DF"));
[Fact]
public void BattleTech_GameClient_With_Resolution_Matches_Expected()
=> Assert.Equal(
@"BattleTech 4.11|f4c957fd-72f7-4c5f-8971-28095007e8df|C:\Games\BT411\btl4.exe|-net 1501 -res 1024 768|C:\Games\BT411|True",
Entry("F4C957FD-72F7-4C5F-8971-28095007E8DF", "1024", "768"));
[Fact]
public void BattleTech_LiveCamera_Matches_Expected()
=> Assert.Equal(
@"BattleTech 4.11 LC|d393711a-eda0-48b2-82a0-89df12b768af|C:\Games\BT411\btl4.exe|-net 1501 -lc|C:\Games\BT411|True",
Entry("D393711A-EDA0-48B2-82A0-89DF12B768AF"));
[Fact]
public void BattleTech_MissionReview_Matches_Expected()
=> Assert.Equal(
@"BattleTech 4.11 MR|2e9b8628-9c20-42fb-b070-e9c38d521082|C:\Games\BT411\btl4.exe|-net 1501 -mr|C:\Games\BT411|True",
Entry("2E9B8628-9C20-42FB-B070-E9C38D521082"));
// vPOD (Virtual Pod) — the game-client stand-in for testing the consoles.
[Fact]
public void VPod_GameClient_Matches_Expected()
=> Assert.Equal(
@"vPOD|0041c870-6e5e-4f3b-9782-f94f2f76f21d|C:\Games\vPOD\vPOD.exe|-net 1501|C:\Games\vPOD|True",
Entry("0041C870-6E5E-4F3B-9782-F94F2F76F21D"));
[Fact]
public void VPod_GameClient_With_Resolution_Matches_Expected()
=> Assert.Equal(
@"vPOD|0041c870-6e5e-4f3b-9782-f94f2f76f21d|C:\Games\vPOD\vPOD.exe|-net 1501 -res 1024 768|C:\Games\vPOD|True",
Entry("0041C870-6E5E-4F3B-9782-F94F2F76F21D", "1024", "768"));
[Fact]
public void VPod_LiveCamera_Matches_Expected()
=> Assert.Equal(
@"vPOD LC|ea0d4129-8950-428d-8399-e6a77d2d566a|C:\Games\vPOD\vPOD.exe|-net 1501 -lc|C:\Games\vPOD|True",
Entry("EA0D4129-8950-428D-8399-E6A77D2D566A"));
[Fact]
public void VPod_MissionReview_Matches_Expected()
=> Assert.Equal(
@"vPOD MR|fc7ce34e-f4fe-4218-84cd-b13a6fa58e57|C:\Games\vPOD\vPOD.exe|-net 1501 -mr|C:\Games\vPOD|True",
Entry("FC7CE34E-F4FE-4218-84CD-B13A6FA58E57"));
}
}