Add nuget command to dotnet cli

This commit is contained in:
drewgil 2016-08-10 10:50:18 -07:00
parent 49527d3ea6
commit 11b666acee
31 changed files with 237 additions and 25 deletions

View file

@ -0,0 +1,59 @@
// 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.Collections.Generic;
using FluentAssertions;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.TestFramework;
using Microsoft.DotNet.Tools.Test.Utilities;
using Microsoft.DotNet.Tools.NuGet;
using Moq;
using NuGet.Frameworks;
using Xunit;
namespace Microsoft.DotNet.Tools.Run.Tests
{
public class GivenANuGetCommand : TestBase
{
[Theory]
[InlineData(new[] { "push", "foo.1.0.0.nupkg" }, 0)]
[InlineData(new[] { "push", "foo.1.0.0.nupkg", "-k", "12345678-1234-1234-1234-123456789012" }, 0)]
[InlineData(new[] { "push", "foo.1.0.0.nupkg",
"--api-key", "12345678-1234-1234-1234-123456789012",
"--source", "http://www.myget.org/foofeed" }, 0)]
[InlineData(new[] { "push", "foo.1.0.0.nupkg",
"--api-key", "12345678-1234-1234-1234-123456789012",
"--source", "http://www.nuget.org/foofeed",
"--symbol-api-key", "12345678-1234-1234-1234-123456789012",
"--symbol-source", "https://nuget.smbsrc.net/foo",
"--timeout", "1000",
"--disable-buffering",
"--no-symbols" }, 0)] // Unlikely option given others, but testing max options edge case
[InlineData(new[] { "delete", "foo.1.0.0.nupkg" }, 0)]
[InlineData(new[] { "delete", "foo.1.0.0.nupkg",
"--non-interactive" }, 0)]
[InlineData(new[] { "delete", "foo.1.0.0.nupkg",
"--api-key", "12345678-1234-1234-1234-123456789012",
"--source", "http://www.nuget.org/foofeed",
"--non-interactive" }, 0)]
[InlineData(new[] { "locals" }, 0)]
[InlineData(new[] { "locals", "http-cache", "packages-cache", "global-packages", "temp" }, 0)]
public void ItPassesCommandIfSupported(string[] inputArgs, int result)
{
// Arrange
string[] receivedArgs = null;
var testCommandRunner = new Mock<INuGetCommandRunner>();
testCommandRunner
.Setup(x => x.Run(It.IsAny<string[]>()))
.Callback<string[]>(s => receivedArgs = s)
.Returns(0);
// Act
var returned = NuGetCommand.RunCommand(inputArgs, testCommandRunner.Object);
// Assert
receivedArgs.Should().BeEquivalentTo(inputArgs);
returned.Should().Be(result);
}
}
}

View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0.24720" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.24720</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>2EC08501-CFC6-412F-9345-8D31D258A60E</ProjectGuid>
<RootNamespace>Microsoft.DotNet.Tools.NuGet.UnitTests</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

View file

@ -0,0 +1,28 @@
{
"version": "1.0.0-*",
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"System.Runtime.Serialization.Primitives": "4.1.1",
"dotnet": {
"target": "project"
},
"Microsoft.DotNet.Tools.Tests.Utilities": {
"target": "project"
},
"xunit": "2.1.0",
"moq.netcore": "4.4.0-beta8",
"dotnet-test-xunit": "1.0.0-rc2-192208-24"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.4",
"portable-net451+win8"
]
}
},
"testRunner": "xunit"
}