Adding dotnet run tests for passing arguments to the app.
This commit is contained in:
parent
dd327b52a5
commit
5d2da26e74
3 changed files with 90 additions and 14 deletions
|
@ -82,18 +82,67 @@ namespace Microsoft.DotNet.Tools.Run.Tests
|
|||
.HaveStdOutContaining("Hélló Wórld!");
|
||||
}
|
||||
|
||||
private void CopyProjectToTempDir(string projectDir, TempDirectory tempDir)
|
||||
[Fact]
|
||||
public void ItPassesArgumentsToTheApp()
|
||||
{
|
||||
// copy all the files to temp dir
|
||||
foreach (var file in Directory.EnumerateFiles(projectDir))
|
||||
{
|
||||
tempDir.CopyFile(file);
|
||||
}
|
||||
TestInstance instance = TestAssetsManager.CreateTestInstance("TestAppWithArgs")
|
||||
.WithLockFiles()
|
||||
.WithBuildArtifacts();
|
||||
new RunCommand(instance.TestRoot)
|
||||
.ExecuteWithCapturedOutput("one --two -three")
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdOutContaining(
|
||||
JoinWithNewlines(
|
||||
"Hello World!",
|
||||
"I was passed 3 args:",
|
||||
"arg: [one]",
|
||||
"arg: [--two]",
|
||||
"arg: [-three]"));
|
||||
}
|
||||
|
||||
private string GetProjectPath(TempDirectory projectDir)
|
||||
[Fact]
|
||||
public void ItPassesAllArgsAfterUnexpectedArg()
|
||||
{
|
||||
return Path.Combine(projectDir.Path, "project.json");
|
||||
TestInstance instance = TestAssetsManager.CreateTestInstance("TestAppWithArgs")
|
||||
.WithLockFiles()
|
||||
.WithBuildArtifacts();
|
||||
new RunCommand(instance.TestRoot)
|
||||
.ExecuteWithCapturedOutput("Hello -f")
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdOutContaining(
|
||||
JoinWithNewlines(
|
||||
"Hello World!",
|
||||
"I was passed 2 args:",
|
||||
"arg: [Hello]",
|
||||
"arg: [-f]"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItHandlesArgSeparatorCorrectly()
|
||||
{
|
||||
TestInstance instance = TestAssetsManager.CreateTestInstance("TestAppWithArgs")
|
||||
.WithLockFiles()
|
||||
.WithBuildArtifacts();
|
||||
new RunCommand(instance.TestRoot)
|
||||
.ExecuteWithCapturedOutput("-- one two")
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdOutContaining(
|
||||
JoinWithNewlines(
|
||||
"Hello World!",
|
||||
"I was passed 2 args:",
|
||||
"arg: [one]",
|
||||
"arg: [two]"));
|
||||
}
|
||||
|
||||
private static string JoinWithNewlines(params string[] values)
|
||||
{
|
||||
return string.Join(Environment.NewLine, values);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue