-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
tests/SystemTests/ProjectRepoM.ActionMenu.Core/ActionMenu/Context/FileFunctionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters