dotnet-installer/test/dotnet-run.Tests/RunTests.cs
2016-02-22 15:11:24 -08:00

54 lines
2.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 Microsoft.DotNet.Tools.Test.Utilities;
using Xunit;
namespace Microsoft.DotNet.Tools.Compiler.Tests
{
public class CompilerTests : TestBase
{
private static const string RunTestsBase = "RunTestsApps";
[WindowsOnlyFact]
public void RunsSingleTarget()
{
TestInstance instance = TestAssetsManager.CreateTestInstance(Path.Combine(RunTestsBase, "TestAppDesktopClr"))
.WithLockFiles()
.WithBuildArtifacts();
new RunCommand(testInstance.TestRoot).Execute().Should().Pass();
}
public void RunsDefaultWhenPresent()
{
TestInstance instance = TestAssetsManager.CreateTestInstance(Path.Combine(RunTestsBase, "TestAppMultiTarget"))
.WithLockFiles()
.WithBuildArtifacts();
new RunCommand(testInstance.TestRoot).Execute().Should().Pass();
}
public void FailsWithMultipleTargetAndNoDefault()
{
TestInstance instance = TestAssetsManager.CreateTestInstance(RunTestsBase, "TestAppMultiTargetNoCoreClr")
.WithLockFiles()
.WithBuildArtifacts();
new RunCommand(testInstance.TestRoot).Execute().Should().Fail();
}
private void CopyProjectToTempDir(string projectDir, TempDirectory tempDir)
{
// copy all the files to temp dir
foreach (var file in Directory.EnumerateFiles(projectDir))
{
tempDir.CopyFile(file);
}
}
private string GetProjectPath(TempDirectory projectDir)
{
return Path.Combine(projectDir.Path, "project.json");
}
}
}