acdream/tests/AcDream.App.Tests/UI/Layout/ChatOptionsDatDefaultsTests.cs

58 lines
2.3 KiB
C#

using AcDream.App.UI.Layout;
using DatReaderWriter;
using DatReaderWriter.Options;
using Xunit.Sdk;
using SysEnv = System.Environment;
namespace AcDream.App.Tests.UI.Layout;
/// <summary>
/// Campaign OP slice OP5: live-DAT proof that <see cref="ChatOptionsDatDefaults"/>
/// resolves the Chat tab's two opacity-slider defaults from the installed DAT —
/// same pattern as <c>RetailSelectionAssetTests</c> (runs against the real
/// installed <c>client_portal.dat</c>, skips gracefully when none is present, no
/// env-var gate needed since it never writes anything).
/// </summary>
public sealed class ChatOptionsDatDefaultsTests
{
[Fact]
[Trait("Lane", "InstalledDat")]
public void InstalledDat_ResolvesTheByteVerifiedSliderDefaults()
{
string datDir = ResolveDatDir();
using var dats = new DatCollection(datDir, DatAccessType.Read);
bool resolved = ChatOptionsDatDefaults.TryRead(
dats, out float defaultOpacity, out float activeOpacity);
// Empirically confirmed against the installed DAT (this slice's own research
// trace): DID 0x78000001, Option_DefaultOpacity_Property = 0.5,
// Option_ActiveOpacity_Property = 1.0 — matching retail's ChatInterface base-
// constructor fallback exactly (a coincidence the fallback documents, not
// something this test relies on to pass).
Assert.True(resolved);
Assert.Equal(0.5f, defaultOpacity);
Assert.Equal(1.0f, activeOpacity);
}
private static string ResolveDatDir()
{
string? configured = SysEnv.GetEnvironmentVariable("ACDREAM_DAT_DIR");
if (!string.IsNullOrWhiteSpace(configured)
&& File.Exists(Path.Combine(configured, "client_portal.dat")))
return configured;
const string installed = @"C:\Turbine\Asheron's Call";
if (File.Exists(Path.Combine(installed, "client_portal.dat")))
return installed;
string conventional = Path.Combine(
SysEnv.GetFolderPath(SysEnv.SpecialFolder.UserProfile),
"Documents",
"Asheron's Call");
if (File.Exists(Path.Combine(conventional, "client_portal.dat")))
return conventional;
throw SkipException.ForSkip("Installed client_portal.dat is required.");
}
}