Implements C5 + C7 from docs/Extra.md Part 2 (final wave). - Application: pure MaintenanceSuggestions.For(SystemStatus) (low system- drive space -> Disk Cleanup; uptime > 7 days -> restart) and NaturalLanguageSearch.Suggest (EN/VI phrase -> catalog keyword). Natural-language search is 100% LOCAL — no LLM, no network (golden rule #5). - WPF: Home shows a "Maintenance suggestions" section (reason + optional Open button for the suggested catalog command). The catalog search bar shows a "Did you mean: <keyword>" chip for natural-language queries; clicking it applies the keyword. - EN/VI .resx; docs (Changelog/roadmap). - Tests: NL phrase mapping (+ null/already-keyword cases) and the maintenance heuristics. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
36 lines
1.4 KiB
C#
36 lines
1.4 KiB
C#
using CommandForge.Application.Ports;
|
|
using CommandForge.Application.SystemInfo;
|
|
|
|
namespace CommandForge.Tests;
|
|
|
|
/// <summary>Tests the local maintenance-suggestion heuristics over system status.</summary>
|
|
public sealed class MaintenanceSuggestionsTests
|
|
{
|
|
private static SystemStatus Status(long driveTotal, long driveFree, TimeSpan uptime)
|
|
=> new("Windows 11", 26100, 16_000_000_000UL, 8_000_000_000UL, "C:", driveTotal, driveFree, uptime);
|
|
|
|
[Fact]
|
|
public void For_LowDisk_SuggestsCleanup()
|
|
{
|
|
var suggestions = MaintenanceSuggestions.For(Status(driveTotal: 100, driveFree: 5, uptime: TimeSpan.FromHours(1)));
|
|
|
|
Assert.Contains(suggestions, s => s.CommandId == "cleanup.cleanmgr");
|
|
}
|
|
|
|
[Fact]
|
|
public void For_HealthyDisk_NoCleanup()
|
|
=> Assert.DoesNotContain(
|
|
MaintenanceSuggestions.For(Status(driveTotal: 100, driveFree: 50, uptime: TimeSpan.FromHours(1))),
|
|
s => s.ReasonKey == "Maint_LowDisk");
|
|
|
|
[Fact]
|
|
public void For_HighUptime_SuggestsRestart()
|
|
=> Assert.Contains(
|
|
MaintenanceSuggestions.For(Status(driveTotal: 100, driveFree: 50, uptime: TimeSpan.FromDays(8))),
|
|
s => s.ReasonKey == "Maint_HighUptime");
|
|
|
|
[Fact]
|
|
public void For_FreshHealthy_NoSuggestions()
|
|
=> Assert.Empty(MaintenanceSuggestions.For(Status(driveTotal: 100, driveFree: 80, uptime: TimeSpan.FromHours(2))));
|
|
}
|