Merge pull request #4993 from livarcocc/cyclic_dependency_test

Adding a test that validates CLI templates don't depend on CLI packages.
This commit is contained in:
Livar 2016-12-12 15:48:41 -08:00 committed by GitHub
commit 1a49787a1f

View file

@ -21,7 +21,7 @@ namespace Microsoft.DotNet.New.Tests
[InlineData("Web", true)] [InlineData("Web", true)]
[InlineData("Mstest", false)] [InlineData("Mstest", false)]
[InlineData("XUnittest", false)] [InlineData("XUnittest", false)]
public void When_dotnet_build_is_invoked_then_project_restores_and_builds_without_warnings( public void ICanRestoreBuildAndPublishTheAppWithoutWarnings(
string projectType, string projectType,
bool useNuGetConfigForAspNet) bool useNuGetConfigForAspNet)
{ {
@ -36,15 +36,56 @@ namespace Microsoft.DotNet.New.Tests
File.Copy("NuGet.tempaspnetpatch.config", Path.Combine(rootPath, "NuGet.Config")); File.Copy("NuGet.tempaspnetpatch.config", Path.Combine(rootPath, "NuGet.Config"));
} }
new TestCommand("dotnet") { WorkingDirectory = rootPath } new RestoreCommand()
.Execute($"restore /p:SkipInvalidConfigurations=true") .WithWorkingDirectory(rootPath)
.Execute("/p:SkipInvalidConfigurations=true")
.Should().Pass(); .Should().Pass();
var buildResult = new TestCommand("dotnet") new BuildCommand()
.WithWorkingDirectory(rootPath) .WithWorkingDirectory(rootPath)
.ExecuteWithCapturedOutput("build") .ExecuteWithCapturedOutput()
.Should().Pass()
.And.NotHaveStdErr();
new PublishCommand()
.WithWorkingDirectory(rootPath)
.ExecuteWithCapturedOutput()
.Should().Pass() .Should().Pass()
.And.NotHaveStdErr(); .And.NotHaveStdErr();
} }
[Fact]
public void RestoreDoesNotUseAnyCliProducedPackagesOnItsTemplates()
{
var cSharpTemplates = new [] { "Console", "Lib", "Web", "Mstest", "XUnittest" };
var rootPath = TestAssetsManager.CreateTestDirectory().Path;
var packagesDirectory = Path.Combine(rootPath, "packages");
foreach (var cSharpTemplate in cSharpTemplates)
{
var projectFolder = Path.Combine(rootPath, cSharpTemplate);
Directory.CreateDirectory(projectFolder);
CreateAndRestoreNewProject(cSharpTemplate, projectFolder, packagesDirectory);
}
Directory.EnumerateFiles(packagesDirectory, $"*.nupkg", SearchOption.AllDirectories)
.Should().NotContain(p => p.Contains("Microsoft.DotNet.Cli.Utils"));
}
private void CreateAndRestoreNewProject(
string projectType,
string projectFolder,
string packagesDirectory)
{
new TestCommand("dotnet") { WorkingDirectory = projectFolder }
.Execute($"new --type {projectType}")
.Should().Pass();
new RestoreCommand()
.WithWorkingDirectory(projectFolder)
.Execute($"--packages {packagesDirectory} /p:SkipInvalidConfigurations=true")
.Should().Pass();
}
} }
} }