From dbf4b5de77cb5811697684d3cfd0ec5f90feb87b Mon Sep 17 00:00:00 2001 From: Livar Cunha Date: Thu, 19 Jan 2017 13:59:31 -0800 Subject: [PATCH] Adding a test that verifies that running dotnet migrate solution.sln will only migrate the projects in the solution file. --- .../TestApp/TestAssets/TestAsset/Program.cs | 12 ++++++++ .../TestApp/TestAssets/TestAsset/project.json | 15 ++++++++++ .../GivenThatIWantToMigrateSolutions.cs | 29 +++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithSlnAndXprojRefs/TestApp/TestAssets/TestAsset/Program.cs create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithSlnAndXprojRefs/TestApp/TestAssets/TestAsset/project.json diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndXprojRefs/TestApp/TestAssets/TestAsset/Program.cs b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndXprojRefs/TestApp/TestAssets/TestAsset/Program.cs new file mode 100644 index 000000000..c56978bf5 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndXprojRefs/TestApp/TestAssets/TestAsset/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace App.Tests +{ + public class Program + { + public static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndXprojRefs/TestApp/TestAssets/TestAsset/project.json b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndXprojRefs/TestApp/TestAssets/TestAsset/project.json new file mode 100644 index 000000000..91b0a9ae6 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndXprojRefs/TestApp/TestAssets/TestAsset/project.json @@ -0,0 +1,15 @@ +{ + "frameworks": { + "netcoreapp1.0": { + "imports": [ + "portable-net451+win8" + ], + "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.0.0", + "type": "platform" + } + } + } + } +} \ No newline at end of file diff --git a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateSolutions.cs b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateSolutions.cs index ad29bec23..07f68b5b8 100644 --- a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateSolutions.cs +++ b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateSolutions.cs @@ -51,6 +51,35 @@ namespace Microsoft.DotNet.Migration.Tests "PJAppWithSlnAndXprojRefs"); } + [Fact] + public void ItOnlyMigratesProjectsInTheSlnFile() + { + var projectDirectory = TestAssets + .Get("NonRestoredTestProjects", "PJAppWithSlnAndXprojRefs") + .CreateInstance() + .WithSourceFiles() + .Root; + + var solutionRelPath = Path.Combine("TestApp", "TestApp.sln"); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute($"migrate \"{solutionRelPath}\"") + .Should().Pass(); + + new DirectoryInfo(projectDirectory.FullName) + .Should().HaveFiles(new [] + { + Path.Combine("TestApp", "TestApp.csproj"), + Path.Combine("TestLibrary", "TestLibrary.csproj"), + Path.Combine("TestApp", "src", "subdir", "subdir.csproj"), + Path.Combine("TestApp", "TestAssets", "TestAsset", "project.json") + }); + + new DirectoryInfo(projectDirectory.FullName) + .Should().NotHaveFile(Path.Combine("TestApp", "TestAssets", "TestAsset", "TestAsset.csproj")); + } + [Fact] public void WhenDirectoryAlreadyContainsCsprojFileItMigratesAndBuildsSln() {