Fix tests

Missing namespace
Re-enable dotnet-nuget unit tests
This commit is contained in:
PiotrP 2016-08-26 18:14:04 -07:00
parent 336ecc0e89
commit ae4a690724
4 changed files with 39 additions and 7 deletions

View file

@ -0,0 +1,13 @@
// 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;
namespace Microsoft.DotNet.Cli
{
public interface ICommandRunner
{
int Run(string[] commandArgs);
}
}

View file

@ -3,6 +3,7 @@
using System;
using System.Linq;
using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.InternalAbstractions;
@ -10,15 +11,33 @@ using Microsoft.DotNet.Tools;
namespace Microsoft.DotNet.Tools.Restore
{
public partial class NuGetCommand
public class NuGetCommand
{
public static int Run(string[] args)
{
return Run(args, new NuGetCommandRunner());
}
public static int Run(string[] args, ICommandRunner nugetCommandRunner)
{
DebugHelper.HandleDebugSwitch(ref args);
if (nugetCommandRunner == null)
{
throw new ArgumentNullException(nameof(nugetCommandRunner));
}
return nugetCommandRunner.Run(args);
}
private class NuGetCommandRunner : ICommandRunner
{
public int Run(string [] args)
{
var nugetApp = new NuGetForwardingApp(args);
return nugetApp.Execute();
}
}
}
}

View file

@ -4,6 +4,7 @@
using Microsoft.DotNet.Tools.Test.Utilities;
using Xunit;
using FluentAssertions;
using System.IO;
namespace Microsoft.DotNet.Tests
{
@ -18,8 +19,7 @@ namespace Microsoft.DotNet.Tests
new TestCommand("dotnet") { WorkingDirectory = rootPath }
.Execute("new --type xunittest")
.Should()
.Pass();
.Should().Pass();
new TestCommand("dotnet") { WorkingDirectory = rootPath }
.Execute("restore")

View file

@ -42,14 +42,14 @@ namespace Microsoft.DotNet.Tools.Run.Tests
{
// Arrange
string[] receivedArgs = null;
var testCommandRunner = new Mock<INuGetCommandRunner>();
var testCommandRunner = new Mock<ICommandRunner>();
testCommandRunner
.Setup(x => x.Run(It.IsAny<string[]>()))
.Callback<string[]>(s => receivedArgs = s)
.Returns(0);
// Act
var returned = NuGetCommand.RunCommand(inputArgs, testCommandRunner.Object);
var returned = NuGetCommand.Run(inputArgs, testCommandRunner.Object);
// Assert
receivedArgs.Should().BeEquivalentTo(inputArgs);