2017-01-19 18:32:32 +00:00
|
|
|
// 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()
|
|
|
|
{
|
2017-01-22 22:40:00 +00:00
|
|
|
var solutionDirectory = TestAssets
|
|
|
|
.GetProjectJson("AppWithPackageNamedAfterFolder")
|
|
|
|
.CreateInstance()
|
|
|
|
.WithSourceFiles()
|
|
|
|
.Root;
|
|
|
|
|
|
|
|
var globalJsonPath = solutionDirectory.GetFile("global.json");
|
2017-01-19 18:32:32 +00:00
|
|
|
|
|
|
|
new TestCommand("dotnet")
|
|
|
|
.WithForwardingToConsole()
|
2017-01-22 22:40:00 +00:00
|
|
|
.Execute($"migrate {globalJsonPath.FullName}")
|
2017-01-19 18:32:32 +00:00
|
|
|
.Should()
|
|
|
|
.Pass();
|
|
|
|
}
|
|
|
|
|
2017-01-19 19:34:37 +00:00
|
|
|
[Fact]
|
|
|
|
public void WhenUsingGlobalJsonItOnlyMigratesProjectsInTheGlobalJsonNode()
|
|
|
|
{
|
2017-01-22 22:40:00 +00:00
|
|
|
var solutionDirectory = TestAssets
|
|
|
|
.GetProjectJson("AppWithPackageNamedAfterFolder")
|
|
|
|
.CreateInstance()
|
|
|
|
.WithSourceFiles()
|
|
|
|
.Root;
|
|
|
|
|
|
|
|
var globalJsonPath = solutionDirectory.GetFile("global.json");
|
2017-01-19 19:34:37 +00:00
|
|
|
|
|
|
|
new TestCommand("dotnet")
|
|
|
|
.WithForwardingToConsole()
|
2017-01-22 22:40:00 +00:00
|
|
|
.Execute($"migrate {globalJsonPath.FullName}")
|
2017-01-19 19:34:37 +00:00
|
|
|
.Should()
|
|
|
|
.Pass();
|
|
|
|
|
2017-01-22 22:40:00 +00:00
|
|
|
solutionDirectory
|
2017-01-19 19:34:37 +00:00
|
|
|
.Should().HaveFiles(new []
|
|
|
|
{
|
|
|
|
Path.Combine("src", "App", "App.csproj"),
|
|
|
|
Path.Combine("test", "App.Tests", "App.Tests.csproj"),
|
|
|
|
Path.Combine("TestAssets", "TestAsset", "project.json")
|
|
|
|
});
|
|
|
|
|
2017-01-22 22:40:00 +00:00
|
|
|
solutionDirectory
|
2017-01-19 19:34:37 +00:00
|
|
|
.Should().NotHaveFile(Path.Combine("TestAssets", "TestAsset", "TestAsset.csproj"));
|
|
|
|
}
|
|
|
|
|
2017-01-19 18:32:32 +00:00
|
|
|
[Fact]
|
|
|
|
public void ItMigratesWhenBeingPassedJustGlobalJson()
|
|
|
|
{
|
2017-01-22 22:40:00 +00:00
|
|
|
var solutionDirectory = TestAssets
|
|
|
|
.GetProjectJson("AppWithPackageNamedAfterFolder")
|
|
|
|
.CreateInstance()
|
|
|
|
.WithSourceFiles()
|
|
|
|
.Root;
|
|
|
|
|
|
|
|
var globalJsonPath = solutionDirectory.GetFile("global.json");
|
2017-01-19 18:32:32 +00:00
|
|
|
|
|
|
|
new TestCommand("dotnet")
|
|
|
|
.WithWorkingDirectory(solutionDirectory)
|
|
|
|
.WithForwardingToConsole()
|
|
|
|
.Execute($"migrate global.json")
|
|
|
|
.Should()
|
|
|
|
.Pass();
|
|
|
|
}
|
|
|
|
}
|
2017-03-03 04:35:20 +00:00
|
|
|
}
|