dotnet-installer/test/dotnet.Tests/ParserTests/AddReferenceParserTests.cs

53 lines
1.5 KiB
C#
Raw Normal View History

// 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;
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;
using Parser = Microsoft.DotNet.Cli.Parser;
2017-03-03 21:14:36 +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]
public void AddReferenceHasDefaultArgumentSetToCurrentDirectory()
2017-03-03 21:14:36 +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]
public void AddReferenceWithoutArgumentResultsInAnError()
2017-03-03 21:14:36 +00:00
{
var command = Parser.Instance;
2017-03-03 21:14:36 +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(string.Format(LocalizableStrings.RequiredArgumentMissingForCommand, "reference"));
2017-03-03 21:14:36 +00:00
}
}
}