2016-10-29 00:22:58 +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 Microsoft.DotNet.Tools.Test.Utilities;
|
|
|
|
using System.Linq;
|
|
|
|
using Xunit;
|
|
|
|
using FluentAssertions;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|
|
|
{
|
2016-11-09 17:52:52 +00:00
|
|
|
public class GivenThatIWantToMigrateTools : PackageDependenciesTestBase
|
2016-10-29 00:22:58 +00:00
|
|
|
{
|
2016-10-29 02:09:04 +00:00
|
|
|
[Theory]
|
2017-01-12 03:30:05 +00:00
|
|
|
[InlineData("Microsoft.EntityFrameworkCore.Tools", "1.0.0-preview2-final", "Microsoft.EntityFrameworkCore.Tools", ConstantPackageVersions.AspNetToolsVersion)]
|
|
|
|
[InlineData("Microsoft.VisualStudio.Web.CodeGenerators.Mvc", "1.0.0-preview2-final", "Microsoft.VisualStudio.Web.CodeGeneration.Design", ConstantPackageVersions.AspNetToolsVersion)]
|
|
|
|
[InlineData("Microsoft.VisualStudio.Web.CodeGenerators.Mvc", "1.0.0-*", "Microsoft.VisualStudio.Web.CodeGeneration.Design", ConstantPackageVersions.AspNetToolsVersion)]
|
2017-01-12 07:29:49 +00:00
|
|
|
[InlineData("Microsoft.VisualStudio.Web.CodeGenerators.Mvc", "1.0.1", "Microsoft.VisualStudio.Web.CodeGeneration.Design", ConstantPackageVersions.AspNetToolsVersion)]
|
2017-01-12 03:30:05 +00:00
|
|
|
[InlineData("Microsoft.VisualStudio.Web.CodeGenerators.Mvc", "1.0.0-preview3-final", "Microsoft.VisualStudio.Web.CodeGeneration.Design", ConstantPackageVersions.AspNetToolsVersion)]
|
2017-01-12 07:29:49 +00:00
|
|
|
[InlineData("Microsoft.VisualStudio.Web.CodeGenerators.Mvc", "1.1.0-preview4-final", "Microsoft.VisualStudio.Web.CodeGeneration.Design", ConstantPackageVersions.AspNet110ToolsVersion)]
|
2017-01-12 00:51:45 +00:00
|
|
|
[InlineData("Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Design", "1.1.0-preview4-final", "Microsoft.AspNetCore.Mvc.Razor.ViewCompilation", ConstantPackageVersions.AspNet110ToolsVersion)]
|
2017-02-23 04:07:47 +00:00
|
|
|
[InlineData("Microsoft.VisualStudio.Web.BrowserLink.Loader", "14.0.0-preview2-final", "Microsoft.VisualStudio.Web.BrowserLink", "1.0.1")]
|
|
|
|
[InlineData("Microsoft.VisualStudio.Web.BrowserLink.Loader", "14.0.0-*", "Microsoft.VisualStudio.Web.BrowserLink", "1.0.1")]
|
|
|
|
[InlineData("Microsoft.VisualStudio.Web.BrowserLink.Loader", "14.0.1", "Microsoft.VisualStudio.Web.BrowserLink", "1.0.1")]
|
|
|
|
[InlineData("Microsoft.VisualStudio.Web.BrowserLink.Loader", "14.1.0-preview4-final", "Microsoft.VisualStudio.Web.BrowserLink", "1.1.0")]
|
2017-01-12 03:30:05 +00:00
|
|
|
public void ItMigratesProjectDependenciesToANewNameAndVersion(
|
2016-10-29 02:09:04 +00:00
|
|
|
string sourceToolName,
|
2017-01-12 03:30:05 +00:00
|
|
|
string sourceVersion,
|
2016-10-29 02:09:04 +00:00
|
|
|
string targetToolName,
|
|
|
|
string targetVersion)
|
2016-10-29 00:22:58 +00:00
|
|
|
{
|
2017-01-12 03:30:05 +00:00
|
|
|
var mockProj = RunPackageDependenciesRuleOnPj("{ \"dependencies\": { \"" + sourceToolName + "\" : { \"version\": \"" + sourceVersion + "\", \"type\": \"build\" } } }");
|
2017-03-03 04:35:20 +00:00
|
|
|
|
2016-10-29 02:09:04 +00:00
|
|
|
var packageRef = mockProj.Items.First(i => i.Include == targetToolName && i.ItemType == "PackageReference");
|
2016-10-29 00:22:58 +00:00
|
|
|
|
2017-01-12 03:30:05 +00:00
|
|
|
packageRef.GetMetadataWithName("Version").Value.Should().Be(targetVersion);
|
2016-10-29 00:22:58 +00:00
|
|
|
|
2016-10-29 02:09:04 +00:00
|
|
|
packageRef.GetMetadataWithName("PrivateAssets").Value.Should().NotBeNull().And.Be("All");
|
2016-10-29 00:22:58 +00:00
|
|
|
}
|
|
|
|
|
2016-11-02 18:54:49 +00:00
|
|
|
[Theory]
|
|
|
|
[InlineData("Microsoft.AspNetCore.Razor.Tools")]
|
|
|
|
[InlineData("Microsoft.AspNetCore.Razor.Design")]
|
|
|
|
[InlineData("Microsoft.VisualStudio.Web.CodeGeneration.Tools")]
|
2016-11-09 17:52:52 +00:00
|
|
|
[InlineData("dotnet-test-xunit")]
|
2016-11-11 18:52:33 +00:00
|
|
|
[InlineData("dotnet-test-mstest")]
|
2017-01-12 03:30:05 +00:00
|
|
|
public void ItDoesNotMigrateProjectToolDependencyThatIsNoLongerNeeded(string dependencyName)
|
2016-10-29 00:22:58 +00:00
|
|
|
{
|
|
|
|
var mockProj = RunPackageDependenciesRuleOnPj(@"
|
|
|
|
{
|
|
|
|
""dependencies"": {
|
2016-11-02 18:54:49 +00:00
|
|
|
""" + dependencyName + @""" : {
|
2016-10-29 00:22:58 +00:00
|
|
|
""version"": ""1.0.0-preview2-final"",
|
|
|
|
""type"": ""build""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}");
|
|
|
|
|
2016-10-31 23:34:37 +00:00
|
|
|
var packageRef = mockProj.Items.Where(i =>
|
|
|
|
i.Include != "Microsoft.NET.Sdk" &&
|
|
|
|
i.Include != "NETStandard.Library" &&
|
|
|
|
i.ItemType == "PackageReference").Should().BeEmpty();
|
2016-10-29 00:22:58 +00:00
|
|
|
}
|
|
|
|
|
2016-10-29 02:09:04 +00:00
|
|
|
[Theory]
|
2017-02-12 03:11:14 +00:00
|
|
|
[InlineData("Microsoft.EntityFrameworkCore.Tools.DotNet", "Microsoft.EntityFrameworkCore.Tools.DotNet", ConstantPackageVersions.AspNetToolsVersion)]
|
2016-10-29 02:09:04 +00:00
|
|
|
[InlineData("Microsoft.EntityFrameworkCore.Tools", "Microsoft.EntityFrameworkCore.Tools.DotNet", ConstantPackageVersions.AspNetToolsVersion)]
|
|
|
|
[InlineData("Microsoft.VisualStudio.Web.CodeGeneration.Tools", "Microsoft.VisualStudio.Web.CodeGeneration.Tools", ConstantPackageVersions.AspNetToolsVersion)]
|
|
|
|
[InlineData("Microsoft.DotNet.Watcher.Tools", "Microsoft.DotNet.Watcher.Tools", ConstantPackageVersions.AspNetToolsVersion)]
|
|
|
|
[InlineData("Microsoft.Extensions.SecretManager.Tools", "Microsoft.Extensions.SecretManager.Tools", ConstantPackageVersions.AspNetToolsVersion)]
|
2016-11-04 02:55:52 +00:00
|
|
|
[InlineData("BundlerMinifier.Core", "BundlerMinifier.Core", ConstantPackageVersions.BundleMinifierToolVersion)]
|
2017-01-12 03:30:05 +00:00
|
|
|
public void ItMigratesAspProjectToolsToANewNameAndVersion(
|
2016-10-29 02:09:04 +00:00
|
|
|
string sourceToolName,
|
|
|
|
string targetToolName,
|
|
|
|
string targetVersion)
|
2016-10-29 00:22:58 +00:00
|
|
|
{
|
2016-10-29 02:09:04 +00:00
|
|
|
const string anyVersion = "1.0.0-preview2-final";
|
|
|
|
var mockProj = RunPackageDependenciesRuleOnPj("{ \"tools\": { \"" + sourceToolName + "\": \"" + anyVersion + "\" } }");
|
2017-03-03 04:35:20 +00:00
|
|
|
|
2016-10-29 02:09:04 +00:00
|
|
|
EmitsToolReferences(mockProj, Tuple.Create(targetToolName, targetVersion));
|
2016-10-29 00:22:58 +00:00
|
|
|
}
|
|
|
|
|
2016-11-02 18:54:49 +00:00
|
|
|
[Theory]
|
|
|
|
[InlineData("Microsoft.AspNetCore.Razor.Tools")]
|
|
|
|
[InlineData("Microsoft.AspNetCore.Server.IISIntegration.Tools")]
|
2017-01-12 00:51:45 +00:00
|
|
|
[InlineData("Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Tools")]
|
2017-01-12 03:30:05 +00:00
|
|
|
public void ItDoesNotMigrateAspProjectTool(string toolName)
|
2016-10-29 00:22:58 +00:00
|
|
|
{
|
|
|
|
var mockProj = RunPackageDependenciesRuleOnPj(@"
|
|
|
|
{
|
|
|
|
""tools"": {
|
2016-11-02 18:54:49 +00:00
|
|
|
""" + toolName + @""": ""1.0.0-preview2-final""
|
2016-10-29 00:22:58 +00:00
|
|
|
}
|
|
|
|
}");
|
|
|
|
|
|
|
|
var packageRef = mockProj.Items.Where(i => i.ItemType == "DotNetCliToolReference").Should().BeEmpty();
|
|
|
|
}
|
2017-02-12 03:11:14 +00:00
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void ItMergesEntityFrameworkCoreToolsAndEntityFrameworkCoreToolsDotNet()
|
|
|
|
{
|
|
|
|
var mockProj = RunPackageDependenciesRuleOnPj("{ \"tools\": { \"Microsoft.EntityFrameworkCore.Tools\": \"1.0.0-preview4-final\", \"Microsoft.EntityFrameworkCore.Tools.DotNet\": \"1.0.0-preview4-final\" } }");
|
|
|
|
|
|
|
|
EmitsToolReferences(mockProj, Tuple.Create("Microsoft.EntityFrameworkCore.Tools.DotNet", ConstantPackageVersions.AspNetToolsVersion));
|
|
|
|
}
|
2016-10-29 00:22:58 +00:00
|
|
|
}
|
2017-03-03 04:35:20 +00:00
|
|
|
}
|