refresh enumerator when moving to next subcommand (#5533)

This commit is contained in:
Jon Sequeira 2017-01-31 21:31:02 -08:00 committed by Piotr Puszkiewicz
parent 626c8983c2
commit 6990c71e84
2 changed files with 45 additions and 6 deletions

View file

@ -2,18 +2,23 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using FluentAssertions;
using Microsoft.Build.Construction;
using Microsoft.DotNet.Cli.Sln.Internal;
using Microsoft.DotNet.Tools.Test.Utilities;
using System;
using System.IO;
using System.Linq;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.DotNet.Cli.Package.Add.Tests
{
public class GivenDotnetPackageAdd : TestBase
{
private readonly ITestOutputHelper _output;
public GivenDotnetPackageAdd(ITestOutputHelper output)
{
_output = output;
}
[Fact]
public void WhenValidPackageIsPassedBeforeVersionItGetsAdded()
@ -37,6 +42,35 @@ namespace Microsoft.DotNet.Cli.Package.Add.Tests
cmd.StdErr.Should().BeEmpty();
}
[Fact]
public void
WhenValidProjectAndPackageArePassedItGetsAdded()
{
var testAsset = "TestAppSimple";
var projectDirectory = TestAssets
.Get(testAsset)
.CreateInstance()
.WithSourceFiles()
.Root
.FullName;
var csproj = $"{projectDirectory + Path.DirectorySeparatorChar + testAsset}.csproj";
var packageName = "Newtonsoft.Json";
var packageVersion = "9.0.1";
var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"add {csproj} package {packageName} --version {packageVersion}");
_output.WriteLine($"[STDOUT] {cmd.StdOut}\n[STDERR]{cmd.StdErr}\n");
cmd.Should().Pass();
cmd.StdOut.Should()
.Contain($"PackageReference for package \'{packageName}\' version \'{packageVersion}\' added to file '{csproj}'.");
cmd.StdErr.Should().BeEmpty();
}
[Fact]
public void WhenValidPackageIsPassedAfterVersionItGetsAdded()
{