dotnet-installer/test/dotnet-restore.Tests/GivenThatIWantToRestoreApp.cs
seancpeters 2d93968a88 New3 integration (#5430)
* Partial conversion to new3. 2 tests fail due to browserlink not restoring.

* new cache initialization

* More lzma changes, and removed a razor ref from templates

* Ephemeral hive flag added to tests that need it

* Updated the template engine version to build against. Minor code cleanup

* Config changes to make template versions separate from template engine versions

* Changed dotnet new versioning to use Product.Version

* Fixing Archiver.csproj

* Fixing dotnet new test.

* Fix LZMA Package Source Condition

* Workaround for newline differences.

* fixed tests with changed template parameters. Added a new3 template non-match test
2017-01-31 17:31:37 -08:00

91 lines
3.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.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
{
[Fact]
public void ItRestoresAppToSpecificDirectory()
{
var rootPath = TestAssetsManager.CreateTestDirectory().Path;
string dir = "pkgs";
string fullPath = Path.GetFullPath(Path.Combine(rootPath, dir));
string newArgs = $"console -o \"{rootPath}\"";
new NewCommandShim()
.WithWorkingDirectory(rootPath)
.Execute(newArgs)
.Should()
.Pass();
string args = $"--packages \"{dir}\"";
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()
{
var rootPath = TestAssetsManager.CreateTestDirectory().Path;
string dir = "pkgs";
string fullPath = Path.GetFullPath(Path.Combine(rootPath, dir));
string newArgs = $"classlib -o \"{rootPath}\"";
new NewCommandShim()
.WithWorkingDirectory(rootPath)
.Execute(newArgs)
.Should()
.Pass();
string args = $"--packages \"{dir}\"";
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));
string args = $"--packages \"{dir}\"";
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);
}
}
}