Files
LanMountainDesktop/LanMountainDesktop.Tests/AirAppProcessStarterRuntimeTests.cs

49 lines
1.5 KiB
C#
Raw Normal View History

2026-05-24 23:12:48 +08:00
using Xunit;
namespace LanMountainDesktop.Tests;
public sealed class AirAppProcessStarterRuntimeTests : IDisposable
{
private readonly string _root;
public AirAppProcessStarterRuntimeTests()
{
_root = Path.Combine(Path.GetTempPath(), "LanMountainDesktop.AirAppProcessStarterRuntimeTests", Guid.NewGuid().ToString("N"));
Directory.CreateDirectory(_root);
}
[Fact]
public void CreateStartInfo_UsesPackagedExecutable_WhenExeExists()
{
var hostPath = Path.Combine(_root, OperatingSystem.IsWindows()
? "LanMountainDesktop.AirAppHost.exe"
: "LanMountainDesktop.AirAppHost");
File.WriteAllText(hostPath, string.Empty);
var startInfo = AirAppProcessStarter.CreateStartInfo(hostPath);
Assert.Equal(hostPath, startInfo.FileName);
Assert.Empty(startInfo.ArgumentList);
}
[Fact]
2026-05-31 19:41:10 +08:00
public void CreateStartInfo_UsesDotnetHost_ForDllFallback()
2026-05-24 23:12:48 +08:00
{
var hostDll = Path.Combine(_root, "LanMountainDesktop.AirAppHost.dll");
File.WriteAllText(hostDll, string.Empty);
2026-05-31 19:41:10 +08:00
var startInfo = AirAppProcessStarter.CreateStartInfo(hostDll);
2026-05-24 23:12:48 +08:00
2026-05-31 19:41:10 +08:00
Assert.Contains("dotnet", Path.GetFileName(startInfo.FileName), StringComparison.OrdinalIgnoreCase);
2026-05-24 23:12:48 +08:00
Assert.Equal(hostDll, startInfo.ArgumentList.Single());
}
public void Dispose()
{
if (Directory.Exists(_root))
{
Directory.Delete(_root, recursive: true);
}
}
}