Skip to content

Commit d8b18ed

Browse files
Response to PR review
1 parent 92d4a8d commit d8b18ed

File tree

4 files changed

+23
-20
lines changed

4 files changed

+23
-20
lines changed

src/System.CommandLine.Subsystems.Tests/ValueSubsystemTests.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,61 +34,61 @@ public void Value_is_always_activated()
3434
public void ValueSubsystem_returns_values_that_are_entered()
3535
{
3636
var consoleHack = new ConsoleHack().RedirectToBuffer(true);
37-
CliOption<int> option1 = new CliOption<int>("--intValue");
37+
CliOption<int> option = new CliOption<int>("--intValue");
3838
CliRootCommand rootCommand = [
3939
new CliCommand("x")
4040
{
41-
option1
41+
option
4242
}];
4343
var configuration = new CliConfiguration(rootCommand);
4444
var pipeline = Pipeline.CreateEmpty();
4545
pipeline.Value = new ValueSubsystem();
46-
const int expected1 = 42;
47-
var input = $"x --intValue {expected1}";
46+
const int expected = 42;
47+
var input = $"x --intValue {expected}";
4848

4949
var parseResult = pipeline.Parse(configuration, input); // assigned for debugging
5050
pipeline.Execute(configuration, input, consoleHack);
5151

52-
pipeline.Value.GetValue<int>(option1).Should().Be(expected1);
52+
pipeline.Value.GetValue<int>(option).Should().Be(expected);
5353
}
5454

5555
[Fact]
5656
public void ValueSubsystem_returns_default_value_when_no_value_is_entered()
5757
{
5858
var consoleHack = new ConsoleHack().RedirectToBuffer(true);
59-
CliOption<int> option1 = new CliOption<int>("--intValue");
60-
CliRootCommand rootCommand = [option1];
59+
CliOption<int> option = new CliOption<int>("--intValue");
60+
CliRootCommand rootCommand = [option];
6161
var configuration = new CliConfiguration(rootCommand);
6262
var pipeline = Pipeline.CreateEmpty();
6363
pipeline.Value = new ValueSubsystem();
64-
pipeline.Value.DefaultValue.Set(option1, 43);
65-
const int expected1 = 43;
64+
pipeline.Value.DefaultValue.Set(option, 43);
65+
const int expected = 43;
6666
var input = $"";
6767

6868
var parseResult = pipeline.Parse(configuration, input); // assigned for debugging
6969
pipeline.Execute(configuration, input, consoleHack);
7070

71-
pipeline.Value.GetValue<int>(option1).Should().Be(expected1);
71+
pipeline.Value.GetValue<int>(option).Should().Be(expected);
7272
}
7373

7474

7575
[Fact]
7676
public void ValueSubsystem_returns_calculated_default_value_when_no_value_is_entered()
7777
{
7878
var consoleHack = new ConsoleHack().RedirectToBuffer(true);
79-
CliOption<int> option1 = new CliOption<int>("--intValue");
80-
CliRootCommand rootCommand = [option1];
79+
CliOption<int> option = new CliOption<int>("--intValue");
80+
CliRootCommand rootCommand = [option];
8181
var configuration = new CliConfiguration(rootCommand);
8282
var pipeline = Pipeline.CreateEmpty();
8383
pipeline.Value = new ValueSubsystem();
8484
var x = 42;
85-
pipeline.Value.DefaultValueCalculation.Set(option1, () => x + 2);
86-
const int expected1 = 44;
85+
pipeline.Value.DefaultValueCalculation.Set(option, () => x + 2);
86+
const int expected = 44;
8787
var input = $"";
8888

8989
var parseResult = pipeline.Parse(configuration, input); // assigned for debugging
9090
pipeline.Execute(configuration, input, consoleHack);
9191

92-
pipeline.Value.GetValue<int>(option1).Should().Be(expected1);
92+
pipeline.Value.GetValue<int>(option).Should().Be(expected);
9393
}
9494
}

src/System.CommandLine.Tests/ParseResultValueTests.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
using System.CommandLine.Parsing;
5-
using System.Linq;
65
using FluentAssertions;
6+
using FluentAssertions.Execution;
77
using Xunit;
88

99
namespace System.CommandLine.Tests;
@@ -26,8 +26,11 @@ public void Symbol_found_by_name()
2626

2727
var symbol1 = parseResult.GetSymbolByName("--opt1");
2828
var symbol2 = parseResult.GetSymbolByName("--opt2");
29-
symbol1.Should().Be(option1);
30-
symbol2.Should().Be(option2);
29+
using (new AssertionScope())
30+
{
31+
symbol1.Should().Be(option1);
32+
symbol2.Should().Be(option2);
33+
}
3134
}
3235

3336
[Fact]

src/System.CommandLine.Tests/ParserTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1883,7 +1883,7 @@ public void Locations_correct_for_collection()
18831883
{
18841884
option1
18851885
};
1886-
var expectedOuterLocation = new Location("testhost", Location.User, -1, null);
1886+
var expectedOuterLocation = new Location(CliExecutable.ExecutableName, Location.User, -1, null);
18871887
var expectedLocation1 = new Location("Kirk", Location.User, 2, expectedOuterLocation);
18881888
var expectedLocation2 = new Location("Spock", Location.User, 3, expectedOuterLocation);
18891889
var expectedLocation3 = new Location("Uhura", Location.User, 4, expectedOuterLocation);

src/System.CommandLine/ParseResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public sealed class ParseResult
1717
private readonly IReadOnlyDictionary<CliSymbol, ValueResult> valueResultDictionary = new Dictionary<CliSymbol, ValueResult>();
1818
private SymbolLookupByName? symbolLookupByName = null;
1919

20-
private readonly CommandResult? _rootCommandResult;
20+
private readonly CommandResult _rootCommandResult;
2121
// TODO: unmatched tokens, invocation, completion
2222
/*
2323
private readonly IReadOnlyList<CliToken> _unmatchedTokens;

0 commit comments

Comments
 (0)