using CursorLang.Services; namespace CursorLang.Tests.Services; /// /// Telling a launch by Windows apart from a launch by the user: the first one goes /// to the tray without a window, the second one is what the window is for. /// public sealed class StartupLaunchTests { [Fact] public void A_launch_by_the_user_carries_no_argument() { Assert.False(StartupLaunch.HasArgument([])); Assert.False(StartupLaunch.IsAutomatic([])); } [Fact] public void The_startup_entry_says_so_in_the_command_line() { Assert.True(StartupLaunch.HasArgument([StartupLaunch.Argument])); Assert.True(StartupLaunch.IsAutomatic([StartupLaunch.Argument])); } // The argument does not have to come first: Windows may put its own // alongside it one day [Fact] public void The_argument_is_looked_for_among_the_others() { Assert.True(StartupLaunch.HasArgument(["--whatever", StartupLaunch.Argument])); } [Fact] public void The_case_of_the_argument_does_not_matter() { Assert.True(StartupLaunch.HasArgument([StartupLaunch.Argument.ToUpperInvariant()])); } [Fact] public void Anything_else_is_a_launch_by_the_user() { Assert.False(StartupLaunch.HasArgument(["--startupp", "startup", "-startup"])); } /// /// The command written into the registry carries the argument: that is the whole /// point of the argument. /// [Fact] public void The_startup_entry_is_written_with_the_argument() { string? command = RegistryStartup.GetCommand(); Assert.NotNull(command); Assert.EndsWith(StartupLaunch.Argument, command, StringComparison.Ordinal); // And the path itself stays quoted: it has spaces in it more often than not Assert.StartsWith("\"", command, StringComparison.Ordinal); } }