forked from dotnet/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddReferenceParserTests.cs
53 lines (42 loc) · 1.7 KB
/
AddReferenceParserTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.CommandLine.Parsing;
using Microsoft.DotNet.Cli.Commands.Hidden.Add;
using Microsoft.DotNet.Cli.Commands.Reference.Add;
using Microsoft.DotNet.Cli.Utils;
using Parser = Microsoft.DotNet.Cli.Parser;
namespace Microsoft.DotNet.Tests.ParserTests
{
public class AddReferenceParserTests
{
private readonly ITestOutputHelper output;
public AddReferenceParserTests(ITestOutputHelper output)
{
this.output = output;
}
[Fact]
public void AddReferenceHasDefaultArgumentSetToCurrentDirectory()
{
var result = Parser.Instance.Parse("dotnet add reference my.csproj");
result.GetValue<string>(AddCommandParser.ProjectArgument)
.Should()
.BeEquivalentTo(
PathUtility.EnsureTrailingSlash(Directory.GetCurrentDirectory()));
}
[Fact]
public void AddReferenceHasInteractiveFlag()
{
var result = Parser.Instance.Parse("dotnet add reference my.csproj --interactive");
result.GetValue<bool>(ReferenceAddCommandParser.InteractiveOption)
.Should().BeTrue();
}
[Fact]
public void AddReferenceWithoutArgumentResultsInAnError()
{
var result = Parser.Instance.Parse("dotnet add reference");
result.Errors.Should().NotBeEmpty();
var argument = (result.Errors.SingleOrDefault()?.SymbolResult as ArgumentResult)?.Argument;
argument.Should().Be(ReferenceAddCommandParser.ProjectPathArgument);
}
}
}