Skip to content

Commit d79f309

Browse files
committed
add initial prototype
1 parent 803c0d0 commit d79f309

7 files changed

Lines changed: 1569 additions & 0 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
using Azure.Sdk.Tools.Cli.Helpers;
5+
6+
namespace Azure.Sdk.Tools.Cli.Tests.Helpers
7+
{
8+
[TestFixture]
9+
public class FileHelperTests
10+
{
11+
[Test]
12+
[TestCase("src/test/file.cs", new[] { "**/test/**" }, true)]
13+
[TestCase("src/test/subfolder/file.cs", new[] { "**/test/**" }, true)]
14+
[TestCase("src/main/file.cs", new[] { "**/test/**" }, false)]
15+
[TestCase("file.tmp", new[] { "*.tmp" }, true)]
16+
[TestCase("file.cs", new[] { "*.tmp" }, false)]
17+
[TestCase("bin/Debug/file.dll", new[] { "bin/**" }, true)]
18+
[TestCase("obj/Release/file.obj", new[] { "obj/**" }, true)]
19+
[TestCase("src/file.cs", new[] { "bin/**", "obj/**" }, false)]
20+
[TestCase("bin/file.dll", new[] { "bin/**", "obj/**" }, true)]
21+
[TestCase("node_modules/package/file.js", new[] { "**/node_modules/**" }, true)]
22+
[TestCase("src/node_modules/file.js", new[] { "**/node_modules/**" }, true)]
23+
[TestCase("src/file.js", new[] { "**/node_modules/**" }, false)]
24+
[TestCase("Bin/Debug/file.dll", new[] { "bin/**" }, true)]
25+
[TestCase("BIN/DEBUG/FILE.DLL", new[] { "bin/**" }, true)]
26+
[TestCase("test.tmp", new[] { "*.tmp", "*.bak", "**/test/**" }, true)]
27+
[TestCase("test.bak", new[] { "*.tmp", "*.bak", "**/test/**" }, true)]
28+
[TestCase("src/test/file.cs", new[] { "*.tmp", "*.bak", "**/test/**" }, true)]
29+
[TestCase("src/main/file.cs", new[] { "*.tmp", "*.bak", "**/test/**" }, false)]
30+
public void IsMatchingExcludePattern_ShouldReturnExpectedResult(string filePath, string[] patterns, bool expected)
31+
{
32+
var result = FileHelper.IsMatchingExcludePattern(filePath, patterns);
33+
34+
Assert.That(result, Is.EqualTo(expected),
35+
$"Path '{filePath}' with patterns [{string.Join(", ", patterns)}] should return {expected} but returned {result}");
36+
}
37+
38+
[Test]
39+
public void IsMatchingExcludePattern_WithEmptyPatterns_ShouldReturnFalse()
40+
{
41+
var filePath = "any/file.cs";
42+
var patterns = Array.Empty<string>();
43+
44+
var result = FileHelper.IsMatchingExcludePattern(filePath, patterns);
45+
46+
Assert.That(result, Is.False);
47+
}
48+
49+
[Test]
50+
public void IsMatchingExcludePattern_WithNullPatterns_ShouldReturnFalse()
51+
{
52+
var filePath = "any/file.cs";
53+
string[]? patterns = null;
54+
55+
var result = FileHelper.IsMatchingExcludePattern(filePath, patterns!);
56+
57+
Assert.That(result, Is.False);
58+
}
59+
60+
[Test]
61+
public void IsMatchingExcludePattern_WithEmptyFilePath_ShouldReturnFalse()
62+
{
63+
var filePath = "";
64+
var patterns = new[] { "*.tmp" };
65+
66+
var result = FileHelper.IsMatchingExcludePattern(filePath, patterns);
67+
68+
Assert.That(result, Is.False);
69+
}
70+
}
71+
}

tools/azsdk-cli/Azure.Sdk.Tools.Cli/Azure.Sdk.Tools.Cli.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
<PackageReference Include="ModelContextProtocol" Version="0.3.0-preview.4" />
4141
<PackageReference Include="ModelContextProtocol.AspNetCore" Version="0.1.0-preview.11" />
4242
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.3" />
43+
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="9.0.3" />
4344
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.3" />
4445
<PackageReference Include="Microsoft.VisualStudio.Services.Client" Version="19.225.1" />
4546
<PackageReference Include="Microsoft.TeamFoundation.DistributedTask.WebApi" Version="19.225.1" />

tools/azsdk-cli/Azure.Sdk.Tools.Cli/Commands/SharedOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public static class SharedOptions
2626
typeof(PipelineTestsTool),
2727
typeof(QuokkaTool),
2828
typeof(ReadMeGeneratorTool),
29+
typeof(SampleGeneratorTool),
2930
typeof(ReleasePlanTool),
3031
typeof(ReleaseReadinessTool),
3132
typeof(SdkBuildTool),

0 commit comments

Comments
 (0)