2016-12-18 08:45:25 +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;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
using Microsoft.Build.Construction;
|
|
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
|
|
|
using Xunit;
|
|
|
|
using FluentAssertions;
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Restore.Tests
|
|
|
|
{
|
|
|
|
public class GivenThatIWantToRestoreApp : TestBase
|
|
|
|
{
|
2017-04-04 05:15:40 +00:00
|
|
|
private static string RepoRootNuGetConfig = Path.Combine(RepoDirectoriesProvider.RepoRoot, "NuGet.Config");
|
|
|
|
|
2016-12-18 08:45:25 +00:00
|
|
|
[Fact]
|
|
|
|
public void ItRestoresAppToSpecificDirectory()
|
|
|
|
{
|
2017-02-15 23:35:03 +00:00
|
|
|
var rootPath = TestAssets.CreateTestDirectory().FullName;
|
2016-12-18 08:45:25 +00:00
|
|
|
|
|
|
|
string dir = "pkgs";
|
|
|
|
string fullPath = Path.GetFullPath(Path.Combine(rootPath, dir));
|
|
|
|
|
2017-04-05 20:50:12 +00:00
|
|
|
string newArgs = $"console -o \"{rootPath}\" --skip-restore";
|
2017-02-01 01:31:37 +00:00
|
|
|
new NewCommandShim()
|
2016-12-18 08:45:25 +00:00
|
|
|
.WithWorkingDirectory(rootPath)
|
2017-02-01 01:31:37 +00:00
|
|
|
.Execute(newArgs)
|
2016-12-18 08:45:25 +00:00
|
|
|
.Should()
|
|
|
|
.Pass();
|
|
|
|
|
2017-04-04 05:15:40 +00:00
|
|
|
string args = $"--configfile {RepoRootNuGetConfig} --packages \"{dir}\"";
|
2016-12-18 08:45:25 +00:00
|
|
|
new RestoreCommand()
|
|
|
|
.WithWorkingDirectory(rootPath)
|
|
|
|
.ExecuteWithCapturedOutput(args)
|
|
|
|
.Should()
|
|
|
|
.Pass()
|
|
|
|
.And.NotHaveStdErr();
|
|
|
|
|
|
|
|
Directory.Exists(fullPath).Should().BeTrue();
|
|
|
|
Directory.EnumerateFiles(fullPath, "*.dll", SearchOption.AllDirectories).Count().Should().BeGreaterThan(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void ItRestoresLibToSpecificDirectory()
|
|
|
|
{
|
2017-02-15 23:35:03 +00:00
|
|
|
var rootPath = TestAssets.CreateTestDirectory().FullName;
|
2016-12-18 08:45:25 +00:00
|
|
|
|
|
|
|
string dir = "pkgs";
|
|
|
|
string fullPath = Path.GetFullPath(Path.Combine(rootPath, dir));
|
|
|
|
|
2017-04-05 20:50:12 +00:00
|
|
|
string newArgs = $"classlib -o \"{rootPath}\" --skip-restore";
|
2017-02-01 01:31:37 +00:00
|
|
|
new NewCommandShim()
|
2016-12-18 08:45:25 +00:00
|
|
|
.WithWorkingDirectory(rootPath)
|
2017-02-01 01:31:37 +00:00
|
|
|
.Execute(newArgs)
|
2016-12-18 08:45:25 +00:00
|
|
|
.Should()
|
|
|
|
.Pass();
|
|
|
|
|
2017-04-04 05:15:40 +00:00
|
|
|
string args = $"--configfile {RepoRootNuGetConfig} --packages \"{dir}\"";
|
2016-12-18 08:45:25 +00:00
|
|
|
new RestoreCommand()
|
|
|
|
.WithWorkingDirectory(rootPath)
|
|
|
|
.ExecuteWithCapturedOutput(args)
|
|
|
|
.Should()
|
|
|
|
.Pass()
|
|
|
|
.And.NotHaveStdErr();
|
|
|
|
|
|
|
|
Directory.Exists(fullPath).Should().BeTrue();
|
|
|
|
Directory.EnumerateFiles(fullPath, "*.dll", SearchOption.AllDirectories).Count().Should().BeGreaterThan(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void ItRestoresTestAppToSpecificDirectory()
|
|
|
|
{
|
|
|
|
var rootPath = TestAssets.Get("VSTestDotNetCore").CreateInstance().WithSourceFiles().Root.FullName;
|
|
|
|
|
|
|
|
string dir = "pkgs";
|
|
|
|
string fullPath = Path.GetFullPath(Path.Combine(rootPath, dir));
|
|
|
|
|
2017-04-04 05:15:40 +00:00
|
|
|
string args = $"--configfile {RepoRootNuGetConfig} --packages \"{dir}\"";
|
2016-12-18 08:45:25 +00:00
|
|
|
new RestoreCommand()
|
|
|
|
.WithWorkingDirectory(rootPath)
|
|
|
|
.ExecuteWithCapturedOutput(args)
|
|
|
|
.Should()
|
|
|
|
.Pass()
|
|
|
|
.And.NotHaveStdErr();
|
|
|
|
|
|
|
|
Directory.Exists(fullPath).Should().BeTrue();
|
|
|
|
Directory.EnumerateFiles(fullPath, "*.dll", SearchOption.AllDirectories).Count().Should().BeGreaterThan(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|