Skip to content

Commit 69223a5

Browse files
committed
Changed test AddReferenceWithoutArgumentResultsInAnError to check the error information more explicitly.
1 parent c594e85 commit 69223a5

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

test/dotnet.Tests/ParserTests/AddReferenceParserTests.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.CommandLine.Parsing;
45
using Microsoft.DotNet.Cli;
56
using Microsoft.DotNet.Cli.Utils;
67
using Parser = Microsoft.DotNet.Cli.Parser;
@@ -50,13 +51,11 @@ public void AddReferenceWithoutArgumentResultsInAnError()
5051
{
5152
var result = Parser.Instance.Parse("dotnet add reference");
5253

53-
result
54-
.Errors
55-
.Select(e => e.Message)
56-
.Should()
57-
// This string comes from System.CommandLine:
58-
// https://github.com/dotnet/command-line-api/blob/b4485d8417c4eb0ec3d1a291e1003686618ce598/src/System.CommandLine/Properties/Resources.resx#L135-L137
59-
.BeEquivalentTo("Required argument missing for command: 'reference'.");
54+
result.Errors.Should().NotBeEmpty();
55+
56+
var argument = (result.Errors.FirstOrDefault()?.SymbolResult as ArgumentResult)?.Argument;
57+
58+
argument.Should().Be(ReferenceAddCommandParser.ProjectPathArgument);
6059
}
6160
}
6261
}

0 commit comments

Comments
 (0)