Skip to content

Commit d606b4d

Browse files
committed
Clean up tests
1 parent 01ee07d commit d606b4d

File tree

1 file changed

+12
-24
lines changed

1 file changed

+12
-24
lines changed

CliWrap.Tests/PipingSpecs.cs

+12-24
Original file line numberDiff line numberDiff line change
@@ -143,30 +143,18 @@ public async Task I_can_execute_a_command_and_pipe_the_stdin_from_another_comman
143143
public async Task I_can_execute_a_command_and_pipe_the_stdin_from_another_command_with_a_transform()
144144
{
145145
// Arrange
146-
var cmdInput = Cli.Wrap(Dummy.Program.FilePath)
147-
.WithArguments(["generate binary", "--length", "100000"]);
148-
149-
var cmd = Cli.Wrap(Dummy.Program.FilePath)
150-
.WithArguments("length stdin")
151-
.WithStandardInputPipe(
152-
PipeSource.FromCommand(
153-
cmdInput,
154-
// Take only the first 5000 bytes
155-
async (source, destination, cancellationToken) =>
156-
{
157-
using var buffer = MemoryPool<byte>.Shared.Rent(5000);
158-
159-
await source.ReadAtLeastAsync(
160-
buffer.Memory,
161-
5000,
162-
false,
163-
cancellationToken
164-
);
165-
166-
await destination.WriteAsync(buffer.Memory[..5000], cancellationToken);
167-
}
168-
)
169-
);
146+
var cmd =
147+
PipeSource.FromCommand(
148+
Cli.Wrap(Dummy.Program.FilePath)
149+
.WithArguments(["generate binary", "--length", "100000"]),
150+
// Transform: take the first 5000 bytes and discard the rest
151+
async (source, destination, cancellationToken) =>
152+
{
153+
using var buffer = MemoryPool<byte>.Shared.Rent(5000);
154+
await source.ReadAtLeastAsync(buffer.Memory, 5000, false, cancellationToken);
155+
await destination.WriteAsync(buffer.Memory[..5000], cancellationToken);
156+
}
157+
) | Cli.Wrap(Dummy.Program.FilePath).WithArguments("length stdin");
170158

171159
// Act
172160
var result = await cmd.ExecuteBufferedAsync();

0 commit comments

Comments
 (0)