Move dotnet-pack.Tests to TestAssetsManager
This commit is contained in:
parent
8c9e1fca90
commit
8fbc227422
1 changed files with 28 additions and 37 deletions
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue