Refactor (#56)

This commit is contained in:
Alexey Golub
2020-05-23 18:45:07 +03:00
committed by GitHub
parent 17449e0794
commit bed22b6500
38 changed files with 1624 additions and 1521 deletions

View File

@@ -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\"]");
}
}
}