Fix tests
Missing namespace Re-enable dotnet-nuget unit tests
This commit is contained in:
parent
336ecc0e89
commit
ae4a690724
4 changed files with 39 additions and 7 deletions
13
src/dotnet/ICommandRunner.cs
Normal file
13
src/dotnet/ICommandRunner.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Microsoft.DotNet.Cli;
|
||||||
using Microsoft.DotNet.Cli.CommandLine;
|
using Microsoft.DotNet.Cli.CommandLine;
|
||||||
using Microsoft.DotNet.Cli.Utils;
|
using Microsoft.DotNet.Cli.Utils;
|
||||||
using Microsoft.DotNet.InternalAbstractions;
|
using Microsoft.DotNet.InternalAbstractions;
|
||||||
|
@ -10,15 +11,33 @@ using Microsoft.DotNet.Tools;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Tools.Restore
|
namespace Microsoft.DotNet.Tools.Restore
|
||||||
{
|
{
|
||||||
public partial class NuGetCommand
|
public class NuGetCommand
|
||||||
{
|
{
|
||||||
public static int Run(string[] args)
|
public static int Run(string[] args)
|
||||||
|
{
|
||||||
|
return Run(args, new NuGetCommandRunner());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int Run(string[] args, ICommandRunner nugetCommandRunner)
|
||||||
{
|
{
|
||||||
DebugHelper.HandleDebugSwitch(ref args);
|
DebugHelper.HandleDebugSwitch(ref args);
|
||||||
|
|
||||||
var nugetApp = new NuGetForwardingApp(args);
|
if (nugetCommandRunner == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(nugetCommandRunner));
|
||||||
|
}
|
||||||
|
|
||||||
return nugetApp.Execute();
|
return nugetCommandRunner.Run(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class NuGetCommandRunner : ICommandRunner
|
||||||
|
{
|
||||||
|
public int Run(string [] args)
|
||||||
|
{
|
||||||
|
var nugetApp = new NuGetForwardingApp(args);
|
||||||
|
|
||||||
|
return nugetApp.Execute();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Tests
|
namespace Microsoft.DotNet.Tests
|
||||||
{
|
{
|
||||||
|
@ -18,8 +19,7 @@ namespace Microsoft.DotNet.Tests
|
||||||
|
|
||||||
new TestCommand("dotnet") { WorkingDirectory = rootPath }
|
new TestCommand("dotnet") { WorkingDirectory = rootPath }
|
||||||
.Execute("new --type xunittest")
|
.Execute("new --type xunittest")
|
||||||
.Should()
|
.Should().Pass();
|
||||||
.Pass();
|
|
||||||
|
|
||||||
new TestCommand("dotnet") { WorkingDirectory = rootPath }
|
new TestCommand("dotnet") { WorkingDirectory = rootPath }
|
||||||
.Execute("restore")
|
.Execute("restore")
|
||||||
|
|
|
@ -42,14 +42,14 @@ namespace Microsoft.DotNet.Tools.Run.Tests
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
string[] receivedArgs = null;
|
string[] receivedArgs = null;
|
||||||
var testCommandRunner = new Mock<INuGetCommandRunner>();
|
var testCommandRunner = new Mock<ICommandRunner>();
|
||||||
testCommandRunner
|
testCommandRunner
|
||||||
.Setup(x => x.Run(It.IsAny<string[]>()))
|
.Setup(x => x.Run(It.IsAny<string[]>()))
|
||||||
.Callback<string[]>(s => receivedArgs = s)
|
.Callback<string[]>(s => receivedArgs = s)
|
||||||
.Returns(0);
|
.Returns(0);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var returned = NuGetCommand.RunCommand(inputArgs, testCommandRunner.Object);
|
var returned = NuGetCommand.Run(inputArgs, testCommandRunner.Object);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
receivedArgs.Should().BeEquivalentTo(inputArgs);
|
receivedArgs.Should().BeEquivalentTo(inputArgs);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue