From 72c59c4d05d09b4bdb3fa76abfcf3a01b4ad5362 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Thu, 21 Jul 2016 15:04:05 -0500 Subject: [PATCH] Add test for MSBuild End to End. --- .../MSBuildTestApp/MSBuildTestApp.csproj | 34 ++------------ test/EndToEnd/GivenDotNetUsesMSBuild.cs | 46 +++++++++++++++++++ .../Commands/Build3Command.cs | 30 ++++++++++++ .../Commands/Run3Command.cs | 30 ++++++++++++ .../TempFileSystem/TempRoot.cs | 2 +- 5 files changed, 111 insertions(+), 31 deletions(-) create mode 100644 test/EndToEnd/GivenDotNetUsesMSBuild.cs create mode 100644 test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/Build3Command.cs create mode 100644 test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/Run3Command.cs diff --git a/TestAssets/TestProjects/MSBuildTestApp/MSBuildTestApp.csproj b/TestAssets/TestProjects/MSBuildTestApp/MSBuildTestApp.csproj index ed112f20e..5df78bcbd 100644 --- a/TestAssets/TestProjects/MSBuildTestApp/MSBuildTestApp.csproj +++ b/TestAssets/TestProjects/MSBuildTestApp/MSBuildTestApp.csproj @@ -1,44 +1,18 @@ - - - + + - Debug - x64 - x64 Exe - MSBuildTestApp - $(MSBuildThisFileName) - NETCoreApp + .NETCoreApp v1.0 bin\$(Configuration)\netcoreapp1.0 - false - true - true - true - .NETCoreApp,Version=v1.0 - - win7 - false - none + - - - $(DotnetHostPath) - - - - - - - - - \ No newline at end of file diff --git a/test/EndToEnd/GivenDotNetUsesMSBuild.cs b/test/EndToEnd/GivenDotNetUsesMSBuild.cs new file mode 100644 index 000000000..24a85fa11 --- /dev/null +++ b/test/EndToEnd/GivenDotNetUsesMSBuild.cs @@ -0,0 +1,46 @@ +// 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 Microsoft.DotNet.Tools.Test.Utilities; +using Xunit; + +namespace Microsoft.DotNet.Tests.EndToEnd +{ + public class GivenDotNetUsesMSBuild : TestBase + { + [Fact] + public void ItCanNewRestoreBuildRunMSBuildProject() + { + using (DisposableDirectory directory = Temp.CreateDirectory()) + { + string projectDirectory = directory.Path; + + new NewCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("-t msbuild") + .Should() + .Pass(); + + new RestoreCommand() + .WithWorkingDirectory(projectDirectory) + .Execute() + .Should() + .Pass(); + + new Build3Command() + .WithWorkingDirectory(projectDirectory) + .Execute() + .Should() + .Pass(); + + new Run3Command() + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput() + .Should() + .Pass() + .And + .HaveStdOutContaining("Hello World!"); + } + } + } +} diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/Build3Command.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/Build3Command.cs new file mode 100644 index 000000000..39eb4a415 --- /dev/null +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/Build3Command.cs @@ -0,0 +1,30 @@ +// 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 Microsoft.DotNet.Cli.Utils; +using System.Runtime.InteropServices; +using Microsoft.DotNet.ProjectModel; + +namespace Microsoft.DotNet.Tools.Test.Utilities +{ + public sealed class Build3Command : TestCommand + { + public Build3Command() + : base("dotnet") + { + } + + public override CommandResult Execute(string args = "") + { + args = $"build3 {args}"; + return base.Execute(args); + } + + public override CommandResult ExecuteWithCapturedOutput(string args = "") + { + args = $"build3 {args}"; + return base.ExecuteWithCapturedOutput(args); + } + } +} diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/Run3Command.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/Run3Command.cs new file mode 100644 index 000000000..0d1bb39fa --- /dev/null +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/Run3Command.cs @@ -0,0 +1,30 @@ +// 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 Microsoft.DotNet.Cli.Utils; +using System.Runtime.InteropServices; +using Microsoft.DotNet.ProjectModel; + +namespace Microsoft.DotNet.Tools.Test.Utilities +{ + public sealed class Run3Command : TestCommand + { + public Run3Command() + : base("dotnet") + { + } + + public override CommandResult Execute(string args = "") + { + args = $"run3 {args}"; + return base.Execute(args); + } + + public override CommandResult ExecuteWithCapturedOutput(string args = "") + { + args = $"run3 {args}"; + return base.ExecuteWithCapturedOutput(args); + } + } +} diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/TempRoot.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/TempRoot.cs index 0cff5cb32..58e426b47 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/TempRoot.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/TempRoot.cs @@ -55,7 +55,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities } } - public TempDirectory CreateDirectory() + public DisposableDirectory CreateDirectory() { var dir = new DisposableDirectory(this); _temps.Add(dir);