using AcDream.UI.Abstractions.Panels.Settings; namespace AcDream.UI.Abstractions.Tests.Panels.Settings; /// /// L.0: is the immutable record of /// display-tab preferences. Defaults are pinned here so a regression /// (e.g. someone changing the default FOV out from under users) /// surfaces immediately. /// public sealed class DisplaySettingsTests { [Fact] public void Default_values_match_pre_L0_runtime_state() { // Defaults pinned to match the actual pre-L.0 startup state: // · Resolution matches WindowOptions (1280×720 in GameWindow.Run) // · FieldOfView matches camera FovY (60° = π/3) // · VSync matches WindowOptions (false during dev) // · ShowFps true preserves the perf string in the title bar // Net effect: opening Display + Save with no edits is a visual // no-op (no window resize, no camera FovY change, no title // bar change). var d = DisplaySettings.Default; Assert.Equal("1280x720", d.Resolution); Assert.False(d.Fullscreen); Assert.False(d.VSync); Assert.Equal(60f, d.FieldOfView); Assert.Equal(1.0f, d.Gamma); Assert.True(d.ShowFps); } [Fact] public void AvailableResolutions_includes_common_16_9_options() { var list = DisplaySettings.AvailableResolutions; Assert.Contains("1280x720", list); Assert.Contains("1920x1080", list); Assert.Contains("2560x1440", list); Assert.Contains("3840x2160", list); // List should be ascending so the dropdown reads naturally. for (int i = 1; i < list.Count; i++) { int prevW = ParseWidth(list[i - 1]); int curW = ParseWidth(list[i]); Assert.True(curW >= prevW, $"Resolutions not sorted: {list[i - 1]} >= {list[i]}"); } } [Fact] public void Equality_is_value_based() { var a = DisplaySettings.Default; var b = DisplaySettings.Default with { Fullscreen = true }; var c = DisplaySettings.Default with { Fullscreen = true }; Assert.NotEqual(a, b); Assert.Equal(b, c); } [Fact] public void With_expression_clones_one_field() { var d = DisplaySettings.Default with { FieldOfView = 90f }; Assert.Equal(90f, d.FieldOfView); // Other fields untouched. Assert.Equal("1280x720", d.Resolution); Assert.False(d.VSync); Assert.True(d.ShowFps); } private static int ParseWidth(string res) { int x = res.IndexOf('x'); return int.Parse(res.AsSpan(0, x)); } }