2017-03-06 19:57:19 +00:00
|
|
|
// 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.
|
|
|
|
|
2017-03-03 21:14:36 +00:00
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
2017-03-06 19:57:19 +00:00
|
|
|
using FluentAssertions;
|
2017-03-03 21:14:36 +00:00
|
|
|
using Microsoft.DotNet.Cli.CommandLine;
|
|
|
|
using Microsoft.DotNet.Tools.Common;
|
|
|
|
using Xunit;
|
|
|
|
using Xunit.Abstractions;
|
2017-03-06 19:57:19 +00:00
|
|
|
using Parser = Microsoft.DotNet.Cli.Parser;
|
2017-03-03 21:14:36 +00:00
|
|
|
|
2017-03-06 19:57:19 +00:00
|
|
|
namespace Microsoft.DotNet.Tests.ParserTests
|
2017-03-03 21:14:36 +00:00
|
|
|
{
|
|
|
|
public class AddReferenceParserTests
|
|
|
|
{
|
|
|
|
private readonly ITestOutputHelper output;
|
|
|
|
|
|
|
|
public AddReferenceParserTests(ITestOutputHelper output)
|
|
|
|
{
|
|
|
|
this.output = output;
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
2017-03-06 19:57:19 +00:00
|
|
|
public void AddReferenceHasDefaultArgumentSetToCurrentDirectory()
|
2017-03-03 21:14:36 +00:00
|
|
|
{
|
2017-03-08 00:40:18 +00:00
|
|
|
var command = Parser.Instance;
|
2017-03-03 21:14:36 +00:00
|
|
|
|
|
|
|
var result = command.Parse("dotnet add reference my.csproj");
|
|
|
|
|
|
|
|
result["dotnet"]["add"]
|
|
|
|
.Arguments
|
|
|
|
.Should()
|
|
|
|
.BeEquivalentTo(
|
|
|
|
PathUtility.EnsureTrailingSlash(Directory.GetCurrentDirectory()));
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
2017-03-06 19:57:19 +00:00
|
|
|
public void AddReferenceWithoutArgumentResultsInAnError()
|
2017-03-03 21:14:36 +00:00
|
|
|
{
|
2017-03-08 00:40:18 +00:00
|
|
|
var command = Parser.Instance;
|
2017-03-03 21:14:36 +00:00
|
|
|
|
2017-03-06 19:57:19 +00:00
|
|
|
var result = command.Parse("dotnet add reference");
|
2017-03-03 21:14:36 +00:00
|
|
|
|
|
|
|
result
|
|
|
|
.Errors
|
|
|
|
.Select(e => e.Message)
|
|
|
|
.Should()
|
|
|
|
.BeEquivalentTo("Required argument missing for command: reference");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|