Files
PrimeBuild-pc b3cd418864 fix: keep a completion status until it fades, not until the finally
Success was invisible while failure stayed on screen. An apply set its result
with SetStatus(message, isBusyState: false), and the operation's own finally
called ClearStatus, which blanked it before it could be read; failures go
through SetCriticalStatus, which is preserved. The only surviving signal was
the toast, and success toasts are exactly what users switch off.

Fixed in ClearStatus rather than in the callers: the affinity path had already
lost its ClearStatus, but priority, memory priority, I/O priority and registry
enforcement all route through the same finally and were still silent. A
completion message is not busy state and already carries its own fade
lifetime, so clearing it there was never right for any caller.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 23:38:13 +02:00

63 lines
2.1 KiB
C#

namespace ThreadPilot.Core.Tests
{
using Microsoft.Extensions.Logging.Abstractions;
using ThreadPilot.ViewModels;
public sealed class BaseViewModelStatusTests
{
[Fact]
public void ClearStatus_DoesNotClearCriticalStatus()
{
var viewModel = new TestViewModel();
viewModel.SetCritical("Realtime priority is blocked.");
viewModel.Clear();
Assert.Equal("Realtime priority is blocked.", viewModel.StatusMessage);
Assert.False(viewModel.IsBusy);
}
[Fact]
public void ClearStatus_KeepsACompletionMessage()
{
// The regression this covers: an apply succeeded, set its status, and the operation's
// own finally wiped it before the user could read it - while failures stayed up.
var viewModel = new TestViewModel();
viewModel.SetCompletion("CPU assignment applied successfully to cs2 using AffinityMask.");
viewModel.Clear();
Assert.Equal("CPU assignment applied successfully to cs2 using AffinityMask.", viewModel.StatusMessage);
Assert.False(viewModel.IsBusy);
}
[Fact]
public void ClearStatus_StillClearsAProgressMessage()
{
var viewModel = new TestViewModel();
viewModel.SetProgress("Setting affinity for cs2...");
viewModel.Clear();
Assert.Equal(string.Empty, viewModel.StatusMessage);
Assert.False(viewModel.IsBusy);
}
private sealed class TestViewModel : BaseViewModel
{
public TestViewModel()
: base(NullLogger<TestViewModel>.Instance)
{
}
public void SetCritical(string message) => this.SetCriticalStatus(message);
public void SetCompletion(string message) => this.SetStatus(message, false);
public void SetProgress(string message) => this.SetStatus(message);
public void Clear() => this.ClearStatus();
}
}
}