Skip to content

Commit d6f9e5f

Browse files
committed
Change the way the recurse option is parsed and update unit test to use it
1 parent 0daf783 commit d6f9e5f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/dotnet-grpc/Commands/AddFileCommand.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static Command Create(HttpClient httpClient)
6363
var services = context.ParseResult.GetValueForOption(serviceOption);
6464
var access = context.ParseResult.GetValueForOption(accessOption);
6565
var additionalImportDirs = context.ParseResult.GetValueForOption(additionalImportDirsOption);
66-
var searchOption = context.ParseResult.GetValueForOption(recursiveOption) ? SearchOption.TopDirectoryOnly : SearchOption.TopDirectoryOnly;
66+
var searchOption = context.ParseResult.HasOption(recursiveOption) ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
6767
var files = context.ParseResult.GetValueForArgument(filesArgument);
6868

6969
try

test/dotnet-grpc.Tests/AddFileCommandTests.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public async Task Commandline_AddFileCommand_AddsPackagesAndReferences()
4141
var parser = Program.BuildParser(CreateClient());
4242

4343
// Act
44-
var result = await parser.InvokeAsync($"add-file -p {tempDir} -s Server --access Internal -i ImportDir {Path.Combine("Proto", "*.proto")}", testConsole);
44+
var result = await parser.InvokeAsync($"add-file -p {tempDir} -s Server --access Internal -r -i ImportDir {Path.Combine("Proto", "*.proto")}", testConsole);
4545

4646
// Assert
4747
Assert.AreEqual(0, result, testConsole.Error.ToString());
@@ -55,9 +55,10 @@ public async Task Commandline_AddFileCommand_AddsPackagesAndReferences()
5555

5656

5757
var protoRefs = project.GetItems(CommandBase.ProtobufElement);
58-
Assert.AreEqual(2, protoRefs.Count);
58+
Assert.AreEqual(3, protoRefs.Count);
5959
Assert.NotNull(protoRefs.SingleOrDefault(r => r.UnevaluatedInclude == "Proto\\a.proto"));
6060
Assert.NotNull(protoRefs.SingleOrDefault(r => r.UnevaluatedInclude == "Proto\\b.proto"));
61+
Assert.NotNull(protoRefs.SingleOrDefault(r => r.UnevaluatedInclude == "Proto\\Subfolder\\c.proto"));
6162
foreach (var protoRef in protoRefs)
6263
{
6364
Assert.AreEqual("Server", protoRef.GetMetadataValue(CommandBase.GrpcServicesElement));

0 commit comments

Comments
 (0)