// Copyright (c) The Geekeey Authors // SPDX-License-Identifier: EUPL-1.2 using Geekeey.Process.Buffered; namespace Geekeey.Process.Tests; internal sealed class PathResolutionTests { [Test] public async Task I_can_execute_a_command_on_an_executable_using_its_short_name() { // Arrange var cmd = new Command("dotnet") .WithArguments("--version"); // Act var result = await cmd.ExecuteBufferedAsync(); // Assert using (Assert.Multiple()) { await Assert.That(result.ExitCode).IsEqualTo(0); await Assert.That(result.StandardOutput.Trim()).Matches(@"^\d+\.\d+\.\d+$"); } } [Test] [Platform(PlatformAttribute.Windows)] public async Task I_can_execute_a_command_on_a_script_using_its_short_name() { // Arrange using var dir = TestTempDirectory.Create(); await File.WriteAllTextAsync(Path.Combine(dir.Path, "script.cmd"), "@echo hi"); using var _1 = TestEnvironment.ExtendPath(dir.Path); var cmd = new Command("script"); // Act var result = await cmd.ExecuteBufferedAsync(); // Assert // Assert using (Assert.Multiple()) { await Assert.That(result.ExitCode).IsEqualTo(0); await Assert.That(result.StandardOutput.Trim()).IsEqualTo("hi"); } } }