Add tests
This commit is contained in:
parent
48ae5d17ac
commit
5016aea90c
2 changed files with 23 additions and 3 deletions
|
@ -269,6 +269,26 @@ namespace Microsoft.DotNet.Migration.Tests
|
|||
VerifyAllMSBuildOutputsRunnable(projectDirectory);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
// https://github.com/dotnet/cli/issues/4313
|
||||
[InlineData("TestDirWithNoProjects", true)]
|
||||
[InlineData("TestDirWithNoProjects", false)]
|
||||
public void It_migrates_no_projects_found(string projectDir, bool useGlobalJson)
|
||||
{
|
||||
// The migrate command should return 1 for failure.
|
||||
const int ExpectedResult = 1;
|
||||
|
||||
var projectDirectory = TestAssetsManager.CreateTestInstance(projectDir, callingMethod: "It_migrates_no_projects_found").WithLockFiles().Path;
|
||||
if (useGlobalJson)
|
||||
{
|
||||
MigrateProject(new[] { Path.Combine(projectDirectory, "global.json") }, ExpectedResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
MigrateProject(new[] { projectDirectory }, ExpectedResult);
|
||||
}
|
||||
}
|
||||
|
||||
private void VerifyMigration(IEnumerable<string> expectedProjects, string rootDir)
|
||||
{
|
||||
var migratedProjects = Directory.EnumerateFiles(rootDir, "project.json", SearchOption.AllDirectories)
|
||||
|
@ -384,12 +404,12 @@ namespace Microsoft.DotNet.Migration.Tests
|
|||
result.Should().Pass();
|
||||
}
|
||||
|
||||
private void MigrateProject(string[] migrateArgs)
|
||||
private void MigrateProject(string[] migrateArgs, int expectedResult = 0)
|
||||
{
|
||||
var result =
|
||||
MigrateCommand.Run(migrateArgs);
|
||||
|
||||
result.Should().Be(0);
|
||||
result.Should().Be(expectedResult);
|
||||
}
|
||||
|
||||
private void DotnetNew(string projectDirectory, string dotnetNewType)
|
||||
|
|
Loading…
Add table
Reference in a new issue