Skip to content

Commit

Permalink
edit with skylar suggestion and add/edit summary of some methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jlee671 committed Feb 21, 2023
1 parent 17c9680 commit da912f2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
16 changes: 11 additions & 5 deletions VSConfigFinder.Test/UtilitiesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace VSConfigFinder.Test

public class UtilitiesTests
{
const string VSConfig = ".vsconfig";

[Fact]
public void ValidateIsNotNullOrEmpty_NullOrEmpty_String_Throws_AppropriateException()
{
Expand Down Expand Up @@ -71,7 +73,7 @@ public void CreateOutput_Creates_FileOrArguments_With_Expected_String(bool creat

if (createFile)
{
var outputPath = Path.Combine(options.ConfigOutputPath, ".vsconfig");
var outputPath = Path.Combine(options.ConfigOutputPath, VSConfig);
fileSystem.Verify(x => x.WriteAllText(outputPath, jsonString));
}
else
Expand Down Expand Up @@ -102,6 +104,8 @@ public void ReadComponents_Reads_AllNestedDirectories_And_OutputsAllComponents()

// pathA
var pathA = "C:\\pathA";
var pathAConfigFile = Path.Combine(pathA, VSConfig);

var pathAConfig = """
{
"Version": "1.0",
Expand All @@ -114,7 +118,9 @@ public void ReadComponents_Reads_AllNestedDirectories_And_OutputsAllComponents()
var pathAReader = new MemoryStream(Encoding.UTF8.GetBytes(pathAConfig));

// pathB
var pathB = "C:\\pathA\\pathB";
var pathB = Path.Combine(pathA, "pathB");
var pathBConfigFile = Path.Combine(pathB, VSConfig);

var pathBConfig = """
{
"Version": "1.0",
Expand All @@ -126,10 +132,10 @@ public void ReadComponents_Reads_AllNestedDirectories_And_OutputsAllComponents()
""";
var pathBReader = new MemoryStream(Encoding.UTF8.GetBytes(pathBConfig));

fileSystem.Setup(x => x.GetFileSystemEntries("C:\\pathA", "*.vsconfig", true)).Returns(new[] { pathA, pathB });
fileSystem.Setup(x => x.GetFileSystemEntries("C:\\pathA", "*"+VSConfig, true)).Returns(new[] { pathAConfigFile, pathBConfigFile });

fileSystem.Setup(x => x.OpenFile(pathA)).Returns(pathAReader);
fileSystem.Setup(x => x.OpenFile(pathB)).Returns(pathBReader);
fileSystem.Setup(x => x.OpenFile(pathAConfigFile)).Returns(pathAReader);
fileSystem.Setup(x => x.OpenFile(pathBConfigFile)).Returns(pathBReader);

var components = Utilities.ReadComponents(fileSystem.Object, options);
Assert.Equal(3, components.Length);
Expand Down
4 changes: 2 additions & 2 deletions VSConfigFinder/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public static class Extensions
/// </summary>
/// <param name="fileSystem">The <see cref="IFileSystem"/>.</param>
/// <param name="paths">The list of top-level paths.</param>
/// <param name="pattern">pattern to match for file names. To match anything and everything, specify '*'</param>
/// <param name="pattern">Pattern to match for file names. To match anything and everything, specify '*'</param>
/// <param name="recursive">Optional: recursively search sub directories</param>
/// <returns></returns>
/// <returns>A set of path to files that match the pattern</returns>
public static IEnumerable<string> GetFileSystemEntries(this IFileSystem fileSystem, IEnumerable<string> paths, string pattern, bool recursive = false)
{
Utilities.IsNotNull(paths, nameof(paths));
Expand Down
6 changes: 3 additions & 3 deletions VSConfigFinder/IFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public interface IFileSystem
/// <summary>
/// Get files and directories within directory.
/// </summary>
/// <param name="path">directory path to search for.</param>
/// <param name="pattern">pattern to match for file names. To match anything and everything, specify '*'</param>
/// <param name="path">Directory path to search for.</param>
/// <param name="pattern">Pattern to match for file names. To match anything and everything, specify '*'</param>
/// <param name="recursive">Optional: recursively search sub directories</param>
/// <returns>array of files within the directory</returns>
/// <returns>Array of path to files that match the pattern within the directory.</returns>
/// <exception cref="ArgumentException"><paramref name="path"/> is empty.</exception>
/// <exception cref="ArgumentNullException"><paramref name="path"/> is null.</exception>
public IEnumerable<string> GetFileSystemEntries(string path, string pattern, bool recursive = false);
Expand Down

0 comments on commit da912f2

Please sign in to comment.