Completes Phase 5 (Polish): - Home dashboard (default screen): recent commands, pinned favorites, and a read-only system-status widget (Windows + build, RAM, system drive, uptime) via ISystemInfoService. Status is read locally with no process spawn, no elevation and no network (golden rules). - Favorites: pin/unpin from the list + detail star, persisted by id in config.json; a Favorites sidebar item filters the catalog to pins. - Recent commands: last 10 run command ids tracked for Home. - Window placement: persist + restore size/position/maximized, clamped to the virtual screen so a stale multi-monitor position never lands off-screen. - Accessibility: AutomationProperties.Name on new controls + palette and confirmation inputs; heading semantics on Home; Ctrl+H opens Home. Implementation notes: - ISystemInfoService uses Environment.OSVersion + CsWin32 GlobalMemoryStatusEx + DriveInfo + TickCount64 (AllowUnsafeBlocks for the generated interop). - Pure, unit-tested helpers RecentCommands.Add / Favorites.Toggle and WindowPlacement.IsOnScreen. - 102 tests pass; 0-warning Release build. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
using CommandForge.Application.Settings;
|
|
|
|
namespace CommandForge.Tests;
|
|
|
|
/// <summary>Tests the recently-run command-id list helper (front-insert, de-dupe, cap).</summary>
|
|
public sealed class RecentCommandsTests
|
|
{
|
|
[Fact]
|
|
public void Add_PutsNewIdFirst()
|
|
{
|
|
IReadOnlyList<string> result = RecentCommands.Add(["b", "c"], "a");
|
|
|
|
Assert.Equal(["a", "b", "c"], result);
|
|
}
|
|
|
|
[Fact]
|
|
public void Add_MovesExistingIdToFront_WithoutDuplicating()
|
|
{
|
|
IReadOnlyList<string> result = RecentCommands.Add(["a", "b", "c"], "c");
|
|
|
|
Assert.Equal(["c", "a", "b"], result);
|
|
}
|
|
|
|
[Fact]
|
|
public void Add_CapsAtMaxItems()
|
|
{
|
|
var current = Enumerable.Range(0, RecentCommands.MaxItems).Select(i => $"cmd{i}").ToList();
|
|
|
|
var result = RecentCommands.Add(current, "newest");
|
|
|
|
Assert.Equal(RecentCommands.MaxItems, result.Count);
|
|
Assert.Equal("newest", result[0]);
|
|
Assert.DoesNotContain($"cmd{RecentCommands.MaxItems - 1}", result); // oldest dropped
|
|
}
|
|
|
|
[Fact]
|
|
public void Add_DoesNotMutateInput()
|
|
{
|
|
var current = new List<string> { "a", "b" };
|
|
|
|
RecentCommands.Add(current, "c");
|
|
|
|
Assert.Equal(["a", "b"], current);
|
|
}
|
|
}
|