dotnet-installer/test/dotnet-build.Tests/GivenDotnetBuildBuildsCsproj.cs
Krzysztof Wicher a6bc22e499 Remove TAM (#5670)
* remove reference to TestAssetsManager in dotnet-add-reference

* remove TestAssetsManager dependency from dotnet-build

* remove TAM ref from dotnet-list-reference

* remove TAM dependency from dotnet-msbuild

* remove TAM dependency from ProjectJsonMigration tests

* remove TAM dependency from dotnet.Tests

* remove TAM dependency from dotnet-new.Tests

* remove TAM from dotnet-pack.Tests

* remove TAM from dotnet-publish.Tests

* remove TAM from dotnet-restore.Tests

* remove TAM dependency from dotnet-remove-reference.Tests

* remove TAM dependency from dotnet-run.Tests

* remove TAM dependency from dotnet-test.Tests

* remove TAM dependency from Microsoft.DotNet.Cli.Utils.Tests

* remove TAM from TestBase

* remove TAM

* remove newly introduced dependency on TAM
2017-02-15 15:35:03 -08:00

97 lines
3.1 KiB
C#

// 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;
using System.IO;
using FluentAssertions;
using Microsoft.DotNet.Tools.Test.Utilities;
using Xunit;
using System.Linq;
namespace Microsoft.DotNet.Cli.Build.Tests
{
public class GivenDotnetBuildBuildsCsproj : TestBase
{
[Fact]
public void ItBuildsARunnableOutput()
{
var testAppName = "MSBuildTestApp";
var testInstance = TestAssets.Get(testAppName)
.CreateInstance(testAppName)
.WithSourceFiles()
.WithRestoreFiles();
new BuildCommand()
.WithWorkingDirectory(testInstance.Root)
.Execute()
.Should().Pass();
var configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";
var outputDll = testInstance.Root.GetDirectory("bin", configuration, "netcoreapp1.0")
.GetFile($"{testAppName}.dll");
var outputRunCommand = new TestCommand("dotnet");
outputRunCommand.ExecuteWithCapturedOutput(outputDll.FullName)
.Should().Pass()
.And.HaveStdOutContaining("Hello World");
}
[Fact]
public void ItRunsWhenRestoringToSpecificPackageDir()
{
var rootPath = TestAssets.CreateTestDirectory().FullName;
string dir = "pkgs";
string args = $"--packages {dir}";
string newArgs = $"console -o \"{rootPath}\" --debug:ephemeral-hive";
new NewCommandShim()
.WithWorkingDirectory(rootPath)
.Execute(newArgs)
.Should()
.Pass();
new RestoreCommand()
.WithWorkingDirectory(rootPath)
.Execute(args)
.Should()
.Pass()
.And.NotHaveStdErr();
new BuildCommand()
.WithWorkingDirectory(rootPath)
.Execute()
.Should().Pass();
var outputDll = Directory.EnumerateFiles(Path.Combine(rootPath, "bin"), "*.dll", SearchOption.AllDirectories).Single();
var outputRunCommand = new TestCommand("dotnet");
outputRunCommand.ExecuteWithCapturedOutput(outputDll)
.Should().Pass()
.And.HaveStdOutContaining("Hello World");
}
[Fact]
public void ItPrintsBuildSummary()
{
var testAppName = "MSBuildTestApp";
var testInstance = TestAssets.Get(testAppName)
.CreateInstance(testAppName)
.WithSourceFiles()
.WithRestoreFiles();
string expectedBuildSummary = @"Build succeeded.
0 Warning(s)
0 Error(s)";
var cmd = new BuildCommand()
.WithWorkingDirectory(testInstance.Root)
.ExecuteWithCapturedOutput();
cmd.Should().Pass();
cmd.StdOut.Should().ContainVisuallySameFragment(expectedBuildSummary);
}
}
}