Skip to content

Commit

Permalink
Merge branch 'release/v1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
coenm committed Oct 22, 2024
2 parents aa3f283 + c2917ce commit a58d8b0
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
<_Parameter1>RepoM.ActionMenu.CodeGen</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
<_Parameter1>SystemTests</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
<_Parameter1>Tests</_Parameter1>
</AssemblyAttribute>
Expand Down
4 changes: 2 additions & 2 deletions src/RepoM.ActionMenu.Core/ActionMenu/Context/FileFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal partial class FileFunctions : ScribanModuleWithFunctions
private static readonly EnumerationOptions _findFilesOptions = new()
{
RecurseSubdirectories = true,
AttributesToSkip = FileAttributes.Hidden | FileAttributes.System | FileAttributes.Device | FileAttributes.Directory,
AttributesToSkip = FileAttributes.Hidden | FileAttributes.System | FileAttributes.Device,
IgnoreInaccessible = true,
MatchType = MatchType.Simple,
ReturnSpecialDirectories = false,
Expand All @@ -47,7 +47,7 @@ public FileFunctions()
/// solution_files = file.find_files('C:\Project\', '*.sln');
/// </code>
/// <result/>
/// As a result, the variable `solution_files` is an enumerable of strings, for example:
/// As a result, the variable `solution_files` is an ennumerable of strings, for example:
/// <code-file language='yaml' filename='file.find_files.verified.yaml' />
/// <repository-action-sample/>
/// <snippet name='find_files@actionmenu01' mode='snippet' />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
namespace SystemTests.ProjectRepoM.ActionMenu.Core.ActionMenu.Context;

using System;
using System.IO;
using System.IO.Abstractions;
using FakeItEasy;
using FluentAssertions;
using RepoM.ActionMenu.Core.ActionMenu.Context;
using RepoM.ActionMenu.Interface.ActionMenuFactory;
using Scriban.Parsing;

public class FileFunctionsTests
{
private readonly IFileSystem _fileSystem = new FileSystem();
private readonly IMenuContext _context;
private readonly SourceSpan _span;
private readonly string _rootPath;
private readonly string _rootPathSubDir;

public FileFunctionsTests()
{
_context = A.Fake<IMenuContext>();
A.CallTo(() => _context.FileSystem).Returns(_fileSystem);
_span = new SourceSpan("fileName", new TextPosition(1, 1, 1), new TextPosition(1, 1, 1));
_rootPath = Path.Combine(Path.GetTempPath(), $"RepoM_Test_Repositories_{Guid.NewGuid().ToString()}");
_rootPathSubDir = Path.Combine(_rootPath, "subDir");
}

[Before(Test)]
public void Setup()
{
_fileSystem.Directory.CreateDirectory(_rootPath);
using var _ = _fileSystem.File.Create(Path.Combine(_rootPath, "root.sln"));
_fileSystem.Directory.CreateDirectory(_rootPathSubDir);
using var __ = _fileSystem.File.Create(Path.Combine(_rootPathSubDir, "sub.sln"));
}

[After(Test)]
public void Cleanup()
{
_fileSystem.Directory.Delete(_rootPath, true);
}

[Test]
public void FindFiles_ShouldReturnRootAndSubDirFile()
{
// arrange

// act
var result = FileFunctions.FindFilesInner(_context, _span, _rootPath, "*.sln");

// assert
result.Should().BeEquivalentTo(
$@"{_rootPath}\root.sln",
$@"{_rootPathSubDir}\sub.sln");
}
}
5 changes: 5 additions & 0 deletions tests/SystemTests/SystemTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\RepoM.ActionMenu.Core\RepoM.ActionMenu.Core.csproj" />
<ProjectReference Include="..\..\src\RepoM.Api\RepoM.Api.csproj" />
</ItemGroup>

Expand All @@ -26,4 +27,8 @@
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
<PackageReference Include="TUnit" Version="0.1.1030" />
</ItemGroup>

<ItemGroup>
<Folder Include="Helpers\" />
</ItemGroup>
</Project>

0 comments on commit a58d8b0

Please sign in to comment.