acdream/tests/Fixtures/campaign-la/LauncherCoreSessionConfigFixture.cs

120 lines
3.9 KiB
C#

using AcDream.Launcher.Core.Launching;
using AcDream.Launcher.Core.Profiles;
using AcDream.Platform;
namespace AcDream.Tests.Fixtures.CampaignLa;
/// <summary>
/// Produces one real Launcher.Core session document that is compiled into
/// both host test suites. Keeping composition in one linked fixture makes the
/// LA1/LA3 anti-drift gate prove that App and Headless accept the identical
/// composer output rather than two hand-maintained lookalikes.
/// </summary>
internal static class LauncherCoreSessionConfigFixture
{
internal const string Password = "must-not-be-serialized";
internal static string Compose()
{
var server = new ServerProfile
{
Name = "Composer Server",
Host = "composer.example",
Port = 9010,
};
var account = new AccountProfile
{
Account = "composer-account",
Password = Password,
};
var character = new CharacterProfile
{
Name = "Composer Character",
Id = "0x50000001",
LaunchMode = LaunchMode.Headless,
Plugins = ["ComposerPlugin"],
LoginCommands = ["/composer command"],
};
var install = new LauncherInstallRecord(
"composer-dats",
"composer-dats/acdream.pak");
var paths = new ApplicationPathSet(
Path.Combine(Path.GetTempPath(), "composer-config"),
Path.Combine(Path.GetTempPath(), "composer-data"),
Path.Combine(Path.GetTempPath(), "composer-cache"),
LegacyConfigDirectory: null);
ComposedSessionConfig composed = SessionConfigComposer.Compose(
server,
account,
character,
install,
paths,
"composer-contract",
loginCommandDelayMs: 625);
return SessionConfigComposer.Serialize(composed.Document);
}
internal static string ComposeEmptyPlugins()
{
(ServerProfile server, AccountProfile account,
LauncherInstallRecord install, ApplicationPathSet paths) = Inputs();
var character = new CharacterProfile
{
Name = "Composer Character",
Id = "0x50000001",
LaunchMode = LaunchMode.Headless,
Plugins = [],
LoginCommands = [],
};
ComposedSessionConfig composed = SessionConfigComposer.Compose(
server,
account,
character,
install,
paths,
"composer-empty-plugins");
return SessionConfigComposer.Serialize(composed.Document);
}
internal static string ComposeProbe()
{
(ServerProfile server, AccountProfile account,
LauncherInstallRecord install, ApplicationPathSet paths) = Inputs();
ComposedSessionConfig composed = SessionConfigComposer.ComposeProbe(
server,
account,
install,
paths,
"composer-probe");
return SessionConfigComposer.Serialize(composed.Document);
}
private static (
ServerProfile Server,
AccountProfile Account,
LauncherInstallRecord Install,
ApplicationPathSet Paths) Inputs() =>
(
new ServerProfile
{
Name = "Composer Server",
Host = "composer.example",
Port = 9010,
},
new AccountProfile
{
Account = "composer-account",
Password = Password,
},
new LauncherInstallRecord(
"composer-dats",
"composer-dats/acdream.pak"),
new ApplicationPathSet(
Path.Combine(Path.GetTempPath(), "composer-config"),
Path.Combine(Path.GetTempPath(), "composer-data"),
Path.Combine(Path.GetTempPath(), "composer-cache"),
LegacyConfigDirectory: null));
}