adds ~60 new tests across RuntimeKey parsing, EnvVarKeyDelivery, the legacy and m2pack formats, ReleaseFormatFactory dispatch, manifest loader tolerance of unknown top-level fields, orchestrator wiring and the ClientAppliedReporter (disabled-by-default, success, 5xx, timeout, connection refused). The telemetry tests spin up an in-process HttpListener helper — no new NuGet dependency. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
65 lines
2.1 KiB
C#
65 lines
2.1 KiB
C#
using Metin2Launcher.Formats;
|
|
using Metin2Launcher.Manifest;
|
|
using Xunit;
|
|
using ManifestDto = Metin2Launcher.Manifest.Manifest;
|
|
|
|
namespace Metin2Launcher.Tests;
|
|
|
|
public class LegacyJsonBlobFormatTests
|
|
{
|
|
private static ManifestDto SampleManifest() => new()
|
|
{
|
|
Version = "v1",
|
|
Launcher = new ManifestLauncherEntry { Path = "Metin2Launcher.exe", Sha256 = "x", Size = 1 },
|
|
Files =
|
|
{
|
|
new ManifestFile { Path = "a.pck", Sha256 = "h1", Size = 10 },
|
|
new ManifestFile { Path = "Metin2.exe", Sha256 = "h2", Size = 20, Platform = "windows" },
|
|
new ManifestFile { Path = "linux-bin", Sha256 = "h3", Size = 30, Platform = "linux" },
|
|
},
|
|
};
|
|
|
|
[Fact]
|
|
public void Name_is_legacy_json_blob()
|
|
{
|
|
Assert.Equal("legacy-json-blob", new LegacyJsonBlobFormat().Name);
|
|
}
|
|
|
|
[Fact]
|
|
public void FilterApplicable_windows_platform()
|
|
{
|
|
var format = new LegacyJsonBlobFormat();
|
|
var filtered = format.FilterApplicable(SampleManifest(), "windows");
|
|
Assert.Equal(2, filtered.Count);
|
|
Assert.Contains(filtered, f => f.Path == "a.pck");
|
|
Assert.Contains(filtered, f => f.Path == "Metin2.exe");
|
|
}
|
|
|
|
[Fact]
|
|
public void FilterApplicable_linux_platform()
|
|
{
|
|
var format = new LegacyJsonBlobFormat();
|
|
var filtered = format.FilterApplicable(SampleManifest(), "linux");
|
|
Assert.Equal(2, filtered.Count);
|
|
Assert.Contains(filtered, f => f.Path == "a.pck");
|
|
Assert.Contains(filtered, f => f.Path == "linux-bin");
|
|
}
|
|
|
|
[Fact]
|
|
public void OnApplied_is_noop()
|
|
{
|
|
var outcome = new ReleaseOutcome();
|
|
var tmp = Path.Combine(Path.GetTempPath(), "lg-" + Guid.NewGuid());
|
|
Directory.CreateDirectory(tmp);
|
|
try
|
|
{
|
|
new LegacyJsonBlobFormat().OnApplied(
|
|
tmp,
|
|
new LoadedManifest(Array.Empty<byte>(), Array.Empty<byte>(), SampleManifest()),
|
|
outcome);
|
|
Assert.Null(outcome.RuntimeKey);
|
|
}
|
|
finally { Directory.Delete(tmp, true); }
|
|
}
|
|
}
|