Remove migrate tests
They are in cli-migrate repo now. Keep only one of them to make sure migrate is correctly inserted
This commit is contained in:
parent
3037fdd688
commit
9392561fd5
7 changed files with 0 additions and 2221 deletions
|
@ -1,146 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using FluentAssertions;
|
||||
using Microsoft.DotNet.TestFramework;
|
||||
using Microsoft.DotNet.Tools.Common;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.Migration.Tests
|
||||
{
|
||||
public class GivenThatAnAppWasMigrated : TestBase
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("TestAppWithLibrary")]
|
||||
public void WhenProjectMigrationSucceedsThenProjectJsonArtifactsGetMovedToBackup(string testProjectName)
|
||||
{
|
||||
var testRoot = TestAssets
|
||||
.GetProjectJson(testProjectName)
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root;
|
||||
|
||||
var backupRoot = testRoot.GetDirectory("backup");
|
||||
|
||||
var migratableArtifacts = GetProjectJsonArtifacts(testRoot);
|
||||
|
||||
new MigrateCommand()
|
||||
.WithWorkingDirectory(testRoot)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
|
||||
var backupArtifacts = GetProjectJsonArtifacts(backupRoot);
|
||||
|
||||
backupArtifacts.Should().Equal(migratableArtifacts, "Because all of and only these artifacts should have been moved");
|
||||
|
||||
testRoot.Should().NotHaveFiles(backupArtifacts.Keys);
|
||||
|
||||
backupRoot.Should().HaveTextFiles(backupArtifacts);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("PJTestAppSimple")]
|
||||
public void WhenFolderMigrationSucceedsThenProjectJsonArtifactsGetMovedToBackup(string testProjectName)
|
||||
{
|
||||
var testRoot = TestAssets
|
||||
.GetProjectJson(testProjectName)
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root;
|
||||
|
||||
var backupRoot = testRoot.GetDirectory("backup");
|
||||
|
||||
var migratableArtifacts = GetProjectJsonArtifacts(testRoot);
|
||||
|
||||
new MigrateCommand()
|
||||
.WithWorkingDirectory(testRoot)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
|
||||
var backupArtifacts = GetProjectJsonArtifacts(backupRoot);
|
||||
|
||||
backupArtifacts.Should().Equal(migratableArtifacts, "Because all of and only these artifacts should have been moved");
|
||||
|
||||
testRoot.Should().NotHaveFiles(backupArtifacts.Keys);
|
||||
|
||||
backupRoot.Should().HaveTextFiles(backupArtifacts);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("TestAppWithLibraryAndMissingP2P")]
|
||||
public void WhenMigrationFailsThenProjectJsonArtifactsDoNotGetMovedToBackup(string testProjectName)
|
||||
{
|
||||
var testRoot = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, testProjectName)
|
||||
.CreateInstance(identifier: testProjectName)
|
||||
.WithSourceFiles()
|
||||
.Root;
|
||||
|
||||
var backupRoot = testRoot.GetDirectory("backup");
|
||||
|
||||
var migratableArtifacts = GetProjectJsonArtifacts(testRoot);
|
||||
|
||||
new MigrateCommand()
|
||||
.WithWorkingDirectory(testRoot)
|
||||
.Execute()
|
||||
.Should().Fail();
|
||||
|
||||
backupRoot.Should().NotExist("Because migration failed and therefore no backup is needed.");
|
||||
|
||||
testRoot.Should().HaveTextFiles(migratableArtifacts, "Because migration failed so nothing was moved to backup.");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("PJTestAppSimple")]
|
||||
public void WhenSkipbackupSpecifiedThenProjectJsonArtifactsDoNotGetMovedToBackup(string testProjectName)
|
||||
{
|
||||
var testRoot = TestAssets
|
||||
.GetProjectJson(testProjectName)
|
||||
.CreateInstance(identifier: testProjectName)
|
||||
.WithSourceFiles()
|
||||
.Root;
|
||||
|
||||
var backupRoot = testRoot.GetDirectory("backup");
|
||||
|
||||
var migratableArtifacts = GetProjectJsonArtifacts(testRoot);
|
||||
|
||||
new MigrateCommand()
|
||||
.WithWorkingDirectory(testRoot)
|
||||
.Execute("--skip-backup")
|
||||
.Should().Pass();
|
||||
|
||||
backupRoot.Should().NotExist("Because --skip-backup was specified.");
|
||||
|
||||
testRoot.Should().HaveTextFiles(migratableArtifacts, "Because --skip-backup was specified.");
|
||||
}
|
||||
|
||||
private Dictionary<string, string> GetProjectJsonArtifacts(DirectoryInfo root)
|
||||
{
|
||||
var catalog = new Dictionary<string, string>();
|
||||
|
||||
var patterns = new[] { "global.json", "project.json", "project.lock.json", "*.xproj", "*.xproj.user" };
|
||||
|
||||
foreach (var pattern in patterns)
|
||||
{
|
||||
AddArtifactsToCatalog(catalog, root, pattern);
|
||||
}
|
||||
|
||||
return catalog;
|
||||
}
|
||||
|
||||
private void AddArtifactsToCatalog(Dictionary<string, string> catalog, DirectoryInfo root, string pattern)
|
||||
{
|
||||
var files = root.GetFiles(pattern, SearchOption.AllDirectories);
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
var key = PathUtility.GetRelativePath(root, file);
|
||||
catalog.Add(key, File.ReadAllText(file.FullName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,125 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using Microsoft.Build.Construction;
|
||||
using Microsoft.DotNet.TestFramework;
|
||||
using Microsoft.DotNet.Tools.Common;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
using FluentAssertions;
|
||||
using System.IO;
|
||||
using Microsoft.DotNet.Tools.Migrate;
|
||||
using BuildCommand = Microsoft.DotNet.Tools.Test.Utilities.BuildCommand;
|
||||
using System.Runtime.Loader;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Microsoft.DotNet.Migration.Tests
|
||||
{
|
||||
public class GivenThatIWantMigratedAppsToBinplaceContent : TestBase
|
||||
{
|
||||
[Fact(Skip="Unblocking CI")]
|
||||
public void ItBinplacesContentOnBuildForConsoleApps()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson("TestAppWithContents")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.WithRestoreFiles()
|
||||
.WithEmptyGlobalJson()
|
||||
.Root;
|
||||
|
||||
new TestCommand("dotnet")
|
||||
.WithForwardingToConsole()
|
||||
.Execute($"migrate {projectDirectory.FullName}")
|
||||
.Should()
|
||||
.Pass();
|
||||
|
||||
var command = new RestoreCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass();
|
||||
|
||||
var result = new BuildCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.ExecuteWithCapturedOutput()
|
||||
.Should()
|
||||
.Pass();
|
||||
|
||||
var outputDir = projectDirectory.GetDirectory("bin", "Debug", "netcoreapp1.0");
|
||||
outputDir.Should().Exist().And.HaveFile("testcontentfile.txt");
|
||||
outputDir.GetDirectory("dir").Should().Exist().And.HaveFile("mappingfile.txt");
|
||||
}
|
||||
|
||||
[Fact(Skip="Unblocking CI")]
|
||||
public void ItBinplacesContentOnPublishForConsoleApps()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson("TestAppWithContents")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.WithRestoreFiles()
|
||||
.WithEmptyGlobalJson()
|
||||
.Root;
|
||||
|
||||
new TestCommand("dotnet")
|
||||
.WithForwardingToConsole()
|
||||
.Execute($"migrate {projectDirectory.FullName}")
|
||||
.Should()
|
||||
.Pass();
|
||||
|
||||
var command = new RestoreCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass();
|
||||
|
||||
var result = new PublishCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.ExecuteWithCapturedOutput()
|
||||
.Should()
|
||||
.Pass();
|
||||
|
||||
var publishDir = projectDirectory.GetDirectory("bin", "Debug", "netcoreapp1.0", "publish");
|
||||
publishDir.Should().Exist().And.HaveFile("testcontentfile.txt");
|
||||
publishDir.GetDirectory("dir").Should().Exist().And.HaveFile("mappingfile.txt");
|
||||
}
|
||||
|
||||
[Fact(Skip="CI does not have NPM, which is required for the publish of this app.")]
|
||||
public void ItBinplacesContentOnPublishForWebApps()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson("ProjectJsonWebTemplate")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.WithRestoreFiles()
|
||||
.WithEmptyGlobalJson()
|
||||
.Root;
|
||||
|
||||
new TestCommand("dotnet")
|
||||
.WithForwardingToConsole()
|
||||
.Execute($"migrate {projectDirectory.FullName}")
|
||||
.Should()
|
||||
.Pass();
|
||||
|
||||
var command = new RestoreCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass();
|
||||
|
||||
var result = new PublishCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.ExecuteWithCapturedOutput()
|
||||
.Should()
|
||||
.Pass();
|
||||
|
||||
var publishDir = projectDirectory.GetDirectory("bin", "Debug", "netcoreapp1.0", "publish");
|
||||
publishDir.Should().Exist().And.HaveFile("README.md");
|
||||
publishDir.GetDirectory("wwwroot").Should().Exist();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using Microsoft.Build.Construction;
|
||||
using Microsoft.DotNet.TestFramework;
|
||||
using Microsoft.DotNet.Tools.Common;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
using FluentAssertions;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using Microsoft.DotNet.Tools.Migrate;
|
||||
using BuildCommand = Microsoft.DotNet.Tools.Test.Utilities.BuildCommand;
|
||||
using System.Runtime.Loader;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Microsoft.DotNet.Migration.Tests
|
||||
{
|
||||
public class GivenThatIWantMigratedAppsToPackContent : TestBase
|
||||
{
|
||||
[Fact(Skip="Unblocking CI")]
|
||||
public void ItPacksContentForLibraries()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson("PJTestLibraryWithConfiguration")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.WithRestoreFiles()
|
||||
.WithEmptyGlobalJson()
|
||||
.Root;
|
||||
|
||||
new TestCommand("dotnet")
|
||||
.WithForwardingToConsole()
|
||||
.Execute($"migrate {projectDirectory.FullName}")
|
||||
.Should()
|
||||
.Pass();
|
||||
|
||||
var command = new RestoreCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass();
|
||||
|
||||
var result = new PackCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.ExecuteWithCapturedOutput()
|
||||
.Should()
|
||||
.Pass();
|
||||
|
||||
using (var archive = ZipFile.OpenRead(
|
||||
Path.Combine(projectDirectory.FullName, "bin", "debug", "PJTestLibraryWithConfiguration.1.0.0.nupkg")))
|
||||
{
|
||||
archive.Entries.Select(e => e.FullName).Should().Contain("dir/contentitem.txt");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using FluentAssertions;
|
||||
using Microsoft.DotNet.TestFramework;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using System.IO;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.Migration.Tests
|
||||
{
|
||||
public class GivenThatIWantToMigrateAppsUsingGlobalJson : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void ItMigratesWhenBeingPassedAFullPathToGlobalJson()
|
||||
{
|
||||
var solutionDirectory = TestAssets
|
||||
.GetProjectJson("AppWithPackageNamedAfterFolder")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root;
|
||||
|
||||
var globalJsonPath = solutionDirectory.GetFile("global.json");
|
||||
|
||||
new TestCommand("dotnet")
|
||||
.WithForwardingToConsole()
|
||||
.Execute($"migrate {globalJsonPath.FullName}")
|
||||
.Should()
|
||||
.Pass();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenUsingGlobalJsonItOnlyMigratesProjectsInTheGlobalJsonNode()
|
||||
{
|
||||
var solutionDirectory = TestAssets
|
||||
.GetProjectJson("AppWithPackageNamedAfterFolder")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root;
|
||||
|
||||
var globalJsonPath = solutionDirectory.GetFile("global.json");
|
||||
|
||||
new TestCommand("dotnet")
|
||||
.WithForwardingToConsole()
|
||||
.Execute($"migrate {globalJsonPath.FullName}")
|
||||
.Should()
|
||||
.Pass();
|
||||
|
||||
solutionDirectory
|
||||
.Should().HaveFiles(new []
|
||||
{
|
||||
Path.Combine("src", "App", "App.csproj"),
|
||||
Path.Combine("test", "App.Tests", "App.Tests.csproj"),
|
||||
Path.Combine("TestAssets", "TestAsset", "project.json")
|
||||
});
|
||||
|
||||
solutionDirectory
|
||||
.Should().NotHaveFile(Path.Combine("TestAssets", "TestAsset", "TestAsset.csproj"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItMigratesWhenBeingPassedJustGlobalJson()
|
||||
{
|
||||
var solutionDirectory = TestAssets
|
||||
.GetProjectJson("AppWithPackageNamedAfterFolder")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root;
|
||||
|
||||
var globalJsonPath = solutionDirectory.GetFile("global.json");
|
||||
|
||||
new TestCommand("dotnet")
|
||||
.WithWorkingDirectory(solutionDirectory)
|
||||
.WithForwardingToConsole()
|
||||
.Execute($"migrate global.json")
|
||||
.Should()
|
||||
.Pass();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,562 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using FluentAssertions;
|
||||
using Microsoft.DotNet.TestFramework;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.Migration.Tests
|
||||
{
|
||||
public class GivenThatIWantToMigrateDeprecatedProjects : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void WhenMigratingDeprecatedPackOptionsWarningsArePrinted()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedPack")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root;
|
||||
|
||||
var cmd = new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.ExecuteWithCapturedOutput("migrate");
|
||||
|
||||
cmd.Should().Pass();
|
||||
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'repository' option in the root is deprecated. Use it in 'packOptions' instead.");
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'projectUrl' option in the root is deprecated. Use it in 'packOptions' instead.");
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'licenseUrl' option in the root is deprecated. Use it in 'packOptions' instead.");
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'iconUrl' option in the root is deprecated. Use it in 'packOptions' instead.");
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'owners' option in the root is deprecated. Use it in 'packOptions' instead.");
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'tags' option in the root is deprecated. Use it in 'packOptions' instead.");
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'releaseNotes' option in the root is deprecated. Use it in 'packOptions' instead.");
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'requireLicenseAcceptance' option in the root is deprecated. Use it in 'packOptions' instead.");
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'summary' option in the root is deprecated. Use it in 'packOptions' instead.");
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'packInclude' option is deprecated. Use 'files' in 'packOptions' instead.");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MigrateDeprecatedPack()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedPack")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root;
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("migrate")
|
||||
.Should().Pass();
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("restore")
|
||||
.Should().Pass();
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("build -c Debug")
|
||||
.Should().Pass();
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("pack -c Debug")
|
||||
.Should().Pass();
|
||||
|
||||
var outputDir = projectDirectory.GetDirectory("bin", "Debug");
|
||||
outputDir.Should().Exist()
|
||||
.And.HaveFile("PJDeprecatedPack.1.0.0.nupkg");
|
||||
|
||||
var outputPackage = outputDir.GetFile("PJDeprecatedPack.1.0.0.nupkg");
|
||||
|
||||
var zip = ZipFile.Open(outputPackage.FullName, ZipArchiveMode.Read);
|
||||
zip.Entries.Should().Contain(e => e.FullName == "PJDeprecatedPack.nuspec")
|
||||
.And.Contain(e => e.FullName == "content/Content1.txt")
|
||||
.And.Contain(e => e.FullName == "content/Content2.txt");
|
||||
|
||||
var manifestReader = new StreamReader(
|
||||
zip.Entries.First(e => e.FullName == "PJDeprecatedPack.nuspec").Open());
|
||||
|
||||
// NOTE: Commented out those that are not migrated.
|
||||
// https://microsoft.sharepoint.com/teams/netfx/corefx/_layouts/15/WopiFrame.aspx?sourcedoc=%7B0cfbc196-0645-4781-84c6-5dffabd76bee%7D&action=edit&wd=target%28Planning%2FMSBuild%20CLI%20integration%2Eone%7C41D470DD-CF44-4595-8E05-0CE238864B55%2FProject%2Ejson%20Migration%7CA553D979-EBC6-484B-A12E-036E0730864A%2F%29
|
||||
var nuspecXml = XDocument.Parse(manifestReader.ReadToEnd());
|
||||
nuspecXml.Descendants().Single(e => e.Name.LocalName == "projectUrl").Value
|
||||
.Should().Be("http://projecturl/");
|
||||
nuspecXml.Descendants().Single(e => e.Name.LocalName == "licenseUrl").Value
|
||||
.Should().Be("http://licenseurl/");
|
||||
nuspecXml.Descendants().Single(e => e.Name.LocalName == "iconUrl").Value
|
||||
.Should().Be("http://iconurl/");
|
||||
//nuspecXml.Descendants().Single(e => e.Name.LocalName == "owners").Value
|
||||
// .Should().Be("owner1,owner2");
|
||||
nuspecXml.Descendants().Single(e => e.Name.LocalName == "tags").Value
|
||||
.Should().Be("tag1 tag2");
|
||||
nuspecXml.Descendants().Single(e => e.Name.LocalName == "releaseNotes").Value
|
||||
.Should().Be("releaseNotes");
|
||||
nuspecXml.Descendants().Single(e => e.Name.LocalName == "requireLicenseAcceptance").Value
|
||||
.Should().Be("true");
|
||||
//nuspecXml.Descendants().Single(e => e.Name.LocalName == "summary").Value
|
||||
// .Should().Be("summary");
|
||||
|
||||
var repositoryNode = nuspecXml.Descendants().Single(e => e.Name.LocalName == "repository");
|
||||
repositoryNode.Attributes("type").Single().Value.Should().Be("git");
|
||||
repositoryNode.Attributes("url").Single().Value.Should().Be("http://url/");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenMigratingDeprecatedCompilationOptionsWarningsArePrinted()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompilation")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root;
|
||||
|
||||
var cmd = new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.ExecuteWithCapturedOutput("migrate");
|
||||
|
||||
cmd.Should().Pass();
|
||||
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'compilerName' option in the root is deprecated. Use it in 'buildOptions' instead.");
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'compilationOptions' option is deprecated. Use 'buildOptions' instead.");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MigratingDeprecatedCompilation()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompilation")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root;
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("migrate")
|
||||
.Should().Pass();
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("restore")
|
||||
.Should().Pass();
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("build -c Debug")
|
||||
.Should().Pass();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenMigratingDeprecatedContentOptionsWarningsArePrinted()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedContent")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root;
|
||||
|
||||
var cmd = new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.ExecuteWithCapturedOutput("migrate");
|
||||
|
||||
cmd.Should().Pass();
|
||||
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'content' option is deprecated. Use 'publishOptions' to publish or 'copyToOutput' in 'buildOptions' to copy to build output instead.");
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'contentExclude' option is deprecated. Use 'publishOptions' to publish or 'copyToOutput' in 'buildOptions' to copy to build output instead.");
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'contentFiles' option is deprecated. Use 'publishOptions' to publish or 'copyToOutput' in 'buildOptions' to copy to build output instead.");
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'contentBuiltIn' option is deprecated. Use 'publishOptions' to publish or 'copyToOutput' in 'buildOptions' to copy to build output instead.");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MigratingDeprecatedContent()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedContent")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root
|
||||
.GetDirectory("project");
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("migrate")
|
||||
.Should().Pass();
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("restore")
|
||||
.Should().Pass();
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("build -c Debug")
|
||||
.Should().Pass();
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("publish -c Debug")
|
||||
.Should().Pass();
|
||||
|
||||
var outputDir = projectDirectory.GetDirectory("bin", "Debug", "netcoreapp1.1");
|
||||
outputDir.Should().Exist()
|
||||
.And.HaveFiles(new[]
|
||||
{
|
||||
"ContentFile1.txt1",
|
||||
"ContentFile2.txt1",
|
||||
"ContentFileBuiltIn1.txt1",
|
||||
"ContentFileBuiltIn2.txt1",
|
||||
"IncludeThis.txt",
|
||||
});
|
||||
Directory.Exists(Path.Combine(outputDir.FullName, "ExcludeThis1.txt")).Should().BeFalse();
|
||||
Directory.Exists(Path.Combine(outputDir.FullName, "ExcludeThis2.txt")).Should().BeFalse();
|
||||
|
||||
var publishDir = projectDirectory.GetDirectory("bin", "Debug", "netcoreapp1.1", "publish");
|
||||
publishDir.Should().Exist()
|
||||
.And.HaveFiles(new[]
|
||||
{
|
||||
"ContentFile1.txt1",
|
||||
"ContentFile2.txt1",
|
||||
"ContentFileBuiltIn1.txt1",
|
||||
"ContentFileBuiltIn2.txt1",
|
||||
"IncludeThis.txt",
|
||||
});
|
||||
Directory.Exists(Path.Combine(publishDir.FullName, "ExcludeThis1.txt")).Should().BeFalse();
|
||||
Directory.Exists(Path.Combine(publishDir.FullName, "ExcludeThis2.txt")).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenMigratingDeprecatedCompileOptionsWarningsArePrinted()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompile")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root;
|
||||
|
||||
var cmd = new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.ExecuteWithCapturedOutput("migrate");
|
||||
|
||||
cmd.Should().Pass();
|
||||
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'compile' option is deprecated. Use 'compile' in 'buildOptions' instead.");
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'compileFiles' option is deprecated. Use 'compile' in 'buildOptions' instead.");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MigratingDeprecatedCompile()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompile")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root
|
||||
.GetDirectory("project");
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("migrate")
|
||||
.Should().Pass();
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("restore")
|
||||
.Should().Pass();
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("build -c Debug")
|
||||
.Should().Pass();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenMigratingDeprecatedCompileBuiltInOptionsWarningsArePrinted()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompileBuiltIn")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root;
|
||||
|
||||
var cmd = new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.ExecuteWithCapturedOutput("migrate");
|
||||
|
||||
cmd.Should().Pass();
|
||||
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'compileBuiltIn' option is deprecated. Use 'compile' in 'buildOptions' instead.");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MigratingDeprecatedCompileBuiltIn()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompileBuiltIn")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root
|
||||
.GetDirectory("project");
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("migrate")
|
||||
.Should().Pass();
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("restore")
|
||||
.Should().Pass();
|
||||
|
||||
//Issue: https://github.com/dotnet/cli/issues/5467
|
||||
//new DotnetCommand()
|
||||
// .WithWorkingDirectory(projectDirectory)
|
||||
// .Execute("build -c Debug")
|
||||
// .Should().Pass();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenMigratingDeprecatedCompileExcludeOptionsWarningsArePrinted()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompileExclude")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root;
|
||||
|
||||
var cmd = new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.ExecuteWithCapturedOutput("migrate");
|
||||
|
||||
cmd.Should().Pass();
|
||||
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'compileExclude' option is deprecated. Use 'compile' in 'buildOptions' instead.");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MigratingDeprecatedCompileExclude()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompileExclude")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root;
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("migrate")
|
||||
.Should().Pass();
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("restore")
|
||||
.Should().Pass();
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("build -c Debug")
|
||||
.Should().Pass();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenMigratingDeprecatedResourceOptionsWarningsArePrinted()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedResource")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root
|
||||
.GetDirectory("project");
|
||||
|
||||
var cmd = new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.ExecuteWithCapturedOutput("migrate");
|
||||
|
||||
cmd.Should().Pass();
|
||||
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'resource' option is deprecated. Use 'embed' in 'buildOptions' instead.");
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'resourceFiles' option is deprecated. Use 'embed' in 'buildOptions' instead.");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MigratingDeprecatedResource()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedResource")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root
|
||||
.GetDirectory("project");
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("migrate")
|
||||
.Should().Pass();
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("restore")
|
||||
.Should().Pass();
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("build -c Debug")
|
||||
.Should().Pass();
|
||||
|
||||
if (!EnvironmentInfo.HasSharedFramework("netcoreapp1.1"))
|
||||
{
|
||||
// running the app requires netcoreapp1.1
|
||||
return;
|
||||
}
|
||||
|
||||
var cmd = new DotnetCommand(DotnetUnderTest.WithBackwardsCompatibleRuntimes)
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.ExecuteWithCapturedOutput("run -c Debug");
|
||||
cmd.Should().Pass();
|
||||
cmd.StdOut.Should().Contain("3 Resources Found:");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenMigratingDeprecatedResourceBuiltInOptionsWarningsArePrinted()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedResourceBuiltIn")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root
|
||||
.GetDirectory("project");
|
||||
|
||||
var cmd = new DotnetCommand(DotnetUnderTest.WithBackwardsCompatibleRuntimes)
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.ExecuteWithCapturedOutput("migrate");
|
||||
|
||||
cmd.Should().Pass();
|
||||
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'resourceBuiltIn' option is deprecated. Use 'embed' in 'buildOptions' instead.");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MigratingDeprecatedResourceBuiltIn()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedResourceBuiltIn")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root
|
||||
.GetDirectory("project");
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("migrate")
|
||||
.Should().Pass();
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("restore")
|
||||
.Should().Pass();
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("build -c Debug")
|
||||
.Should().Pass();
|
||||
|
||||
if (!EnvironmentInfo.HasSharedFramework("netcoreapp1.1"))
|
||||
{
|
||||
// running the app requires netcoreapp1.1
|
||||
return;
|
||||
}
|
||||
|
||||
var cmd = new DotnetCommand(DotnetUnderTest.WithBackwardsCompatibleRuntimes)
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.ExecuteWithCapturedOutput("run -c Debug");
|
||||
cmd.Should().Pass();
|
||||
// Issue: https://github.com/dotnet/cli/issues/5467
|
||||
//cmd.StdOut.Should().Contain("2 Resources Found:");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenMigratingDeprecatedResourceExcludeOptionsWarningsArePrinted()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedResourceExclude")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root;
|
||||
|
||||
var cmd = new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.ExecuteWithCapturedOutput("migrate");
|
||||
|
||||
cmd.Should().Pass();
|
||||
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'resourceExclude' option is deprecated. Use 'embed' in 'buildOptions' instead.");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MigratingDeprecatedResourceExclude()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedResourceExclude")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root;
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("migrate")
|
||||
.Should().Pass();
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("restore")
|
||||
.Should().Pass();
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("build -c Debug")
|
||||
.Should().Pass();
|
||||
|
||||
if (!EnvironmentInfo.HasSharedFramework("netcoreapp1.1"))
|
||||
{
|
||||
// running the app requires netcoreapp1.1
|
||||
return;
|
||||
}
|
||||
|
||||
var cmd = new DotnetCommand(DotnetUnderTest.WithBackwardsCompatibleRuntimes)
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.ExecuteWithCapturedOutput("run -c Debug");
|
||||
cmd.Should().Pass();
|
||||
cmd.StdOut.Should().Contain("0 Resources Found:");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,36 +14,6 @@ namespace Microsoft.DotNet.Migration.Tests
|
|||
{
|
||||
public class GivenThatIWantToMigrateSolutions : TestBase
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("PJAppWithSlnVersion14", "Visual Studio 15", "15.0.26114.2", "10.0.40219.1")]
|
||||
[InlineData("PJAppWithSlnVersion15", "Visual Studio 15 Custom", "15.9.12345.4", "10.9.1234.5")]
|
||||
[InlineData("PJAppWithSlnVersionUnknown", "Visual Studio 15", "15.0.26114.2", "10.0.40219.1")]
|
||||
public void ItMigratesSlnAndEnsuresAtLeastVS15(
|
||||
string projectName,
|
||||
string productDescription,
|
||||
string visualStudioVersion,
|
||||
string minVisualStudioVersion)
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, projectName)
|
||||
.CreateInstance(identifier: projectName)
|
||||
.WithSourceFiles()
|
||||
.WithEmptyGlobalJson()
|
||||
.Root;
|
||||
|
||||
var solutionRelPath = "TestApp.sln";
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute($"migrate \"{solutionRelPath}\"")
|
||||
.Should().Pass();
|
||||
|
||||
SlnFile slnFile = SlnFile.Read(Path.Combine(projectDirectory.FullName, solutionRelPath));
|
||||
slnFile.ProductDescription.Should().Be(productDescription);
|
||||
slnFile.VisualStudioVersion.Should().Be(visualStudioVersion);
|
||||
slnFile.MinimumVisualStudioVersion.Should().Be(minVisualStudioVersion);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItMigratesAndBuildsSln()
|
||||
{
|
||||
|
@ -52,208 +22,6 @@ namespace Microsoft.DotNet.Migration.Tests
|
|||
"PJAppWithSlnAndXprojRefs");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItOnlyMigratesProjectsInTheSlnFile()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithSlnAndXprojRefs")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.WithEmptyGlobalJson()
|
||||
.Root;
|
||||
|
||||
var solutionRelPath = Path.Combine("TestApp", "TestApp.sln");
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute($"migrate \"{solutionRelPath}\"")
|
||||
.Should().Pass();
|
||||
|
||||
projectDirectory
|
||||
.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")
|
||||
});
|
||||
|
||||
projectDirectory
|
||||
.Should().NotHaveFile(Path.Combine("TestApp", "TestAssets", "TestAsset", "TestAsset.csproj"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenDirectoryAlreadyContainsCsprojFileItMigratesAndBuildsSln()
|
||||
{
|
||||
MigrateAndBuild(
|
||||
"NonRestoredTestProjects",
|
||||
"PJAppWithSlnAndXprojRefsAndUnrelatedCsproj");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenXprojReferencesCsprojAndSlnDoesNotItMigratesAndBuildsSln()
|
||||
{
|
||||
MigrateAndBuild(
|
||||
"NonRestoredTestProjects",
|
||||
"PJAppWithSlnThatDoesNotRefCsproj");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenSolutionContainsACsprojFileItGetsMovedToBackup()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson("NonRestoredTestProjects", "PJAppWithSlnAndOneAlreadyMigratedCsproj")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.WithEmptyGlobalJson()
|
||||
.Root;
|
||||
|
||||
var solutionRelPath = Path.Combine("TestApp", "TestApp.sln");
|
||||
|
||||
var cmd = new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.ExecuteWithCapturedOutput($"migrate \"{solutionRelPath}\"");
|
||||
|
||||
cmd.Should().Pass();
|
||||
|
||||
projectDirectory
|
||||
.GetDirectory("TestLibrary")
|
||||
.GetFile("TestLibrary.csproj")
|
||||
.Should().Exist();
|
||||
|
||||
projectDirectory
|
||||
.GetDirectory("TestLibrary")
|
||||
.GetFile("TestLibrary.csproj.migration_in_place_backup")
|
||||
.Should().NotExist();
|
||||
|
||||
projectDirectory
|
||||
.GetDirectory("backup", "TestLibrary")
|
||||
.GetFile("TestLibrary.csproj")
|
||||
.Should().Exist();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenSolutionContainsACsprojFileItDoesNotTryToAddItAgain()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithSlnAndOneAlreadyMigratedCsproj")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.WithEmptyGlobalJson()
|
||||
.Root;
|
||||
|
||||
var solutionRelPath = Path.Combine("TestApp", "TestApp.sln");
|
||||
|
||||
var cmd = new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.ExecuteWithCapturedOutput($"migrate \"{solutionRelPath}\"");
|
||||
|
||||
cmd.Should().Pass();
|
||||
cmd.StdOut.Should().NotContain("already contains project");
|
||||
cmd.StdErr.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("NoSolutionItemsAfterMigration.sln", false)]
|
||||
[InlineData("ReadmeSolutionItemAfterMigration.sln", true)]
|
||||
public void WhenMigratingAnSlnLinksReferencingItemsMovedToBackupAreRemoved(
|
||||
string slnFileName,
|
||||
bool solutionItemsContainsReadme)
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithSlnAndSolutionItemsToMoveToBackup")
|
||||
.CreateInstance(Path.GetFileNameWithoutExtension(slnFileName))
|
||||
.WithSourceFiles()
|
||||
.Root
|
||||
.FullName;
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute($"migrate \"{slnFileName}\"")
|
||||
.Should().Pass();
|
||||
|
||||
var slnFile = SlnFile.Read(Path.Combine(projectDirectory, slnFileName));
|
||||
var solutionFolders = slnFile.Projects.Where(p => p.TypeGuid == ProjectTypeGuids.SolutionFolderGuid);
|
||||
if (solutionItemsContainsReadme)
|
||||
{
|
||||
solutionFolders.Count().Should().Be(1);
|
||||
var solutionItems = solutionFolders.Single().Sections.GetSection("SolutionItems");
|
||||
solutionItems.Should().NotBeNull();
|
||||
solutionItems.Properties.Count().Should().Be(1);
|
||||
solutionItems.Properties["readme.txt"].Should().Be("readme.txt");
|
||||
}
|
||||
else
|
||||
{
|
||||
solutionFolders.Count().Should().Be(0);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItMigratesSolutionInTheFolderWhenWeRunMigrationInThatFolder()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.Get("NonRestoredTestProjects", "PJAppWithSlnAndXprojRefs")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.WithEmptyGlobalJson()
|
||||
.Root;
|
||||
|
||||
var workingDirectory = new DirectoryInfo(Path.Combine(projectDirectory.FullName, "TestApp"));
|
||||
var solutionRelPath = Path.Combine("TestApp", "TestApp.sln");
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(workingDirectory)
|
||||
.Execute($"migrate")
|
||||
.Should().Pass();
|
||||
|
||||
SlnFile slnFile = SlnFile.Read(Path.Combine(projectDirectory.FullName, solutionRelPath));
|
||||
|
||||
var nonSolutionFolderProjects = slnFile.Projects
|
||||
.Where(p => p.TypeGuid != ProjectTypeGuids.SolutionFolderGuid);
|
||||
|
||||
nonSolutionFolderProjects.Count().Should().Be(4);
|
||||
|
||||
var slnProject = nonSolutionFolderProjects.Where((p) => p.Name == "TestApp").Single();
|
||||
slnProject.TypeGuid.Should().Be(ProjectTypeGuids.CSharpProjectTypeGuid);
|
||||
slnProject.FilePath.Should().Be("TestApp.csproj");
|
||||
|
||||
slnProject = nonSolutionFolderProjects.Where((p) => p.Name == "TestLibrary").Single();
|
||||
slnProject.TypeGuid.Should().Be(ProjectTypeGuids.CSharpProjectTypeGuid);
|
||||
slnProject.FilePath.Should().Be(Path.Combine("..", "TestLibrary", "TestLibrary.csproj"));
|
||||
|
||||
slnProject = nonSolutionFolderProjects.Where((p) => p.Name == "subdir").Single();
|
||||
slnProject.FilePath.Should().Be(Path.Combine("src", "subdir", "subdir.csproj"));
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute($"restore \"{solutionRelPath}\"")
|
||||
.Should().Pass();
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute($"build \"{solutionRelPath}\"")
|
||||
.Should().Pass();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenXprojNameIsDifferentThanDirNameItGetsRemovedFromSln()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.Get("NonRestoredTestProjects", "PJAppWithXprojNameDifferentThanDirName")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root;
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute($"migrate")
|
||||
.Should().Pass();
|
||||
|
||||
var slnFile = SlnFile.Read(Path.Combine(projectDirectory.FullName, "FolderHasDifferentName.sln"));
|
||||
slnFile.Projects.Count.Should().Be(1);
|
||||
slnFile.Projects[0].FilePath.Should().Be("PJAppWithXprojNameDifferentThanDirName.csproj");
|
||||
}
|
||||
|
||||
private void MigrateAndBuild(string groupName, string projectName, [CallerMemberName] string callingMethod = "", string identifier = "")
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue