From d606b4d6af6d7ff3617c9ece86eff75d6307b126 Mon Sep 17 00:00:00 2001 From: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Date: Sun, 9 Feb 2025 07:19:43 +0200 Subject: [PATCH] Clean up tests --- CliWrap.Tests/PipingSpecs.cs | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/CliWrap.Tests/PipingSpecs.cs b/CliWrap.Tests/PipingSpecs.cs index be648858..81be5e57 100644 --- a/CliWrap.Tests/PipingSpecs.cs +++ b/CliWrap.Tests/PipingSpecs.cs @@ -143,30 +143,18 @@ public async Task I_can_execute_a_command_and_pipe_the_stdin_from_another_comman public async Task I_can_execute_a_command_and_pipe_the_stdin_from_another_command_with_a_transform() { // Arrange - var cmdInput = Cli.Wrap(Dummy.Program.FilePath) - .WithArguments(["generate binary", "--length", "100000"]); - - var cmd = Cli.Wrap(Dummy.Program.FilePath) - .WithArguments("length stdin") - .WithStandardInputPipe( - PipeSource.FromCommand( - cmdInput, - // Take only the first 5000 bytes - async (source, destination, cancellationToken) => - { - using var buffer = MemoryPool.Shared.Rent(5000); - - await source.ReadAtLeastAsync( - buffer.Memory, - 5000, - false, - cancellationToken - ); - - await destination.WriteAsync(buffer.Memory[..5000], cancellationToken); - } - ) - ); + var cmd = + PipeSource.FromCommand( + Cli.Wrap(Dummy.Program.FilePath) + .WithArguments(["generate binary", "--length", "100000"]), + // Transform: take the first 5000 bytes and discard the rest + async (source, destination, cancellationToken) => + { + using var buffer = MemoryPool.Shared.Rent(5000); + await source.ReadAtLeastAsync(buffer.Memory, 5000, false, cancellationToken); + await destination.WriteAsync(buffer.Memory[..5000], cancellationToken); + } + ) | Cli.Wrap(Dummy.Program.FilePath).WithArguments("length stdin"); // Act var result = await cmd.ExecuteBufferedAsync();