mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
Refactor (#56)
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using CliFx.Tests.Internal;
|
||||
using CliWrap;
|
||||
using CliWrap.Buffered;
|
||||
using FluentAssertions;
|
||||
using Xunit;
|
||||
|
||||
@@ -9,7 +15,31 @@ namespace CliFx.Tests
|
||||
public partial class DirectivesSpecs
|
||||
{
|
||||
[Fact]
|
||||
public async Task Preview_directive_can_be_enabled_to_print_provided_arguments_as_they_were_parsed()
|
||||
public async Task Debug_directive_can_be_specified_to_have_the_application_wait_until_debugger_is_attached()
|
||||
{
|
||||
// We can't actually attach a debugger in tests, so instead just cancel execution after some time
|
||||
|
||||
// Arrange
|
||||
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(1));
|
||||
var stdOut = new StringBuilder();
|
||||
|
||||
var command = Cli.Wrap("dotnet")
|
||||
.WithArguments(a => a
|
||||
.Add(Dummy.Program.Location)
|
||||
.Add("[debug]"))
|
||||
.WithEnvironmentVariables(e => e
|
||||
.Set("ENV_TARGET", "Mars")) | stdOut;
|
||||
|
||||
// Act
|
||||
await command.ExecuteAsync(cts.Token).Task.IgnoreCancellation();
|
||||
var stdOutData = stdOut.ToString();
|
||||
|
||||
// Assert
|
||||
stdOutData.Should().Contain("Attach debugger to");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Preview_directive_can_be_specified_to_print_provided_arguments_as_they_were_parsed()
|
||||
{
|
||||
// Arrange
|
||||
await using var stdOut = new MemoryStream();
|
||||
@@ -30,7 +60,7 @@ namespace CliFx.Tests
|
||||
|
||||
// Assert
|
||||
exitCode.Should().Be(0);
|
||||
stdOutData.Should().ContainAll("cmd", "<param>", "[-a]", "[-b]", "[-c]", "[--option foo]");
|
||||
stdOutData.Should().ContainAll("cmd", "<param>", "[-a]", "[-b]", "[-c]", "[--option \"foo\"]");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user