c82f24638d
Apply persistent rules when processes start Wire persistent process rules into runtime process discovery so existing enabled rules can apply automatically while ThreadPilot is running. - Add PersistentRuleAutoApplyService for runtime rule auto-apply - Hook auto-apply into ProcessMonitorManagerService snapshot and process-start paths - Add ApplyPersistentRulesOnProcessStart app setting enabled by default - Use existing PersistentRulesEngine for CpuSelection, legacy affinity, CPU priority and memory priority - Add per-process/rule cooldown to avoid repeated apply spam - Clear cooldown state when processes exit or disappear from snapshots - Preserve safe protected-process and access-denied behavior without bypass claims - Preserve cancellation semantics during shutdown/stop paths - Add tests for matching rules, disabled/no-match cases, cooldown, retry, PID reuse, failures, feature flag and monitor integration No Windows Service, registry/IFEO persistence, installer changes, rules editor, version bump or tag changes.
48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
namespace ThreadPilot.Core.Tests
|
|
{
|
|
using ThreadPilot.Models;
|
|
|
|
public sealed class ApplicationSettingsModelTests
|
|
{
|
|
[Fact]
|
|
public void Constructor_StartMinimizedDefaultsFalse_ForManualLaunchVisibility()
|
|
{
|
|
var settings = new ApplicationSettingsModel();
|
|
|
|
Assert.True(settings.AutostartWithWindows);
|
|
Assert.False(settings.StartMinimized);
|
|
Assert.True(settings.ApplyPersistentRulesOnProcessStart);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasSameUserSettingsAs_ReturnsTrue_WhenChangedSettingIsRestored()
|
|
{
|
|
var savedSettings = new ApplicationSettingsModel
|
|
{
|
|
EnableNotifications = true,
|
|
};
|
|
|
|
var editableSettings = (ApplicationSettingsModel)savedSettings.Clone();
|
|
editableSettings.EnableNotifications = false;
|
|
Assert.False(editableSettings.HasSameUserSettingsAs(savedSettings));
|
|
|
|
editableSettings.EnableNotifications = true;
|
|
|
|
Assert.True(editableSettings.HasSameUserSettingsAs(savedSettings));
|
|
}
|
|
|
|
[Fact]
|
|
public void HasSameUserSettingsAs_IgnoresMetadataTimestamps()
|
|
{
|
|
var savedSettings = new ApplicationSettingsModel
|
|
{
|
|
UpdatedAt = new System.DateTime(2026, 5, 16, 10, 0, 0, System.DateTimeKind.Utc),
|
|
};
|
|
var editableSettings = (ApplicationSettingsModel)savedSettings.Clone();
|
|
editableSettings.UpdatedAt = savedSettings.UpdatedAt.AddMinutes(5);
|
|
|
|
Assert.True(editableSettings.HasSameUserSettingsAs(savedSettings));
|
|
}
|
|
}
|
|
}
|