|
23 | 23 | using Grpc.Dotnet.Cli.Commands; |
24 | 24 | using Grpc.Dotnet.Cli.Internal; |
25 | 25 | using Grpc.Dotnet.Cli.Options; |
| 26 | +using Grpc.Dotnet.Cli.Properties; |
26 | 27 | using Grpc.Tests.Shared; |
27 | 28 | using Microsoft.Build.Definition; |
28 | 29 | using Microsoft.Build.Evaluation; |
@@ -318,33 +319,39 @@ public void ResolveServices_ReturnsClient_IfNotWebSDK() |
318 | 319 | } |
319 | 320 |
|
320 | 321 | [Test] |
321 | | - public void GlobReferences_ExpandsRelativeReferences() |
| 322 | + public void GlobReferences_ExpandsRelativeReferences_WarnsIfReferenceNotResolved() |
322 | 323 | { |
323 | 324 | // Arrange |
| 325 | + var testConsole = new TestConsole(); |
324 | 326 | var commandBase = new CommandBase( |
325 | | - new TestConsole(), |
| 327 | + testConsole, |
326 | 328 | CreateIsolatedProject(Path.Combine(Directory.GetCurrentDirectory(), "TestAssets", "EmptyProject", "test.csproj"))); |
| 329 | + var invalidReference = Path.Combine("Proto", "invalid*reference.proto"); |
327 | 330 |
|
328 | 331 | // Act |
329 | | - var references = commandBase.GlobReferences(new[] { Path.Combine("Proto", "*.proto") }); |
| 332 | + var references = commandBase.GlobReferences(new[] { Path.Combine("Proto", "*.proto"), invalidReference }); |
330 | 333 |
|
331 | 334 | // Assert |
332 | 335 | Assert.Contains(Path.Combine("Proto", "a.proto"), references); |
333 | 336 | Assert.Contains(Path.Combine("Proto", "b.proto"), references); |
| 337 | + Assert.AreEqual($"Warning: {string.Format(CoreStrings.LogWarningNoReferenceResolved, invalidReference, SourceUrl)}", testConsole.Out.ToString()!.TrimEnd()); |
334 | 338 | } |
335 | 339 |
|
336 | 340 | [Test] |
337 | | - public void GlobReferences_ExpandsAbsoluteReferences() |
| 341 | + public void GlobReferences_ExpandsAbsoluteReferences_WarnsIfReferenceNotResolved() |
338 | 342 | { |
339 | 343 | // Arrange |
340 | | - var commandBase = new CommandBase(new TestConsole(), new Project()); |
| 344 | + var testConsole = new TestConsole(); |
| 345 | + var commandBase = new CommandBase(testConsole, new Project()); |
| 346 | + var invalidReference = Path.Combine(Directory.GetCurrentDirectory(), "TestAssets", "EmptyProject", "Proto", "invalid*reference.proto"); |
341 | 347 |
|
342 | 348 | // Act |
343 | | - var references = commandBase.GlobReferences(new[] { Path.Combine(Directory.GetCurrentDirectory(), "TestAssets", "EmptyProject", "Proto", "*.proto") }); |
| 349 | + var references = commandBase.GlobReferences(new[] { Path.Combine(Directory.GetCurrentDirectory(), "TestAssets", "EmptyProject", "Proto", "*.proto"), invalidReference }); |
344 | 350 |
|
345 | 351 | // Assert |
346 | 352 | Assert.Contains(Path.Combine(Directory.GetCurrentDirectory(), "TestAssets", "EmptyProject", "Proto", "a.proto"), references); |
347 | 353 | Assert.Contains(Path.Combine(Directory.GetCurrentDirectory(), "TestAssets", "EmptyProject", "Proto", "b.proto"), references); |
| 354 | + Assert.AreEqual($"Warning: {string.Format(CoreStrings.LogWarningNoReferenceResolved, invalidReference, SourceUrl)}", testConsole.Out.ToString()!.TrimEnd()); |
348 | 355 | } |
349 | 356 |
|
350 | 357 | static object[] DirectoryPaths = |
|
0 commit comments