Added OSX Helper
ADD
WalletWasabi.Tests/Helpers/MacOsStartupHelper.cs
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using WalletWasabi.Microservices;
+
+namespace WalletWasabi.Tests.Helpers
+{
+ public class MacOsStartupHelper
+ {
+ private string _listCmd = $"osascript -e \' tell application \"System Events\" to get every login item\'";
+
+ public async Task<string> GetLoginItemsAsync()
+ {
+ var escapedArgs = _listCmd.Replace("\"", "\\\"");
+
+ var startInfo = new ProcessStartInfo
+ {
+ FileName = "/usr/bin/env",
+ Arguments = $"sh -c \"{escapedArgs}\"",
+ RedirectStandardOutput = true,
+ UseShellExecute = false,
+ CreateNoWindow = true,
+ WindowStyle = ProcessWindowStyle.Hidden
+ };
+
+ using var process = new ProcessAsync(startInfo);
+
+ process.Start();
+
+ string output = process.StandardOutput.ReadToEnd(); // Gives back "login item Wasabi Wallet" or "login item"
+
+ await process.WaitForExitAsync(CancellationToken.None).ConfigureAwait(false);
+
+ return output;
+ }
+ }
+}

MODIFY
WalletWasabi.Tests/UnitTests/StartWasabiOnSystemStartupTests.cs
WalletWasabi.Tests/UnitTests/StartWasabiOnSystemStartupTests.cs
@@ -17,10 +17,10 @@ namespace WalletWasabi.Tests.UnitTests
{
public class StartWasabiOnSystemStartupTests
{
- private string _listCmd = $"osascript -e \' tell application \"System Events\" to get every login item\'";
-
private readonly WindowsStartupHelper _windowsHelper = new();
+ private readonly MacOsStartupHelper _macOsHelper = new();
+
[Fact]
public async Task ModifyStartupOnDifferentSystemsTestAsync()
{
@@ -51,13 +51,13 @@ namespace WalletWasabi.Tests.UnitTests
{
await StartupHelper.ModifyStartupSettingAsync(true);
- string loginItems = await GetLoginItemsAsync(_listCmd);
+ string loginItems = await _macOsHelper.GetLoginItemsAsync();
Assert.Contains(Constants.AppName, loginItems);
await StartupHelper.ModifyStartupSettingAsync(false);
- loginItems = await GetLoginItemsAsync(_listCmd);
+ loginItems = await _macOsHelper.GetLoginItemsAsync();
Assert.DoesNotContain(Constants.AppName, loginItems);
}
@@ -74,30 +74,5 @@ namespace WalletWasabi.Tests.UnitTests
return uiConfig;
}
-
- private async Task<string> GetLoginItemsAsync(string cmd)
- {
- var escapedArgs = cmd.Replace("\"", "\\\"");
-
- var startInfo = new ProcessStartInfo
- {
- FileName = "/usr/bin/env",
- Arguments = $"sh -c \"{escapedArgs}\"",
- RedirectStandardOutput = true,
- UseShellExecute = false,
- CreateNoWindow = true,
- WindowStyle = ProcessWindowStyle.Hidden
- };
-
- using var process = new ProcessAsync(startInfo);
-
- process.Start();
-
- string output = process.StandardOutput.ReadToEnd(); // Gives back "login item Wasabi Wallet" or "login item"
-
- await process.WaitForExitAsync(CancellationToken.None).ConfigureAwait(false);
-
- return output;
- }
}
}

Added OSX Helper