using CursorLang.Core.Interop; using CursorLang.Core.Models; using CursorLang.Core.Services; using CursorLang.Tests.Shared; using Windows.ApplicationModel; namespace CursorLang.Core.Tests.Services; /// /// Startup by way of Windows. The tests run outside an MSIX package — as does any /// run of the app from a folder — so the answer they get comes from the registry. /// public sealed class StartupServiceTests { [Fact] public async Task Outside_a_package_the_state_comes_from_the_registry() { if (PackageIdentityNative.IsPackaged) { // The tests are running as a package: the answer comes from the task instead return; } using var agent = new StagedAgentExecutable(); // Whether startup is on depends on the machine; what matters is that the // question is answered at all and the setting is not hidden Assert.NotEqual(StartupState.Unavailable, await new StartupService().GetStateAsync()); } [Theory] [InlineData(StartupTaskState.Enabled, StartupState.Enabled)] [InlineData(StartupTaskState.Disabled, StartupState.Disabled)] [InlineData(StartupTaskState.DisabledByUser, StartupState.DisabledByUser)] [InlineData(StartupTaskState.DisabledByPolicy, StartupState.DisabledByPolicy)] [InlineData(StartupTaskState.EnabledByPolicy, StartupState.EnabledByPolicy)] public void A_Windows_task_state_translates_into_an_app_state( StartupTaskState windows, StartupState expected) { Assert.Equal(expected, StartupService.Translate(windows)); } // Windows may grow a state the app knows nothing about [Fact] public void An_unfamiliar_state_counts_as_unavailable() { Assert.Equal(StartupState.Unavailable, StartupService.Translate((StartupTaskState)999)); } [Fact] public void No_Windows_state_is_left_behind() { foreach (StartupTaskState state in Enum.GetValues()) { Assert.NotEqual(StartupState.Unavailable, StartupService.Translate(state)); } } }