2016-02-19 15:12:04 -08:00
// 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 ;
2016-02-23 11:09:43 -08:00
using Microsoft.DotNet.TestFramework ;
2016-02-19 15:12:04 -08:00
using Microsoft.DotNet.Tools.Test.Utilities ;
using Xunit ;
2016-02-23 11:09:43 -08:00
namespace Microsoft.DotNet.Tools.Run.Tests
2016-02-19 15:12:04 -08:00
{
2016-02-23 11:09:43 -08:00
public class RunTests : TestBase
2016-02-19 15:12:04 -08:00
{
2016-02-23 11:09:43 -08:00
private const string RunTestsBase = "RunTestsApps" ;
2016-02-19 15:12:04 -08:00
[WindowsOnlyFact]
public void RunsSingleTarget ( )
{
2016-02-23 11:09:43 -08:00
TestInstance instance = TestAssetsManager . CreateTestInstance ( Path . Combine ( RunTestsBase , "TestAppFullClr" ) )
2016-02-19 15:12:04 -08:00
. WithLockFiles ( )
. WithBuildArtifacts ( ) ;
2016-02-23 11:09:43 -08:00
new RunCommand ( instance . TestRoot ) . Execute ( ) . Should ( ) . Pass ( ) ;
2016-02-19 15:12:04 -08:00
}
2016-02-23 11:09:43 -08:00
[Fact]
2016-02-19 15:12:04 -08:00
public void RunsDefaultWhenPresent ( )
{
TestInstance instance = TestAssetsManager . CreateTestInstance ( Path . Combine ( RunTestsBase , "TestAppMultiTarget" ) )
. WithLockFiles ( )
. WithBuildArtifacts ( ) ;
2016-02-23 11:09:43 -08:00
new RunCommand ( instance . TestRoot ) . Execute ( ) . Should ( ) . Pass ( ) ;
2016-02-19 15:12:04 -08:00
}
2016-02-23 11:09:43 -08:00
[Fact]
2016-02-19 15:12:04 -08:00
public void FailsWithMultipleTargetAndNoDefault ( )
{
2016-02-23 11:09:43 -08:00
TestInstance instance = TestAssetsManager . CreateTestInstance ( Path . Combine ( RunTestsBase , "TestAppMultiTargetNoCoreClr" ) )
2016-02-19 15:12:04 -08:00
. WithLockFiles ( )
. WithBuildArtifacts ( ) ;
2016-02-23 11:09:43 -08:00
new RunCommand ( instance . TestRoot ) . Execute ( ) . Should ( ) . Fail ( ) ;
2016-02-19 15:12:04 -08:00
}
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" ) ;
}
}
}