Add comprehensive tests for EditSection functionality in the Windows application

- Implement tests for picker behavior, including loading sequences, searching, and handling empty libraries.
- Validate sequence opening via Enter key and double-click actions.
- Ensure proper handling of unsaved edits and sequence deletion scenarios.
- Verify accessibility features for picker rows across different languages.
- Introduce a dialog counting mechanism to manage unsaved edit confirmations.
This commit is contained in:
Alby96 committed 2026-10-19 12:10:42 +02:00
1 parent 4ea44bb917
commit 5aeb6aa787
214 files changed
+6547 -826

No files matched your search

@@ -194,6 +194,75 @@ public sealed class SchedulingTests
Assert.Equal(attempts, saved);
}
[Test]
public async Task AHeldChangeIsNotRetriedUntilReleased()
{
var fail = true;
var attempts = 0;
var stored = new List<int?>();
var saver = new ProjectSaver(p =>
{
attempts++;
if (fail) throw new System.IO.IOException("offline");
stored.Add(p.HeroFrame);
return Task.CompletedTask;
}, TimeSpan.Zero);
saver.Schedule(new ProjectSettings { HeroFrame = 1 });
Assert.False(await saver.FlushAsync());
Assert.True(await saver.HoldAsync(), "the failed change still waits");
fail = false;
var tried = attempts;
// Neither the retry (2 s after the failure) nor a flush writes while the user is asked.
var flush = saver.FlushAsync();
await Task.Delay(2500);
Assert.Equal(tried, attempts, "no write while held");
Assert.False(flush.IsCompleted);
saver.Release();
Assert.True(await flush.WaitAsync(TimeSpan.FromSeconds(10)), "kept: stored once released");
Assert.SequenceEqual([(int?)1], stored);
}
[Test]
public async Task ADiscardedChangeIsNeverWrittenEvenWhenTheArchiveComesBack()
{
var fail = true;
var stored = new List<int?>();
var saver = new ProjectSaver(p =>
{
if (fail) throw new System.IO.IOException("offline");
stored.Add(p.HeroFrame);
return Task.CompletedTask;
}, TimeSpan.Zero);
saver.Schedule(new ProjectSettings { HeroFrame = 3 });
Assert.False(await saver.FlushAsync());
Assert.True(await saver.HoldAsync());
// The archive answers again while the question is open; the user then discards the change.
fail = false;
await Task.Delay(2500);
saver.Stop();
Assert.True(await saver.FlushAsync().WaitAsync(TimeSpan.FromSeconds(10)));
Assert.Count(0, stored, "the discarded change was never written");
}
[Test]
public async Task AHoldWaitsForTheWriteUnderWay()
{
var gate = new TaskCompletionSource();
var started = new TaskCompletionSource();
var saver = new ProjectSaver(async _ =>
{
started.TrySetResult();
await gate.Task;
}, TimeSpan.Zero);
saver.Schedule(new ProjectSettings { HeroFrame = 1 });
await started.Task.WaitAsync(TimeSpan.FromSeconds(10));
var hold = saver.HoldAsync();
Assert.False(hold.IsCompleted, "the write under way may still fail");
gate.SetResult();
Assert.False(await hold.WaitAsync(TimeSpan.FromSeconds(10)), "it stored the change: nothing to ask");
saver.Release();
}
[Test]
public async Task FlushWithNothingPendingIsStored()
{