Files
StarterNG/StarterNG.Tests/SettingsFirstStartTests.cs
maj00r 7e249a7a9a fix(settings): a first start has nothing to save before the simulator starts
With no eu07.ini of the player's own, starting the simulator asked to save
changes nobody made. The UART tune box and the Vulkan device box went by
TextChanged, which Avalonia raises later from the dispatcher: the text the
page put there while loading came back as an edit once the window was shown.

Both now go by their Text property, which changes at once and is passed over
while the page loads; typing in them still counts.
2026-11-17 22:14:45 +01:00

40 lines
1.6 KiB
C#

using StarterNG.Application;
using StarterNG.Tests.Fakes;
namespace StarterNG.Tests;
/// <summary>The settings page on a start with no eu07.ini of the player's own yet.</summary>
[Collection(AvaloniaControls.Name)]
public class SettingsFirstStartTests
{
[Fact]
public void A_first_start_has_nothing_to_save_before_the_simulator_starts()
{
var files = new InMemoryFileSystem();
files.WriteAllText(TestInstallation.At("eu07.ini"), "width 1920\nheight 1080\nendconfig\n");
var installation = new TestInstallation(files);
installation.Environment.AsWindows();
var services = AppServices.Initialize(installation.Paths, installation.Files, installation.Clock,
installation.Environment);
services.SettingsStore.Load();
services.SettingsStore.StartAtHighWithoutOwnSettings();
HeadlessDrawing.Ensure();
// The page reads the graphics cards away from the window and comes back to it, as in the application.
var context = SynchronizationContext.Current;
SynchronizationContext.SetSynchronizationContext(new Avalonia.Threading.AvaloniaSynchronizationContext());
Avalonia.Controls.Window? window = null;
try
{
var page = new StarterNG.Views.Settings();
window = Controls.Show(page, 1600, 1000, themed: true);
Assert.False(page.HasUnsavedChanges);
}
finally
{
window?.Close();
SynchronizationContext.SetSynchronizationContext(context);
}
}
}