From 67579ab07e1cfc6f6fd594f5399219a3bb13ea4e Mon Sep 17 00:00:00 2001 From: Nikolai Emil Damm Date: Sun, 4 Aug 2024 20:57:39 +0200 Subject: [PATCH] chore: Refactor CLIRunner namespace and update integration tests --- .../CLIRunnerTests/RunAsyncTests.cs | 72 +++++++++---------- .../{CLIRunner.cs => Runner.cs} | 2 +- 2 files changed, 37 insertions(+), 37 deletions(-) rename Devantler.CLIRunner/{CLIRunner.cs => Runner.cs} (98%) diff --git a/Devantler.CLIRunner.Tests/CLIRunnerTests/RunAsyncTests.cs b/Devantler.CLIRunner.Tests/CLIRunnerTests/RunAsyncTests.cs index 1bace83..7b236e7 100644 --- a/Devantler.CLIRunner.Tests/CLIRunnerTests/RunAsyncTests.cs +++ b/Devantler.CLIRunner.Tests/CLIRunnerTests/RunAsyncTests.cs @@ -3,15 +3,15 @@ namespace Devantler.CLIRunner.Tests.Integration; /// -/// Integration tests for the method. +/// Integration tests for the method. /// public class RunAsyncTests { - /// - /// Tests that the method returns the expected exit code and stdout result - /// - /// - [Fact] + /// + /// Tests that the method returns the expected exit code and stdout result + /// + /// + [Fact] public async Task RunAsync_WithValidCommand_ReturnsZeroExitCodeAndStdout() { // Arrange @@ -22,22 +22,22 @@ public async Task RunAsync_WithValidCommand_ReturnsZeroExitCodeAndStdout() var validation = CommandResultValidation.ZeroExitCode; bool silent = false; - // Act - var (exitCode, result) = await CLIRunner.RunAsync(command, cancellationToken, validation, silent).ConfigureAwait(false); + // Act + var (exitCode, result) = await Runner.RunAsync(command, cancellationToken, validation, silent); - // Assert - Assert.Equal(0, exitCode); + // Assert + Assert.Equal(0, exitCode); Assert.Contains("Hello, World!", result, StringComparison.Ordinal); // Cleanup Environment.SetEnvironmentVariable("DEBUG", null); } - /// - /// Tests that the method returns the expected exit code and stderr result - /// - /// - [Fact] + /// + /// Tests that the method returns the expected exit code and stderr result + /// + /// + [Fact] public async Task RunAsync_WithInvalidCommand_ReturnsOneExitCodeAndNoOutput() { // Arrange @@ -47,19 +47,19 @@ public async Task RunAsync_WithInvalidCommand_ReturnsOneExitCodeAndNoOutput() var validation = CommandResultValidation.ZeroExitCode; bool silent = false; - // Act - var (exitCode, result) = await CLIRunner.RunAsync(command, cancellationToken, validation, silent).ConfigureAwait(false); + // Act + var (exitCode, result) = await Runner.RunAsync(command, cancellationToken, validation, silent); - // Assert - Assert.Equal(1, exitCode); + // Assert + Assert.Equal(1, exitCode); Assert.True(string.IsNullOrEmpty(result)); } - /// - /// Tests that the method returns the expected exit code and stderr result - /// - /// - [Fact] + /// + /// Tests that the method returns the expected exit code and stderr result + /// + /// + [Fact] public async Task RunAsync_WithInvalidArgument_ReturnsOneExitCodeAndStderr() { // Arrange @@ -69,18 +69,18 @@ public async Task RunAsync_WithInvalidArgument_ReturnsOneExitCodeAndStderr() var cancellationToken = CancellationToken.None; bool silent = false; - // Act - var (exitCode, result) = await CLIRunner.RunAsync(command, cancellationToken, CommandResultValidation.ZeroExitCode, silent).ConfigureAwait(false); + // Act + var (exitCode, result) = await Runner.RunAsync(command, cancellationToken, CommandResultValidation.ZeroExitCode, silent); - // Assert - Assert.Equal(1, exitCode); + // Assert + Assert.Equal(1, exitCode); Assert.True(!string.IsNullOrEmpty(result)); } - /// - /// Tests that the method throws an when the command is null - /// - [Fact] + /// + /// Tests that the method throws an when the command is null + /// + [Fact] public async Task RunAsync_WithNullCommand_ReturnsArgumentNullException() { // Arrange @@ -89,11 +89,11 @@ public async Task RunAsync_WithNullCommand_ReturnsArgumentNullException() var validation = CommandResultValidation.ZeroExitCode; bool silent = false; - // Act - async Task Act() => await CLIRunner.RunAsync(command, cancellationToken, validation, silent).ConfigureAwait(false); + // Act + async Task Act() => await Runner.RunAsync(command, cancellationToken, validation, silent).ConfigureAwait(false); - // Assert - _ = await Assert.ThrowsAsync(Act); + // Assert + _ = await Assert.ThrowsAsync(Act); } } diff --git a/Devantler.CLIRunner/CLIRunner.cs b/Devantler.CLIRunner/Runner.cs similarity index 98% rename from Devantler.CLIRunner/CLIRunner.cs rename to Devantler.CLIRunner/Runner.cs index 6769be8..3a6e691 100644 --- a/Devantler.CLIRunner/CLIRunner.cs +++ b/Devantler.CLIRunner/Runner.cs @@ -8,7 +8,7 @@ namespace Devantler.CLIRunner; /// /// A class to run CLI commands and capture their output. /// -public static class CLIRunner +public static class Runner { /// /// Run a CLI command and capture its output.