Merge pull request #4059 from dotnet/piotrpMSFT/TestAssetManager
Migrate to Test Asset Manager
This commit is contained in:
commit
08fe61aa00
24 changed files with 201 additions and 175 deletions
|
@ -21,7 +21,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
var configuration = "Debug";
|
var configuration = "Debug";
|
||||||
|
|
||||||
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects"));
|
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects"));
|
||||||
var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDependencyDesktopAndPortable")
|
var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDepDesktopAndPortable")
|
||||||
.WithLockFiles();
|
.WithLockFiles();
|
||||||
|
|
||||||
var buildCommand = new BuildCommand(
|
var buildCommand = new BuildCommand(
|
||||||
|
@ -52,7 +52,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
var configuration = "Debug";
|
var configuration = "Debug";
|
||||||
|
|
||||||
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects"));
|
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects"));
|
||||||
var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDependencyDesktopAndPortable")
|
var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDepDesktopAndPortable")
|
||||||
.WithLockFiles();
|
.WithLockFiles();
|
||||||
|
|
||||||
var buildCommand = new BuildCommand(
|
var buildCommand = new BuildCommand(
|
||||||
|
@ -83,7 +83,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
var configuration = "Release";
|
var configuration = "Release";
|
||||||
|
|
||||||
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects"));
|
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects"));
|
||||||
var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDependencyDesktopAndPortable")
|
var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDepDesktopAndPortable")
|
||||||
.WithLockFiles();
|
.WithLockFiles();
|
||||||
|
|
||||||
var buildCommand = new BuildCommand(
|
var buildCommand = new BuildCommand(
|
||||||
|
@ -114,7 +114,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
var configuration = "Release";
|
var configuration = "Release";
|
||||||
|
|
||||||
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects"));
|
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects"));
|
||||||
var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDependencyDesktopAndPortable")
|
var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDepDesktopAndPortable")
|
||||||
.WithLockFiles();
|
.WithLockFiles();
|
||||||
|
|
||||||
var buildCommand = new BuildCommand(
|
var buildCommand = new BuildCommand(
|
||||||
|
@ -145,7 +145,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
var configuration = "Debug";
|
var configuration = "Debug";
|
||||||
|
|
||||||
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "TestProjects"));
|
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "TestProjects"));
|
||||||
var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDependencyWithOutputName")
|
var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDepWithOutputName")
|
||||||
.WithLockFiles();
|
.WithLockFiles();
|
||||||
|
|
||||||
var buildCommand = new BuildCommand(
|
var buildCommand = new BuildCommand(
|
||||||
|
|
|
@ -12,11 +12,10 @@ using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli.Utils.Tests
|
namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
{
|
{
|
||||||
public class GivenAProjectDependenciesCommandResolver
|
public class GivenAProjectDependenciesCommandResolver : TestBase
|
||||||
{
|
{
|
||||||
|
|
||||||
private static readonly string s_liveProjectDirectory =
|
private const string TestProjectName = "AppWithDirectDep";
|
||||||
Path.Combine(AppContext.BaseDirectory, "TestAssets/TestProjects/AppWithDirectDependency");
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void It_returns_null_when_CommandName_is_null()
|
public void It_returns_null_when_CommandName_is_null()
|
||||||
|
@ -61,11 +60,14 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
{
|
{
|
||||||
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
|
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
|
||||||
|
|
||||||
|
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
var commandResolverArguments = new CommandResolverArguments()
|
var commandResolverArguments = new CommandResolverArguments()
|
||||||
{
|
{
|
||||||
CommandName = "command",
|
CommandName = "command",
|
||||||
CommandArguments = new string[] { "" },
|
CommandArguments = new string[] { "" },
|
||||||
ProjectDirectory = s_liveProjectDirectory,
|
ProjectDirectory = testInstance.Path,
|
||||||
Configuration = "Debug",
|
Configuration = "Debug",
|
||||||
Framework = null
|
Framework = null
|
||||||
};
|
};
|
||||||
|
@ -80,11 +82,14 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
{
|
{
|
||||||
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
|
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
|
||||||
|
|
||||||
|
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
var commandResolverArguments = new CommandResolverArguments()
|
var commandResolverArguments = new CommandResolverArguments()
|
||||||
{
|
{
|
||||||
CommandName = "command",
|
CommandName = "command",
|
||||||
CommandArguments = new string[] { "" },
|
CommandArguments = new string[] { "" },
|
||||||
ProjectDirectory = s_liveProjectDirectory,
|
ProjectDirectory = testInstance.Path,
|
||||||
Configuration = null,
|
Configuration = null,
|
||||||
Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10
|
Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10
|
||||||
};
|
};
|
||||||
|
@ -99,11 +104,14 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
{
|
{
|
||||||
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
|
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
|
||||||
|
|
||||||
|
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
var commandResolverArguments = new CommandResolverArguments()
|
var commandResolverArguments = new CommandResolverArguments()
|
||||||
{
|
{
|
||||||
CommandName = "nonexistent-command",
|
CommandName = "nonexistent-command",
|
||||||
CommandArguments = null,
|
CommandArguments = null,
|
||||||
ProjectDirectory = s_liveProjectDirectory,
|
ProjectDirectory = testInstance.Path,
|
||||||
Configuration = "Debug",
|
Configuration = "Debug",
|
||||||
Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10
|
Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10
|
||||||
};
|
};
|
||||||
|
@ -118,11 +126,15 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
{
|
{
|
||||||
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
|
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
|
||||||
|
|
||||||
|
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
|
||||||
|
.WithBuildArtifacts()
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
var commandResolverArguments = new CommandResolverArguments()
|
var commandResolverArguments = new CommandResolverArguments()
|
||||||
{
|
{
|
||||||
CommandName = "dotnet-hello",
|
CommandName = "dotnet-hello",
|
||||||
CommandArguments = null,
|
CommandArguments = null,
|
||||||
ProjectDirectory = s_liveProjectDirectory,
|
ProjectDirectory = testInstance.Path,
|
||||||
Configuration = "Debug",
|
Configuration = "Debug",
|
||||||
Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10
|
Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10
|
||||||
};
|
};
|
||||||
|
@ -143,11 +155,15 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
{
|
{
|
||||||
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
|
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
|
||||||
|
|
||||||
|
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
|
||||||
|
.WithBuildArtifacts()
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
var commandResolverArguments = new CommandResolverArguments()
|
var commandResolverArguments = new CommandResolverArguments()
|
||||||
{
|
{
|
||||||
CommandName = "dotnet-hello",
|
CommandName = "dotnet-hello",
|
||||||
CommandArguments = new[] { "arg with space" },
|
CommandArguments = new[] { "arg with space" },
|
||||||
ProjectDirectory = s_liveProjectDirectory,
|
ProjectDirectory = testInstance.Path,
|
||||||
Configuration = "Debug",
|
Configuration = "Debug",
|
||||||
Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10
|
Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10
|
||||||
};
|
};
|
||||||
|
@ -159,15 +175,19 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void It_passes_depsfile_arg_to_host_when_returning_a_commandspec()
|
public void It_passes_depsfile_arg_to_host_when_returning_a_CommandSpec()
|
||||||
{
|
{
|
||||||
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
|
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
|
||||||
|
|
||||||
|
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
|
||||||
|
.WithBuildArtifacts()
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
var commandResolverArguments = new CommandResolverArguments()
|
var commandResolverArguments = new CommandResolverArguments()
|
||||||
{
|
{
|
||||||
CommandName = "dotnet-hello",
|
CommandName = "dotnet-hello",
|
||||||
CommandArguments = null,
|
CommandArguments = null,
|
||||||
ProjectDirectory = s_liveProjectDirectory,
|
ProjectDirectory = testInstance.Path,
|
||||||
Configuration = "Debug",
|
Configuration = "Debug",
|
||||||
Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10
|
Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10
|
||||||
};
|
};
|
||||||
|
@ -182,26 +202,30 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
public void It_sets_depsfile_in_output_path_in_commandspec()
|
public void It_sets_depsfile_in_output_path_in_commandspec()
|
||||||
{
|
{
|
||||||
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
|
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
|
||||||
var outputDir = Path.Combine(AppContext.BaseDirectory, "outdir");
|
|
||||||
|
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
|
var outputDir = Path.Combine(testInstance.Path, "outdir");
|
||||||
|
|
||||||
var commandResolverArguments = new CommandResolverArguments
|
var commandResolverArguments = new CommandResolverArguments
|
||||||
{
|
{
|
||||||
CommandName = "dotnet-hello",
|
CommandName = "dotnet-hello",
|
||||||
CommandArguments = null,
|
CommandArguments = null,
|
||||||
ProjectDirectory = s_liveProjectDirectory,
|
ProjectDirectory = testInstance.Path,
|
||||||
Configuration = "Debug",
|
Configuration = "Debug",
|
||||||
Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10,
|
Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10,
|
||||||
OutputPath = outputDir
|
OutputPath = outputDir
|
||||||
};
|
};
|
||||||
|
|
||||||
var buildCommand = new BuildCommand(
|
var buildCommand = new BuildCommand(
|
||||||
Path.Combine(s_liveProjectDirectory, "project.json"),
|
Path.Combine(testInstance.Path, "project.json"),
|
||||||
output: outputDir,
|
output: outputDir,
|
||||||
framework: FrameworkConstants.CommonFrameworks.NetCoreApp10.ToString())
|
framework: FrameworkConstants.CommonFrameworks.NetCoreApp10.ToString())
|
||||||
.Execute().Should().Pass();
|
.Execute().Should().Pass();
|
||||||
|
|
||||||
var projectContext = ProjectContext.Create(
|
var projectContext = ProjectContext.Create(
|
||||||
s_liveProjectDirectory,
|
testInstance.Path,
|
||||||
FrameworkConstants.CommonFrameworks.NetCoreApp10,
|
FrameworkConstants.CommonFrameworks.NetCoreApp10,
|
||||||
RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers());
|
RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers());
|
||||||
|
|
||||||
|
@ -218,26 +242,30 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
public void It_sets_depsfile_in_build_base_path_in_commandspec()
|
public void It_sets_depsfile_in_build_base_path_in_commandspec()
|
||||||
{
|
{
|
||||||
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
|
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
|
||||||
var buildBasePath = Path.Combine(AppContext.BaseDirectory, "basedir");
|
|
||||||
|
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
|
var buildBasePath = Path.Combine(testInstance.Path, "basedir");
|
||||||
|
|
||||||
var commandResolverArguments = new CommandResolverArguments
|
var commandResolverArguments = new CommandResolverArguments
|
||||||
{
|
{
|
||||||
CommandName = "dotnet-hello",
|
CommandName = "dotnet-hello",
|
||||||
CommandArguments = null,
|
CommandArguments = null,
|
||||||
ProjectDirectory = s_liveProjectDirectory,
|
ProjectDirectory = testInstance.Path,
|
||||||
Configuration = "Debug",
|
Configuration = "Debug",
|
||||||
Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10,
|
Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10,
|
||||||
BuildBasePath = buildBasePath
|
BuildBasePath = buildBasePath
|
||||||
};
|
};
|
||||||
|
|
||||||
var buildCommand = new BuildCommand(
|
var buildCommand = new BuildCommand(
|
||||||
Path.Combine(s_liveProjectDirectory, "project.json"),
|
Path.Combine(testInstance.Path, "project.json"),
|
||||||
buildBasePath: buildBasePath,
|
buildBasePath: buildBasePath,
|
||||||
framework: FrameworkConstants.CommonFrameworks.NetCoreApp10.ToString())
|
framework: FrameworkConstants.CommonFrameworks.NetCoreApp10.ToString())
|
||||||
.Execute().Should().Pass();
|
.Execute().Should().Pass();
|
||||||
|
|
||||||
var projectContext = ProjectContext.Create(
|
var projectContext = ProjectContext.Create(
|
||||||
s_liveProjectDirectory,
|
testInstance.Path,
|
||||||
FrameworkConstants.CommonFrameworks.NetCoreApp10,
|
FrameworkConstants.CommonFrameworks.NetCoreApp10,
|
||||||
RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers());
|
RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers());
|
||||||
|
|
||||||
|
@ -255,11 +283,15 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
{
|
{
|
||||||
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
|
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
|
||||||
|
|
||||||
|
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
|
||||||
|
.WithBuildArtifacts()
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
var commandResolverArguments = new CommandResolverArguments()
|
var commandResolverArguments = new CommandResolverArguments()
|
||||||
{
|
{
|
||||||
CommandName = "dotnet-hello",
|
CommandName = "dotnet-hello",
|
||||||
CommandArguments = null,
|
CommandArguments = null,
|
||||||
ProjectDirectory = s_liveProjectDirectory,
|
ProjectDirectory = testInstance.Path,
|
||||||
Configuration = "Debug",
|
Configuration = "Debug",
|
||||||
Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10
|
Framework = FrameworkConstants.CommonFrameworks.NetCoreApp10
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,6 +7,7 @@ using System.Linq;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Microsoft.DotNet.ProjectModel;
|
using Microsoft.DotNet.ProjectModel;
|
||||||
using Microsoft.DotNet.ProjectModel.Graph;
|
using Microsoft.DotNet.ProjectModel.Graph;
|
||||||
|
using Microsoft.DotNet.TestFramework;
|
||||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||||
using NuGet.Frameworks;
|
using NuGet.Frameworks;
|
||||||
using NuGet.Versioning;
|
using NuGet.Versioning;
|
||||||
|
@ -14,12 +15,11 @@ using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli.Utils.Tests
|
namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
{
|
{
|
||||||
public class GivenAProjectToolsCommandResolver
|
public class GivenAProjectToolsCommandResolver : TestBase
|
||||||
{
|
{
|
||||||
private static readonly NuGetFramework s_toolPackageFramework = FrameworkConstants.CommonFrameworks.NetCoreApp10;
|
private static readonly NuGetFramework s_toolPackageFramework = FrameworkConstants.CommonFrameworks.NetCoreApp10;
|
||||||
|
|
||||||
private static readonly string s_liveProjectDirectory =
|
private const string TestProjectName = "AppWithToolDependency";
|
||||||
Path.Combine(AppContext.BaseDirectory, "TestAssets/TestProjects/AppWithToolDependency");
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void It_returns_null_when_CommandName_is_null()
|
public void It_returns_null_when_CommandName_is_null()
|
||||||
|
@ -60,11 +60,14 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
{
|
{
|
||||||
var projectToolsCommandResolver = SetupProjectToolsCommandResolver();
|
var projectToolsCommandResolver = SetupProjectToolsCommandResolver();
|
||||||
|
|
||||||
|
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
var commandResolverArguments = new CommandResolverArguments()
|
var commandResolverArguments = new CommandResolverArguments()
|
||||||
{
|
{
|
||||||
CommandName = "nonexistent-command",
|
CommandName = "nonexistent-command",
|
||||||
CommandArguments = null,
|
CommandArguments = null,
|
||||||
ProjectDirectory = s_liveProjectDirectory
|
ProjectDirectory = testInstance.Path
|
||||||
};
|
};
|
||||||
|
|
||||||
var result = projectToolsCommandResolver.Resolve(commandResolverArguments);
|
var result = projectToolsCommandResolver.Resolve(commandResolverArguments);
|
||||||
|
@ -77,11 +80,14 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
{
|
{
|
||||||
var projectToolsCommandResolver = SetupProjectToolsCommandResolver();
|
var projectToolsCommandResolver = SetupProjectToolsCommandResolver();
|
||||||
|
|
||||||
|
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
var commandResolverArguments = new CommandResolverArguments()
|
var commandResolverArguments = new CommandResolverArguments()
|
||||||
{
|
{
|
||||||
CommandName = "dotnet-portable",
|
CommandName = "dotnet-portable",
|
||||||
CommandArguments = null,
|
CommandArguments = null,
|
||||||
ProjectDirectory = s_liveProjectDirectory
|
ProjectDirectory = testInstance.Path
|
||||||
};
|
};
|
||||||
|
|
||||||
var result = projectToolsCommandResolver.Resolve(commandResolverArguments);
|
var result = projectToolsCommandResolver.Resolve(commandResolverArguments);
|
||||||
|
@ -100,11 +106,14 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
{
|
{
|
||||||
var projectToolsCommandResolver = SetupProjectToolsCommandResolver();
|
var projectToolsCommandResolver = SetupProjectToolsCommandResolver();
|
||||||
|
|
||||||
|
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
var commandResolverArguments = new CommandResolverArguments()
|
var commandResolverArguments = new CommandResolverArguments()
|
||||||
{
|
{
|
||||||
CommandName = "dotnet-portable",
|
CommandName = "dotnet-portable",
|
||||||
CommandArguments = new[] { "arg with space" },
|
CommandArguments = new[] { "arg with space" },
|
||||||
ProjectDirectory = s_liveProjectDirectory
|
ProjectDirectory = testInstance.Path
|
||||||
};
|
};
|
||||||
|
|
||||||
var result = projectToolsCommandResolver.Resolve(commandResolverArguments);
|
var result = projectToolsCommandResolver.Resolve(commandResolverArguments);
|
||||||
|
@ -118,11 +127,14 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
{
|
{
|
||||||
var projectToolsCommandResolver = SetupProjectToolsCommandResolver();
|
var projectToolsCommandResolver = SetupProjectToolsCommandResolver();
|
||||||
|
|
||||||
|
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
var commandResolverArguments = new CommandResolverArguments()
|
var commandResolverArguments = new CommandResolverArguments()
|
||||||
{
|
{
|
||||||
CommandName = "dotnet-portable",
|
CommandName = "dotnet-portable",
|
||||||
CommandArguments = null,
|
CommandArguments = null,
|
||||||
ProjectDirectory = s_liveProjectDirectory
|
ProjectDirectory = testInstance.Path
|
||||||
};
|
};
|
||||||
|
|
||||||
var result = projectToolsCommandResolver.Resolve(commandResolverArguments);
|
var result = projectToolsCommandResolver.Resolve(commandResolverArguments);
|
||||||
|
@ -138,14 +150,17 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
{
|
{
|
||||||
var projectToolsCommandResolver = SetupProjectToolsCommandResolver();
|
var projectToolsCommandResolver = SetupProjectToolsCommandResolver();
|
||||||
|
|
||||||
|
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
var commandResolverArguments = new CommandResolverArguments()
|
var commandResolverArguments = new CommandResolverArguments()
|
||||||
{
|
{
|
||||||
CommandName = "dotnet-portable",
|
CommandName = "dotnet-portable",
|
||||||
CommandArguments = null,
|
CommandArguments = null,
|
||||||
ProjectDirectory = s_liveProjectDirectory
|
ProjectDirectory = testInstance.Path
|
||||||
};
|
};
|
||||||
|
|
||||||
var context = ProjectContext.Create(Path.Combine(s_liveProjectDirectory, "project.json"), s_toolPackageFramework);
|
var context = ProjectContext.Create(Path.Combine(testInstance.Path, "project.json"), s_toolPackageFramework);
|
||||||
|
|
||||||
var nugetPackagesRoot = context.PackagesDirectory;
|
var nugetPackagesRoot = context.PackagesDirectory;
|
||||||
var toolPathCalculator = new ToolPathCalculator(nugetPackagesRoot);
|
var toolPathCalculator = new ToolPathCalculator(nugetPackagesRoot);
|
||||||
|
@ -180,7 +195,10 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Generate_deps_json_method_doesnt_overwrite_when_deps_file_already_exists()
|
public void Generate_deps_json_method_doesnt_overwrite_when_deps_file_already_exists()
|
||||||
{
|
{
|
||||||
var context = ProjectContext.Create(Path.Combine(s_liveProjectDirectory, "project.json"), s_toolPackageFramework);
|
var testInstance = TestAssetsManager.CreateTestInstance(TestProjectName)
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
|
var context = ProjectContext.Create(Path.Combine(testInstance.Path, "project.json"), s_toolPackageFramework);
|
||||||
|
|
||||||
var nugetPackagesRoot = context.PackagesDirectory;
|
var nugetPackagesRoot = context.PackagesDirectory;
|
||||||
var toolPathCalculator = new ToolPathCalculator(nugetPackagesRoot);
|
var toolPathCalculator = new ToolPathCalculator(nugetPackagesRoot);
|
||||||
|
|
|
@ -14,20 +14,12 @@ namespace StreamForwarderTests
|
||||||
public class StreamForwarderTests : TestBase
|
public class StreamForwarderTests : TestBase
|
||||||
{
|
{
|
||||||
private static readonly string s_rid = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier();
|
private static readonly string s_rid = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier();
|
||||||
private static readonly string s_testProjectRoot = Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects");
|
|
||||||
|
|
||||||
private TempDirectory _root;
|
|
||||||
|
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
Console.WriteLine("Dummy Entrypoint");
|
Console.WriteLine("Dummy Entrypoint");
|
||||||
}
|
}
|
||||||
|
|
||||||
public StreamForwarderTests()
|
|
||||||
{
|
|
||||||
_root = Temp.CreateDirectory();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IEnumerable<object[]> ForwardingTheoryVariations
|
public static IEnumerable<object[]> ForwardingTheoryVariations
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -127,15 +119,15 @@ namespace StreamForwarderTests
|
||||||
|
|
||||||
private string SetupTestProject()
|
private string SetupTestProject()
|
||||||
{
|
{
|
||||||
var sourceTestProjectPath = Path.Combine(s_testProjectRoot, "OutputStandardOutputAndError");
|
|
||||||
|
|
||||||
var binTestProjectPath = _root.CopyDirectory(sourceTestProjectPath).Path;
|
var testInstance = TestAssetsManager.CreateTestInstance("OutputStandardOutputAndError")
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
var buildCommand = new BuildCommand(Path.Combine(binTestProjectPath, "project.json"));
|
var buildCommand = new BuildCommand(Path.Combine(testInstance.Path, "project.json"));
|
||||||
buildCommand.Execute();
|
buildCommand.Execute();
|
||||||
|
|
||||||
var buildOutputExe = "OutputStandardOutputAndError" + Constants.ExeSuffix;
|
var buildOutputExe = "OutputStandardOutputAndError" + Constants.ExeSuffix;
|
||||||
var buildOutputPath = Path.Combine(binTestProjectPath, "bin/Debug/netcoreapp1.0", buildOutputExe);
|
var buildOutputPath = Path.Combine(testInstance.Path, "bin/Debug/netcoreapp1.0", buildOutputExe);
|
||||||
|
|
||||||
return buildOutputPath;
|
return buildOutputPath;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,24 +7,18 @@ namespace Microsoft.DotNet.ProjectModel.Tests
|
||||||
{
|
{
|
||||||
public class LibraryExporterTests : TestBase
|
public class LibraryExporterTests : TestBase
|
||||||
{
|
{
|
||||||
private readonly string _testProjectsRoot;
|
|
||||||
|
|
||||||
public LibraryExporterTests()
|
|
||||||
{
|
|
||||||
_testProjectsRoot = Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void GetLibraryExportsWithoutLockFile()
|
public void GetLibraryExportsWithoutLockFile()
|
||||||
{
|
{
|
||||||
var root = Temp.CreateDirectory().CopyDirectory(Path.Combine(_testProjectsRoot, "TestAppWithLibrary"));
|
|
||||||
|
|
||||||
foreach (var lockfile in Directory.GetFiles(root.Path, "project.lock.json"))
|
var testInstance = TestAssetsManager.CreateTestInstance("TestAppWithLibrary");
|
||||||
|
|
||||||
|
foreach (var lockfile in Directory.GetFiles(testInstance.Path, "project.lock.json"))
|
||||||
{
|
{
|
||||||
File.Delete(lockfile);
|
File.Delete(lockfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
var builder = new ProjectContextBuilder().WithProjectDirectory(Path.Combine(root.Path, "TestApp"));
|
var builder = new ProjectContextBuilder().WithProjectDirectory(Path.Combine(testInstance.Path, "TestApp"));
|
||||||
|
|
||||||
foreach (var context in builder.BuildAllTargets())
|
foreach (var context in builder.BuildAllTargets())
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,28 +13,18 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
|
||||||
{
|
{
|
||||||
public class CompilerTests : TestBase
|
public class CompilerTests : TestBase
|
||||||
{
|
{
|
||||||
private readonly string _testProjectsRoot;
|
|
||||||
|
|
||||||
public CompilerTests()
|
|
||||||
{
|
|
||||||
_testProjectsRoot = Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void XmlDocumentationFileIsGenerated()
|
public void XmlDocumentationFileIsGenerated()
|
||||||
{
|
{
|
||||||
// create unique directories in the 'temp' folder
|
var testInstance = TestAssetsManager
|
||||||
var root = Temp.CreateDirectory();
|
.CreateTestInstance("TestAppWithLibrary")
|
||||||
root.CopyFile(Path.Combine(_testProjectsRoot, "global.json"));
|
.WithLockFiles();
|
||||||
|
|
||||||
var testLibDir = root.CreateDirectory("TestLibrary");
|
var testLibDir = Path.Combine(testInstance.TestRoot, "TestLibrary");
|
||||||
var sourceTestLibDir = Path.Combine(_testProjectsRoot, "TestAppWithLibrary", "TestLibrary");
|
|
||||||
|
|
||||||
CopyProjectToTempDir(sourceTestLibDir, testLibDir);
|
|
||||||
|
|
||||||
// run compile
|
// run compile
|
||||||
var outputDir = Path.Combine(testLibDir.Path, "bin");
|
var outputDir = Path.Combine(testLibDir, "bin");
|
||||||
var testProject = GetProjectPath(testLibDir);
|
var testProject = Path.Combine(testLibDir, "project.json");
|
||||||
var buildCommand = new BuildCommand(testProject, output: outputDir, framework: DefaultLibraryFramework);
|
var buildCommand = new BuildCommand(testProject, output: outputDir, framework: DefaultLibraryFramework);
|
||||||
var result = buildCommand.ExecuteWithCapturedOutput();
|
var result = buildCommand.ExecuteWithCapturedOutput();
|
||||||
result.Should().Pass();
|
result.Should().Pass();
|
||||||
|
@ -49,16 +39,15 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void SatelliteAssemblyIsGeneratedByDotnetBuild()
|
public void SatelliteAssemblyIsGeneratedByDotnetBuild()
|
||||||
{
|
{
|
||||||
// create unique directories in the 'temp' folder
|
var testInstance = TestAssetsManager
|
||||||
var root = Temp.CreateDirectory();
|
.CreateTestInstance("TestProjectWithCultureSpecificResource")
|
||||||
var testLibDir = root.CreateDirectory("TestProjectWithCultureSpecificResource");
|
.WithLockFiles();
|
||||||
var sourceTestLibDir = Path.Combine(_testProjectsRoot, "TestProjectWithCultureSpecificResource");
|
|
||||||
|
|
||||||
CopyProjectToTempDir(sourceTestLibDir, testLibDir);
|
var testLibDir = testInstance.TestRoot;
|
||||||
|
|
||||||
// run compile on a project with resources
|
// run compile on a project with resources
|
||||||
var outputDir = Path.Combine(testLibDir.Path, "bin");
|
var outputDir = Path.Combine(testLibDir, "bin");
|
||||||
var testProject = GetProjectPath(testLibDir);
|
var testProject = Path.Combine(testLibDir, "project.json");
|
||||||
var buildCmd = new BuildCommand(testProject, output: outputDir, framework: DefaultFramework);
|
var buildCmd = new BuildCommand(testProject, output: outputDir, framework: DefaultFramework);
|
||||||
var result = buildCmd.ExecuteWithCapturedOutput();
|
var result = buildCmd.ExecuteWithCapturedOutput();
|
||||||
result.Should().Pass();
|
result.Should().Pass();
|
||||||
|
@ -75,15 +64,15 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void LibraryWithAnalyzer()
|
public void LibraryWithAnalyzer()
|
||||||
{
|
{
|
||||||
var root = Temp.CreateDirectory();
|
var testInstance = TestAssetsManager
|
||||||
var testLibDir = root.CreateDirectory("TestLibraryWithAnalyzer");
|
.CreateTestInstance("TestLibraryWithAnalyzer")
|
||||||
var sourceTestLibDir = Path.Combine(_testProjectsRoot, "TestLibraryWithAnalyzer");
|
.WithLockFiles();
|
||||||
|
|
||||||
CopyProjectToTempDir(sourceTestLibDir, testLibDir);
|
var testLibDir = testInstance.TestRoot;
|
||||||
|
|
||||||
// run compile
|
// run compile
|
||||||
var outputDir = Path.Combine(testLibDir.Path, "bin");
|
var outputDir = Path.Combine(testLibDir, "bin");
|
||||||
var testProject = GetProjectPath(testLibDir);
|
var testProject = Path.Combine(testLibDir, "project.json");
|
||||||
var buildCmd = new BuildCommand(testProject, output: outputDir, framework: DefaultLibraryFramework);
|
var buildCmd = new BuildCommand(testProject, output: outputDir, framework: DefaultLibraryFramework);
|
||||||
var result = buildCmd.ExecuteWithCapturedOutput();
|
var result = buildCmd.ExecuteWithCapturedOutput();
|
||||||
result.Should().Pass();
|
result.Should().Pass();
|
||||||
|
@ -96,12 +85,15 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
|
||||||
{
|
{
|
||||||
var root = Temp.CreateDirectory();
|
var root = Temp.CreateDirectory();
|
||||||
|
|
||||||
var spaceBufferDirectory = root.CreateDirectory("space directory");
|
var testInstance = TestAssetsManager
|
||||||
var testAppDir = spaceBufferDirectory.CreateDirectory("TestAppCompilationContext");
|
.CreateTestInstance("TestAppCompilationContext", identifier: "A SPACE")
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
CopyProjectToTempDir(Path.Combine(_testProjectsRoot, "TestAppCompilationContext"), testAppDir);
|
var testProjectDir = Path.Combine(
|
||||||
|
Directory.GetParent(testInstance.TestRoot).FullName,
|
||||||
|
"TestAppCompilationContext",
|
||||||
|
"TestApp");
|
||||||
|
|
||||||
var testProjectDir = Path.Combine(_testProjectsRoot, "TestAppCompilationContext", "TestApp");
|
|
||||||
var testProject = Path.Combine(testProjectDir, "project.json");
|
var testProject = Path.Combine(testProjectDir, "project.json");
|
||||||
|
|
||||||
var buildCommand = new BuildCommand(testProject);
|
var buildCommand = new BuildCommand(testProject);
|
||||||
|
|
|
@ -17,49 +17,41 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
|
||||||
{
|
{
|
||||||
private readonly string _testProjectsRoot;
|
private readonly string _testProjectsRoot;
|
||||||
|
|
||||||
public PackTests()
|
|
||||||
{
|
|
||||||
_testProjectsRoot = Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void OutputsPackagesToConfigurationSubdirWhenOutputParameterIsNotPassed()
|
public void OutputsPackagesToConfigurationSubdirWhenOutputParameterIsNotPassed()
|
||||||
{
|
{
|
||||||
var root = Temp.CreateDirectory();
|
var testInstance = TestAssetsManager
|
||||||
|
.CreateTestInstance("TestLibraryWithConfiguration")
|
||||||
|
.WithBuildArtifacts()
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
var testLibDir = root.CreateDirectory("TestLibrary");
|
var testProject = Path.Combine(testInstance.Path, "project.json");
|
||||||
var sourceTestLibDir = Path.Combine(_testProjectsRoot, "TestLibraryWithConfiguration");
|
|
||||||
|
|
||||||
CopyProjectToTempDir(sourceTestLibDir, testLibDir);
|
|
||||||
|
|
||||||
var testProject = GetProjectPath(testLibDir);
|
|
||||||
var packCommand = new PackCommand(testProject, configuration: "Test");
|
var packCommand = new PackCommand(testProject, configuration: "Test");
|
||||||
var result = packCommand.Execute();
|
var result = packCommand.Execute();
|
||||||
result.Should().Pass();
|
result.Should().Pass();
|
||||||
|
|
||||||
var outputDir = new DirectoryInfo(Path.Combine(testLibDir.Path, "bin", "Test"));
|
var outputDir = new DirectoryInfo(Path.Combine(testInstance.Path, "bin", "Test"));
|
||||||
outputDir.Should().Exist();
|
outputDir.Should().Exist();
|
||||||
outputDir.Should().HaveFiles(new [] { "TestLibrary.1.0.0.nupkg" , "TestLibrary.1.0.0.symbols.nupkg" });
|
outputDir.Should().HaveFiles(new [] { "TestLibraryWithConfiguration.1.0.0.nupkg" , "TestLibraryWithConfiguration.1.0.0.symbols.nupkg" });
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void OutputsPackagesFlatIntoOutputDirWhenOutputParameterIsPassed()
|
public void OutputsPackagesFlatIntoOutputDirWhenOutputParameterIsPassed()
|
||||||
{
|
{
|
||||||
var root = Temp.CreateDirectory();
|
var testInstance = TestAssetsManager
|
||||||
|
.CreateTestInstance("TestLibraryWithConfiguration")
|
||||||
|
.WithBuildArtifacts()
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
var testLibDir = root.CreateDirectory("TestLibrary");
|
var testProject = Path.Combine(testInstance.Path, "project.json");
|
||||||
var sourceTestLibDir = Path.Combine(_testProjectsRoot, "TestLibraryWithConfiguration");
|
|
||||||
|
|
||||||
CopyProjectToTempDir(sourceTestLibDir, testLibDir);
|
var outputDir = new DirectoryInfo(Path.Combine(testInstance.Path, "bin2"));
|
||||||
|
|
||||||
var outputDir = new DirectoryInfo(Path.Combine(testLibDir.Path, "bin2"));
|
|
||||||
var testProject = GetProjectPath(testLibDir);
|
|
||||||
var packCommand = new PackCommand(testProject, output: outputDir.FullName);
|
var packCommand = new PackCommand(testProject, output: outputDir.FullName);
|
||||||
var result = packCommand.Execute();
|
var result = packCommand.Execute();
|
||||||
result.Should().Pass();
|
result.Should().Pass();
|
||||||
|
|
||||||
outputDir.Should().Exist();
|
outputDir.Should().Exist();
|
||||||
outputDir.Should().HaveFiles(new[] { "TestLibrary.1.0.0.nupkg", "TestLibrary.1.0.0.symbols.nupkg" });
|
outputDir.Should().HaveFiles(new[] { "TestLibraryWithConfiguration.1.0.0.nupkg", "TestLibraryWithConfiguration.1.0.0.symbols.nupkg" });
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -100,9 +92,10 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void HasIncludedFiles()
|
public void HasIncludedFiles()
|
||||||
{
|
{
|
||||||
var testInstance = TestAssetsManager.CreateTestInstance("EndToEndTestApp")
|
var testInstance = TestAssetsManager
|
||||||
.WithLockFiles()
|
.CreateTestInstance("EndToEndTestApp")
|
||||||
.WithBuildArtifacts();
|
.WithLockFiles()
|
||||||
|
.WithBuildArtifacts();
|
||||||
|
|
||||||
var cmd = new PackCommand(Path.Combine(testInstance.TestRoot, Project.FileName));
|
var cmd = new PackCommand(Path.Combine(testInstance.TestRoot, Project.FileName));
|
||||||
cmd.Execute().Should().Pass();
|
cmd.Execute().Should().Pass();
|
||||||
|
@ -156,27 +149,25 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void HasServiceableFlagWhenArgumentPassed()
|
public void HasServiceableFlagWhenArgumentPassed()
|
||||||
{
|
{
|
||||||
var root = Temp.CreateDirectory();
|
var testInstance = TestAssetsManager
|
||||||
|
.CreateTestInstance("TestLibraryWithConfiguration")
|
||||||
|
.WithBuildArtifacts()
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
var testLibDir = root.CreateDirectory("TestLibrary");
|
var testProject = Path.Combine(testInstance.Path, "project.json");
|
||||||
var sourceTestLibDir = Path.Combine(_testProjectsRoot, "TestLibraryWithConfiguration");
|
|
||||||
|
|
||||||
CopyProjectToTempDir(sourceTestLibDir, testLibDir);
|
|
||||||
|
|
||||||
var testProject = GetProjectPath(testLibDir);
|
|
||||||
var packCommand = new PackCommand(testProject, configuration: "Debug", serviceable: true);
|
var packCommand = new PackCommand(testProject, configuration: "Debug", serviceable: true);
|
||||||
var result = packCommand.Execute();
|
var result = packCommand.Execute();
|
||||||
result.Should().Pass();
|
result.Should().Pass();
|
||||||
|
|
||||||
var outputDir = new DirectoryInfo(Path.Combine(testLibDir.Path, "bin", "Debug"));
|
var outputDir = new DirectoryInfo(Path.Combine(testInstance.Path, "bin", "Debug"));
|
||||||
outputDir.Should().Exist();
|
outputDir.Should().Exist();
|
||||||
outputDir.Should().HaveFiles(new[] { "TestLibrary.1.0.0.nupkg", "TestLibrary.1.0.0.symbols.nupkg" });
|
outputDir.Should().HaveFiles(new[] { "TestLibraryWithConfiguration.1.0.0.nupkg", "TestLibraryWithConfiguration.1.0.0.symbols.nupkg" });
|
||||||
|
|
||||||
var outputPackage = Path.Combine(outputDir.FullName, "TestLibrary.1.0.0.nupkg");
|
var outputPackage = Path.Combine(outputDir.FullName, "TestLibraryWithConfiguration.1.0.0.nupkg");
|
||||||
var zip = ZipFile.Open(outputPackage, ZipArchiveMode.Read);
|
var zip = ZipFile.Open(outputPackage, ZipArchiveMode.Read);
|
||||||
zip.Entries.Should().Contain(e => e.FullName == "TestLibrary.nuspec");
|
zip.Entries.Should().Contain(e => e.FullName == "TestLibraryWithConfiguration.nuspec");
|
||||||
|
|
||||||
var manifestReader = new StreamReader(zip.Entries.First(e => e.FullName == "TestLibrary.nuspec").Open());
|
var manifestReader = new StreamReader(zip.Entries.First(e => e.FullName == "TestLibraryWithConfiguration.nuspec").Open());
|
||||||
var nuspecXml = XDocument.Parse(manifestReader.ReadToEnd());
|
var nuspecXml = XDocument.Parse(manifestReader.ReadToEnd());
|
||||||
var node = nuspecXml.Descendants().Single(e => e.Name.LocalName == "serviceable");
|
var node = nuspecXml.Descendants().Single(e => e.Name.LocalName == "serviceable");
|
||||||
Assert.Equal("true", node.Value);
|
Assert.Equal("true", node.Value);
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void PublishExcludesBuildDependencies()
|
public void PublishExcludesBuildDependencies()
|
||||||
{
|
{
|
||||||
var testInstance = TestAssetsManager.CreateTestInstance("AppWithDirectDependencyAndTypeBuild")
|
var testInstance = TestAssetsManager.CreateTestInstance("AppWithDirectDepAndTypeBuild")
|
||||||
.WithLockFiles();
|
.WithLockFiles();
|
||||||
|
|
||||||
var publishCommand = new PublishCommand(testInstance.TestRoot);
|
var publishCommand = new PublishCommand(testInstance.TestRoot);
|
||||||
|
@ -37,7 +37,7 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
|
||||||
// Check the deps file
|
// Check the deps file
|
||||||
var reader = new DependencyContextJsonReader();
|
var reader = new DependencyContextJsonReader();
|
||||||
DependencyContext context;
|
DependencyContext context;
|
||||||
using (var file = File.OpenRead(Path.Combine(publishDir.FullName, "AppWithDirectDependencyAndTypeBuild.deps.json")))
|
using (var file = File.OpenRead(Path.Combine(publishDir.FullName, "AppWithDirectDepAndTypeBuild.deps.json")))
|
||||||
{
|
{
|
||||||
context = reader.Read(file);
|
context = reader.Read(file);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,14 +14,8 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
|
||||||
{
|
{
|
||||||
public class PublishTests : TestBase
|
public class PublishTests : TestBase
|
||||||
{
|
{
|
||||||
private readonly string _testProjectsRoot;
|
|
||||||
private readonly Func<string, string, string> _getProjectJson = ProjectUtils.GetProjectJson;
|
private readonly Func<string, string, string> _getProjectJson = ProjectUtils.GetProjectJson;
|
||||||
|
|
||||||
public PublishTests()
|
|
||||||
{
|
|
||||||
_testProjectsRoot = Path.Combine(RepoRoot, "TestAssets", "TestProjects");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static readonly dynamic[] CrossPublishTestData = new[]
|
private static readonly dynamic[] CrossPublishTestData = new[]
|
||||||
{
|
{
|
||||||
new
|
new
|
||||||
|
|
|
@ -12,24 +12,16 @@ namespace Microsoft.DotNet.Tools.Resgen.Tests
|
||||||
{
|
{
|
||||||
public class ResgenTests : TestBase
|
public class ResgenTests : TestBase
|
||||||
{
|
{
|
||||||
private readonly string _testProjectsRoot;
|
|
||||||
private readonly TempDirectory _root;
|
|
||||||
|
|
||||||
public ResgenTests()
|
|
||||||
{
|
|
||||||
_testProjectsRoot = Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects");
|
|
||||||
_root = Temp.CreateDirectory();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Test_Build_Project_with_Resources_with_Space_in_Path_Should_Succeed()
|
public void Test_Build_Project_with_Resources_with_Space_in_Path_Should_Succeed()
|
||||||
{
|
{
|
||||||
var spaceBufferDirectory = _root.CreateDirectory("space directory");
|
var testInstance = TestAssetsManager
|
||||||
var testAppDir = spaceBufferDirectory.CreateDirectory("TestProjectWithResource");
|
.CreateTestInstance("TestProjectWithResource", identifier: "A SPACE")
|
||||||
|
.WithBuildArtifacts()
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
CopyProjectToTempDir(Path.Combine(_testProjectsRoot, "TestProjectWithResource"), testAppDir);
|
var testProject = Path.Combine(testInstance.Path, "project.json");
|
||||||
|
|
||||||
var testProject = GetProjectPath(testAppDir);
|
|
||||||
var buildCommand = new BuildCommand(testProject);
|
var buildCommand = new BuildCommand(testProject);
|
||||||
|
|
||||||
buildCommand.Execute().Should().Pass();
|
buildCommand.Execute().Should().Pass();
|
||||||
|
|
|
@ -7,6 +7,7 @@ using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Microsoft.DotNet.Cli.Utils;
|
using Microsoft.DotNet.Cli.Utils;
|
||||||
|
using Microsoft.DotNet.TestFramework;
|
||||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||||
using Microsoft.DotNet.InternalAbstractions;
|
using Microsoft.DotNet.InternalAbstractions;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
@ -15,19 +16,18 @@ namespace Microsoft.DotNet.Tests
|
||||||
{
|
{
|
||||||
public class PackagedCommandTests : TestBase
|
public class PackagedCommandTests : TestBase
|
||||||
{
|
{
|
||||||
private readonly string _testProjectsRoot;
|
private readonly TestAssetsManager _desktopTestAssetsManager = GetTestGroupTestAssetsManager("DesktopTestProjects");
|
||||||
private readonly string _desktopTestProjectsRoot;
|
|
||||||
|
|
||||||
public static IEnumerable<object[]> DependencyToolArguments
|
public static IEnumerable<object[]> DependencyToolArguments
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var rid = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier();
|
var rid = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier();
|
||||||
var projectOutputPath = $"AppWithDirectDependencyDesktopAndPortable\\bin\\Debug\\net451\\{rid}\\dotnet-desktop-and-portable.exe";
|
var projectOutputPath = $"AppWithDirectDepDesktopAndPortable\\bin\\Debug\\net451\\{rid}\\dotnet-desktop-and-portable.exe";
|
||||||
return new[]
|
return new[]
|
||||||
{
|
{
|
||||||
new object[] { ".NETCoreApp,Version=v1.0", "CoreFX", "lib\\netcoreapp1.0\\dotnet-desktop-and-portable.dll", true },
|
new object[] { "CoreFX", ".NETCoreApp,Version=v1.0", "lib\\netcoreapp1.0\\dotnet-desktop-and-portable.dll", true },
|
||||||
new object[] { ".NETFramework,Version=v4.5.1", "NetFX", projectOutputPath, true }
|
new object[] { "NetFX", ".NETFramework,Version=v4.5.1", projectOutputPath, true }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,24 +40,22 @@ namespace Microsoft.DotNet.Tests
|
||||||
var projectOutputPath = $"LibraryWithDirectDependencyDesktopAndPortable\\bin\\Debug\\net451\\dotnet-desktop-and-portable.exe";
|
var projectOutputPath = $"LibraryWithDirectDependencyDesktopAndPortable\\bin\\Debug\\net451\\dotnet-desktop-and-portable.exe";
|
||||||
return new[]
|
return new[]
|
||||||
{
|
{
|
||||||
new object[] { ".NETStandard,Version=v1.6", "CoreFX", "lib\\netstandard1.6\\dotnet-desktop-and-portable.dll", true },
|
new object[] { "CoreFX", ".NETStandard,Version=v1.6", "lib\\netstandard1.6\\dotnet-desktop-and-portable.dll", true },
|
||||||
new object[] { ".NETFramework,Version=v4.5.1", "NetFX", projectOutputPath, true }
|
new object[] { "NetFX", ".NETFramework,Version=v4.5.1", projectOutputPath, true }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PackagedCommandTests()
|
|
||||||
{
|
|
||||||
_testProjectsRoot = Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects");
|
|
||||||
_desktopTestProjectsRoot = Path.Combine(AppContext.BaseDirectory, "TestAssets", "DesktopTestProjects");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("AppWithDirectAndToolDependency")]
|
[InlineData("AppWithDirectAndToolDep")]
|
||||||
[InlineData("AppWithToolDependency")]
|
[InlineData("AppWithToolDependency")]
|
||||||
public void TestProjectToolIsAvailableThroughDriver(string appName)
|
public void TestProjectToolIsAvailableThroughDriver(string appName)
|
||||||
{
|
{
|
||||||
var appDirectory = Path.Combine(_testProjectsRoot, appName);
|
var testInstance = TestAssetsManager
|
||||||
|
.CreateTestInstance(appName, identifier: appName)
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
|
var appDirectory = testInstance.Path;
|
||||||
|
|
||||||
new BuildCommand(Path.Combine(appDirectory, "project.json"))
|
new BuildCommand(Path.Combine(appDirectory, "project.json"))
|
||||||
.Execute()
|
.Execute()
|
||||||
|
@ -75,7 +73,11 @@ namespace Microsoft.DotNet.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void CanInvokeToolWhosePackageNameIsDifferentFromDllName()
|
public void CanInvokeToolWhosePackageNameIsDifferentFromDllName()
|
||||||
{
|
{
|
||||||
var appDirectory = Path.Combine(_testProjectsRoot, "AppWithDependencyOnToolWithOutputName");
|
var testInstance = TestAssetsManager
|
||||||
|
.CreateTestInstance("AppWithDepOnToolWithOutputName")
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
|
var appDirectory = testInstance.Path;
|
||||||
|
|
||||||
new BuildCommand(Path.Combine(appDirectory, "project.json"))
|
new BuildCommand(Path.Combine(appDirectory, "project.json"))
|
||||||
.Execute()
|
.Execute()
|
||||||
|
@ -93,7 +95,12 @@ namespace Microsoft.DotNet.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void CanInvokeToolFromDirectDependenciesIfPackageNameDifferentFromToolName()
|
public void CanInvokeToolFromDirectDependenciesIfPackageNameDifferentFromToolName()
|
||||||
{
|
{
|
||||||
var appDirectory = Path.Combine(_testProjectsRoot, "AppWithDirectDependencyWithOutputName");
|
var testInstance = TestAssetsManager
|
||||||
|
.CreateTestInstance("AppWithDirectDepWithOutputName")
|
||||||
|
.WithBuildArtifacts()
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
|
var appDirectory = testInstance.Path;
|
||||||
const string framework = ".NETCoreApp,Version=v1.0";
|
const string framework = ".NETCoreApp,Version=v1.0";
|
||||||
|
|
||||||
new BuildCommand(Path.Combine(appDirectory, "project.json"))
|
new BuildCommand(Path.Combine(appDirectory, "project.json"))
|
||||||
|
@ -112,14 +119,19 @@ namespace Microsoft.DotNet.Tests
|
||||||
// need conditional theories so we can skip on non-Windows
|
// need conditional theories so we can skip on non-Windows
|
||||||
[Theory]
|
[Theory]
|
||||||
[MemberData("DependencyToolArguments")]
|
[MemberData("DependencyToolArguments")]
|
||||||
public void TestFrameworkSpecificDependencyToolsCanBeInvoked(string framework, string args, string expectedDependencyToolPath, bool windowsOnly)
|
public void TestFrameworkSpecificDependencyToolsCanBeInvoked(string identifier, string framework, string expectedDependencyToolPath, bool windowsOnly)
|
||||||
{
|
{
|
||||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && windowsOnly)
|
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && windowsOnly)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var appDirectory = Path.Combine(_desktopTestProjectsRoot, "AppWithDirectDependencyDesktopAndPortable");
|
var testInstance = _desktopTestAssetsManager
|
||||||
|
.CreateTestInstance("AppWithDirectDepDesktopAndPortable", identifier: identifier)
|
||||||
|
.WithBuildArtifacts()
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
|
var appDirectory = testInstance.Path;
|
||||||
|
|
||||||
new BuildCommand(Path.Combine(appDirectory, "project.json"))
|
new BuildCommand(Path.Combine(appDirectory, "project.json"))
|
||||||
.Execute()
|
.Execute()
|
||||||
|
@ -127,10 +139,10 @@ namespace Microsoft.DotNet.Tests
|
||||||
.Pass();
|
.Pass();
|
||||||
|
|
||||||
CommandResult result = new DependencyToolInvokerCommand { WorkingDirectory = appDirectory }
|
CommandResult result = new DependencyToolInvokerCommand { WorkingDirectory = appDirectory }
|
||||||
.ExecuteWithCapturedOutput("desktop-and-portable", framework, args);
|
.ExecuteWithCapturedOutput("desktop-and-portable", framework, identifier);
|
||||||
|
|
||||||
result.Should().HaveStdOutContaining(framework);
|
result.Should().HaveStdOutContaining(framework);
|
||||||
result.Should().HaveStdOutContaining(args);
|
result.Should().HaveStdOutContaining(identifier);
|
||||||
result.Should().HaveStdOutContaining(expectedDependencyToolPath);
|
result.Should().HaveStdOutContaining(expectedDependencyToolPath);
|
||||||
result.Should().NotHaveStdErr();
|
result.Should().NotHaveStdErr();
|
||||||
result.Should().Pass();
|
result.Should().Pass();
|
||||||
|
@ -138,14 +150,18 @@ namespace Microsoft.DotNet.Tests
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[MemberData("LibraryDependencyToolArguments")]
|
[MemberData("LibraryDependencyToolArguments")]
|
||||||
public void TestFrameworkSpecificLibraryDependencyToolsCannotBeInvoked(string framework, string args, string expectedDependencyToolPath, bool windowsOnly)
|
public void TestFrameworkSpecificLibraryDependencyToolsCannotBeInvoked(string identifier, string framework, string expectedDependencyToolPath, bool windowsOnly)
|
||||||
{
|
{
|
||||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && windowsOnly)
|
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && windowsOnly)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var testInstance = _desktopTestAssetsManager
|
||||||
|
.CreateTestInstance("LibraryWithDirectDependencyDesktopAndPortable", identifier: identifier)
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
var appDirectory = Path.Combine(_desktopTestProjectsRoot, "LibraryWithDirectDependencyDesktopAndPortable");
|
var appDirectory = testInstance.Path;
|
||||||
|
|
||||||
new BuildCommand(Path.Combine(appDirectory, "project.json"))
|
new BuildCommand(Path.Combine(appDirectory, "project.json"))
|
||||||
.Execute()
|
.Execute()
|
||||||
|
@ -153,7 +169,7 @@ namespace Microsoft.DotNet.Tests
|
||||||
.Pass();
|
.Pass();
|
||||||
|
|
||||||
CommandResult result = new DependencyToolInvokerCommand { WorkingDirectory = appDirectory }
|
CommandResult result = new DependencyToolInvokerCommand { WorkingDirectory = appDirectory }
|
||||||
.ExecuteWithCapturedOutput("desktop-and-portable", framework, args);
|
.ExecuteWithCapturedOutput("desktop-and-portable", framework, identifier);
|
||||||
|
|
||||||
result.Should().HaveStdOutContaining("Command not found");
|
result.Should().HaveStdOutContaining("Command not found");
|
||||||
result.Should().Fail();
|
result.Should().Fail();
|
||||||
|
@ -162,7 +178,9 @@ namespace Microsoft.DotNet.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ToolsCanAccessDependencyContextProperly()
|
public void ToolsCanAccessDependencyContextProperly()
|
||||||
{
|
{
|
||||||
var appDirectory = Path.Combine(_testProjectsRoot, "DependencyContextFromTool");
|
var testInstance = TestAssetsManager.CreateTestInstance("DependencyContextFromTool");
|
||||||
|
|
||||||
|
var appDirectory = testInstance.Path;
|
||||||
|
|
||||||
CommandResult result = new DependencyContextTestCommand() { WorkingDirectory = appDirectory }
|
CommandResult result = new DependencyContextTestCommand() { WorkingDirectory = appDirectory }
|
||||||
.Execute(Path.Combine(appDirectory, "project.json"));
|
.Execute(Path.Combine(appDirectory, "project.json"));
|
||||||
|
@ -173,8 +191,11 @@ namespace Microsoft.DotNet.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TestProjectDependencyIsNotAvailableThroughDriver()
|
public void TestProjectDependencyIsNotAvailableThroughDriver()
|
||||||
{
|
{
|
||||||
var appName = "AppWithDirectDependency";
|
var testInstance = TestAssetsManager
|
||||||
var appDirectory = Path.Combine(_testProjectsRoot, appName);
|
.CreateTestInstance("AppWithDirectDep")
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
|
var appDirectory = testInstance.Path;
|
||||||
|
|
||||||
new BuildCommand(Path.Combine(appDirectory, "project.json"))
|
new BuildCommand(Path.Combine(appDirectory, "project.json"))
|
||||||
.Execute()
|
.Execute()
|
||||||
|
|
Loading…
Reference in a new issue