2016-04-25 17:56:05 +00: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.IO;
|
2016-04-28 23:30:32 +00:00
|
|
|
using Microsoft.DotNet.InternalAbstractions;
|
2016-04-25 17:56:05 +00:00
|
|
|
using Microsoft.DotNet.TestFramework;
|
2016-04-28 23:30:32 +00:00
|
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
2016-04-25 17:56:05 +00:00
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Tests
|
|
|
|
{
|
|
|
|
public class TestSetupFixture : TestBase
|
|
|
|
{
|
2016-10-11 23:30:15 +00:00
|
|
|
private const string Framework = "net46";
|
2016-04-25 17:56:05 +00:00
|
|
|
private const string Config = "Debug";
|
|
|
|
private const string AppWithConfig = "AppWithRedirectsAndConfig";
|
|
|
|
private const string AppWithoutConfig = "AppWithRedirectsNoConfig";
|
|
|
|
|
2016-04-28 23:30:32 +00:00
|
|
|
private string _Runtime = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier();
|
2016-04-25 17:56:05 +00:00
|
|
|
private string _desktopProjectsRoot = Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects");
|
|
|
|
private string _buildRelativePath;
|
|
|
|
private string _appWithConfigProjectRoot;
|
|
|
|
private string _appWithConfigBuildDir;
|
|
|
|
private string _appWithConfigPublishDir;
|
|
|
|
private string _appWithoutConfigProjectRoot;
|
|
|
|
private string _appWithoutConfigBuildDir;
|
|
|
|
private string _appWithoutConfigPublishDir;
|
|
|
|
private TestInstance _testInstance;
|
|
|
|
|
|
|
|
public string AppWithConfigProjectRoot { get { return _appWithConfigProjectRoot; } }
|
|
|
|
public string AppWithConfigBuildOutput { get; }
|
|
|
|
public string AppWithConfigPublishOutput { get; }
|
|
|
|
public string AppWithoutConfigProjectRoot { get { return _appWithoutConfigProjectRoot; } }
|
|
|
|
public string AppWithoutConfigBuildOutput { get; }
|
|
|
|
public string AppWithoutConfigPublishOutput { get; }
|
|
|
|
|
|
|
|
public TestSetupFixture()
|
|
|
|
{
|
|
|
|
_buildRelativePath = Path.Combine("bin", Config, Framework, _Runtime);
|
|
|
|
var testAssetsMgr = new TestAssetsManager(_desktopProjectsRoot);
|
|
|
|
_testInstance = testAssetsMgr.CreateTestInstance("BindingRedirectSample")
|
|
|
|
.WithLockFiles();
|
|
|
|
|
|
|
|
Setup(AppWithConfig, ref _appWithConfigProjectRoot, ref _appWithConfigBuildDir, ref _appWithConfigPublishDir);
|
|
|
|
Setup(AppWithoutConfig, ref _appWithoutConfigProjectRoot, ref _appWithoutConfigBuildDir, ref _appWithoutConfigPublishDir);
|
|
|
|
|
|
|
|
AppWithConfigBuildOutput = Path.Combine(_appWithConfigBuildDir, AppWithConfig + ".exe");
|
|
|
|
AppWithConfigPublishOutput = Path.Combine(_appWithConfigPublishDir, AppWithConfig + ".exe");
|
|
|
|
AppWithoutConfigBuildOutput = Path.Combine(_appWithoutConfigBuildDir, AppWithoutConfig + ".exe");
|
|
|
|
AppWithoutConfigPublishOutput = Path.Combine(_appWithoutConfigPublishDir, AppWithoutConfig + ".exe");
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Setup(string project, ref string projectDir, ref string buildDir, ref string publishDir)
|
|
|
|
{
|
|
|
|
projectDir = Path.Combine(_testInstance.TestRoot, project);
|
|
|
|
buildDir = Path.Combine(projectDir, _buildRelativePath);
|
|
|
|
publishDir = Path.Combine(projectDir, "publish");
|
|
|
|
|
|
|
|
var buildCommand = new BuildCommand(projectDir, framework: Framework, runtime: _Runtime);
|
|
|
|
buildCommand.Execute().Should().Pass();
|
|
|
|
|
|
|
|
var publishCommand = new PublishCommand(projectDir, output: publishDir, framework: Framework, runtime: _Runtime);
|
|
|
|
publishCommand.Execute().Should().Pass();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|