Refactor tests, add coverage for building templates
This commit is contained in:
parent
7b76c6dd89
commit
6fd4a5afad
5 changed files with 300 additions and 241 deletions
94
test/EndToEnd/ProjectBuildTests.cs
Normal file
94
test/EndToEnd/ProjectBuildTests.cs
Normal file
|
@ -0,0 +1,94 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.DotNet.TestFramework;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using Xunit;
|
||||
|
||||
namespace EndToEnd.Tests
|
||||
{
|
||||
|
||||
public class ProjectBuildTests : TestBase
|
||||
{
|
||||
|
||||
[Fact]
|
||||
public void ItCanNewRestoreBuildRunCleanMSBuildProject()
|
||||
{
|
||||
var directory = TestAssets.CreateTestDirectory();
|
||||
string projectDirectory = directory.FullName;
|
||||
|
||||
string newArgs = "console --debug:ephemeral-hive --no-restore";
|
||||
new NewCommandShim()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute(newArgs)
|
||||
.Should().Pass();
|
||||
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
|
||||
new BuildCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
|
||||
var runCommand = new RunCommand()
|
||||
.WithWorkingDirectory(projectDirectory);
|
||||
|
||||
// Set DOTNET_ROOT as workaround for https://github.com/dotnet/cli/issues/10196
|
||||
var dotnetRoot = Path.GetDirectoryName(RepoDirectoriesProvider.DotnetUnderTest);
|
||||
if (!string.IsNullOrEmpty(dotnetRoot))
|
||||
{
|
||||
runCommand = runCommand.WithEnvironmentVariable(Environment.Is64BitProcess ? "DOTNET_ROOT" : "DOTNET_ROOT(x86)",
|
||||
dotnetRoot);
|
||||
}
|
||||
|
||||
runCommand.ExecuteWithCapturedOutput()
|
||||
.Should().Pass()
|
||||
.And.HaveStdOutContaining("Hello World!");
|
||||
|
||||
var binDirectory = new DirectoryInfo(projectDirectory).Sub("bin");
|
||||
binDirectory.Should().HaveFilesMatching("*.dll", SearchOption.AllDirectories);
|
||||
|
||||
new CleanCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
|
||||
binDirectory.Should().NotHaveFilesMatching("*.dll", SearchOption.AllDirectories);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("console")]
|
||||
[InlineData("classlib")]
|
||||
[InlineData("wpf")]
|
||||
[InlineData("winforms")]
|
||||
[InlineData("mstest")]
|
||||
[InlineData("nunit")]
|
||||
//[InlineData("web")]
|
||||
//[InlineData("mvc")]
|
||||
public void ItCanBuildTemplates(string templateName)
|
||||
{
|
||||
var directory = TestAssets.CreateTestDirectory(identifier: templateName);
|
||||
string projectDirectory = directory.FullName;
|
||||
|
||||
string newArgs = $"{templateName} --debug:ephemeral-hive --no-restore";
|
||||
new NewCommandShim()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute(newArgs)
|
||||
.Should().Pass();
|
||||
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
|
||||
new BuildCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue