2016-04-18 17:51:15 +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 System.IO;
|
2016-04-28 23:30:32 +00:00
|
|
|
using FluentAssertions;
|
2016-04-18 17:51:15 +00:00
|
|
|
using Microsoft.DotNet.ProjectModel;
|
|
|
|
using Microsoft.DotNet.TestFramework;
|
2016-04-28 23:30:32 +00:00
|
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
2016-04-18 17:51:15 +00:00
|
|
|
using NuGet.Frameworks;
|
2016-04-28 23:30:32 +00:00
|
|
|
using Xunit;
|
2016-04-18 17:51:15 +00:00
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Cli.Utils.Tests
|
|
|
|
{
|
|
|
|
public class GivenAProjectDependenciesCommandFactory : TestBase
|
|
|
|
{
|
2016-04-20 23:05:53 +00:00
|
|
|
private static readonly NuGetFramework s_desktopTestFramework = FrameworkConstants.CommonFrameworks.Net451;
|
|
|
|
|
2016-04-18 17:51:15 +00:00
|
|
|
[WindowsOnlyFact]
|
2016-04-20 17:47:50 +00:00
|
|
|
public void It_resolves_desktop_apps_defaulting_to_Debug_Configuration()
|
2016-04-18 17:51:15 +00:00
|
|
|
{
|
|
|
|
var configuration = "Debug";
|
|
|
|
|
|
|
|
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects"));
|
2016-08-18 17:17:58 +00:00
|
|
|
var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDepDesktopAndPortable")
|
2016-04-18 17:51:15 +00:00
|
|
|
.WithLockFiles();
|
|
|
|
|
|
|
|
var buildCommand = new BuildCommand(
|
2016-04-20 23:05:53 +00:00
|
|
|
Path.Combine(testInstance.TestRoot, "project.json"),
|
2016-04-18 17:51:15 +00:00
|
|
|
configuration: configuration)
|
|
|
|
.ExecuteWithCapturedOutput()
|
|
|
|
.Should()
|
|
|
|
.Pass();
|
|
|
|
|
|
|
|
var context = ProjectContext.Create(testInstance.TestRoot, s_desktopTestFramework);
|
|
|
|
|
|
|
|
var factory = new ProjectDependenciesCommandFactory(
|
|
|
|
s_desktopTestFramework,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
testInstance.TestRoot);
|
|
|
|
|
|
|
|
var command = factory.Create("dotnet-desktop-and-portable", null);
|
|
|
|
|
|
|
|
command.CommandName.Should().Contain(Path.Combine(testInstance.TestRoot, "bin", configuration));
|
|
|
|
Path.GetFileName(command.CommandName).Should().Be("dotnet-desktop-and-portable.exe");
|
|
|
|
}
|
|
|
|
|
|
|
|
[WindowsOnlyFact]
|
2016-04-20 17:47:50 +00:00
|
|
|
public void It_resolves_desktop_apps_when_configuration_is_Debug()
|
2016-04-18 17:51:15 +00:00
|
|
|
{
|
|
|
|
var configuration = "Debug";
|
|
|
|
|
|
|
|
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects"));
|
2016-08-18 17:17:58 +00:00
|
|
|
var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDepDesktopAndPortable")
|
2016-04-18 17:51:15 +00:00
|
|
|
.WithLockFiles();
|
|
|
|
|
|
|
|
var buildCommand = new BuildCommand(
|
2016-04-20 23:05:53 +00:00
|
|
|
Path.Combine(testInstance.TestRoot, "project.json"),
|
2016-04-18 17:51:15 +00:00
|
|
|
configuration: configuration)
|
|
|
|
.ExecuteWithCapturedOutput()
|
|
|
|
.Should()
|
|
|
|
.Pass();
|
|
|
|
|
|
|
|
var context = ProjectContext.Create(testInstance.TestRoot, s_desktopTestFramework);
|
|
|
|
|
|
|
|
var factory = new ProjectDependenciesCommandFactory(
|
|
|
|
s_desktopTestFramework,
|
|
|
|
configuration,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
testInstance.TestRoot);
|
|
|
|
|
|
|
|
var command = factory.Create("dotnet-desktop-and-portable", null);
|
|
|
|
|
|
|
|
command.CommandName.Should().Contain(Path.Combine(testInstance.TestRoot, "bin", configuration));
|
|
|
|
Path.GetFileName(command.CommandName).Should().Be("dotnet-desktop-and-portable.exe");
|
|
|
|
}
|
|
|
|
|
|
|
|
[WindowsOnlyFact]
|
2016-04-20 17:47:50 +00:00
|
|
|
public void It_resolves_desktop_apps_when_configuration_is_Release()
|
2016-04-18 17:51:15 +00:00
|
|
|
{
|
|
|
|
var configuration = "Release";
|
|
|
|
|
|
|
|
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects"));
|
2016-08-18 17:17:58 +00:00
|
|
|
var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDepDesktopAndPortable")
|
2016-04-18 17:51:15 +00:00
|
|
|
.WithLockFiles();
|
|
|
|
|
|
|
|
var buildCommand = new BuildCommand(
|
2016-04-20 23:05:53 +00:00
|
|
|
Path.Combine(testInstance.TestRoot, "project.json"),
|
2016-04-18 17:51:15 +00:00
|
|
|
configuration: configuration)
|
|
|
|
.ExecuteWithCapturedOutput()
|
|
|
|
.Should()
|
|
|
|
.Pass();
|
|
|
|
|
|
|
|
var context = ProjectContext.Create(testInstance.TestRoot, s_desktopTestFramework);
|
|
|
|
|
|
|
|
var factory = new ProjectDependenciesCommandFactory(
|
|
|
|
s_desktopTestFramework,
|
|
|
|
configuration,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
testInstance.TestRoot);
|
|
|
|
|
|
|
|
var command = factory.Create("dotnet-desktop-and-portable", null);
|
|
|
|
|
|
|
|
command.CommandName.Should().Contain(Path.Combine(testInstance.TestRoot, "bin", configuration));
|
|
|
|
Path.GetFileName(command.CommandName).Should().Be("dotnet-desktop-and-portable.exe");
|
|
|
|
}
|
|
|
|
|
|
|
|
[WindowsOnlyFact]
|
2016-04-20 17:47:50 +00:00
|
|
|
public void It_resolves_desktop_apps_using_configuration_passed_to_create()
|
2016-04-18 17:51:15 +00:00
|
|
|
{
|
|
|
|
var configuration = "Release";
|
|
|
|
|
|
|
|
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects"));
|
2016-08-18 17:17:58 +00:00
|
|
|
var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDepDesktopAndPortable")
|
2016-04-18 17:51:15 +00:00
|
|
|
.WithLockFiles();
|
|
|
|
|
|
|
|
var buildCommand = new BuildCommand(
|
2016-04-20 23:05:53 +00:00
|
|
|
Path.Combine(testInstance.TestRoot, "project.json"),
|
2016-04-18 17:51:15 +00:00
|
|
|
configuration: configuration)
|
|
|
|
.ExecuteWithCapturedOutput()
|
|
|
|
.Should()
|
|
|
|
.Pass();
|
|
|
|
|
|
|
|
var context = ProjectContext.Create(testInstance.TestRoot, s_desktopTestFramework);
|
|
|
|
|
|
|
|
var factory = new ProjectDependenciesCommandFactory(
|
|
|
|
s_desktopTestFramework,
|
|
|
|
"Debug",
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
testInstance.TestRoot);
|
|
|
|
|
|
|
|
var command = factory.Create("dotnet-desktop-and-portable", null, configuration: configuration);
|
|
|
|
|
|
|
|
command.CommandName.Should().Contain(Path.Combine(testInstance.TestRoot, "bin", configuration));
|
|
|
|
Path.GetFileName(command.CommandName).Should().Be("dotnet-desktop-and-portable.exe");
|
|
|
|
}
|
2016-04-20 23:05:53 +00:00
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void It_resolves_tools_whose_package_name_is_different_than_dll_name()
|
|
|
|
{
|
|
|
|
var configuration = "Debug";
|
|
|
|
|
|
|
|
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "TestProjects"));
|
2016-08-18 17:17:58 +00:00
|
|
|
var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDepWithOutputName")
|
2016-04-20 23:05:53 +00:00
|
|
|
.WithLockFiles();
|
|
|
|
|
|
|
|
var buildCommand = new BuildCommand(
|
|
|
|
Path.Combine(testInstance.TestRoot, "project.json"),
|
|
|
|
configuration: configuration)
|
|
|
|
.ExecuteWithCapturedOutput()
|
|
|
|
.Should()
|
|
|
|
.Pass();
|
|
|
|
|
|
|
|
var context = ProjectContext.Create(testInstance.TestRoot, FrameworkConstants.CommonFrameworks.NetCoreApp10);
|
|
|
|
|
|
|
|
var factory = new ProjectDependenciesCommandFactory(
|
|
|
|
FrameworkConstants.CommonFrameworks.NetCoreApp10,
|
|
|
|
configuration,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
testInstance.TestRoot);
|
|
|
|
|
|
|
|
var command = factory.Create("dotnet-tool-with-output-name", null);
|
|
|
|
|
|
|
|
command.CommandArgs.Should().Contain(
|
2016-07-26 12:47:14 +00:00
|
|
|
Path.Combine("toolwithoutputname", "1.0.0", "lib", "netcoreapp1.0", "dotnet-tool-with-output-name.dll"));
|
2016-04-20 23:05:53 +00:00
|
|
|
}
|
2016-04-18 17:51:15 +00:00
|
|
|
}
|
|
|
|
}
|