-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added IPath<TPath> interface to GamePath - Implemented interface methods - This gives us FileTreeNode<GamePath> * Added GamePath tests for new methods * Added simple test for FileTreeNode<GamePath> * Updated Paths library to 0.1.4 containing the new IPath<TPath> and FileTree
- Loading branch information
Showing
4 changed files
with
236 additions
and
4 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
50 changes: 50 additions & 0 deletions
50
tests/NexusMods.DataModel.Tests/GamePathFileTreeNodeTests.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,50 @@ | ||
using FluentAssertions; | ||
using NexusMods.Paths; | ||
using NexusMods.Paths.FileTree; | ||
|
||
namespace NexusMods.DataModel.Tests; | ||
|
||
public class GamePathFileTreeNodeTests | ||
{ | ||
|
||
[Theory] | ||
[InlineData(GameFolderType.Game, "file1.txt", true, 1)] | ||
[InlineData(GameFolderType.Game,"file2.txt", false, 2)] | ||
[InlineData(GameFolderType.Game,"foo/file2.txt", true, 2)] | ||
[InlineData(GameFolderType.Game,"foo/file3.txt", true, 3)] | ||
[InlineData(GameFolderType.Game,"foo/bar/file4.txt", true, 4)] | ||
[InlineData(GameFolderType.Game,"baz/bazer/file5.txt", true, 5)] | ||
[InlineData(GameFolderType.Saves,"baz/bazer/file5.txt", false, 5)] | ||
public void Test_FindNode(GameFolderType folderType, string path, bool found, int value) | ||
{ | ||
var tree = MakeTestTree(); | ||
|
||
var node = tree.FindNode(new GamePath(folderType, (RelativePath)path)); | ||
if (found) | ||
{ | ||
node.Should().NotBeNull(); | ||
node!.Path.Should().Be(new GamePath(folderType, (RelativePath)path)); | ||
node!.Value.Should().Be(value); | ||
} | ||
else | ||
{ | ||
node.Should().BeNull(); | ||
} | ||
} | ||
|
||
private static FileTreeNode<GamePath, int> MakeTestTree() | ||
{ | ||
Dictionary<GamePath, int> fileEntries; | ||
|
||
fileEntries = new Dictionary<GamePath, int> | ||
{ | ||
{ new GamePath(GameFolderType.Game,"file1.txt"), 1 }, | ||
{ new GamePath(GameFolderType.Game,"foo/file2.txt"), 2 }, | ||
{ new GamePath(GameFolderType.Game,"foo/file3.txt"), 3 }, | ||
{ new GamePath(GameFolderType.Game,"foo/bar/file4.txt"), 4 }, | ||
{ new GamePath(GameFolderType.Game,"baz/bazer/file5.txt"), 5 }, | ||
}; | ||
|
||
return FileTreeNode<GamePath, int>.CreateTree(fileEntries); | ||
} | ||
} |
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