mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 18:57:24 +00:00
Merge pull request #284 from BinaryAlley/feature/set-unlit-color-for-hidden-file-system-browser-dialog-elements
Set unlit color for hidden file system browser dialog elements
This commit is contained in:
58 files changed
+873
-360
No files matched your search
@@ -153,7 +153,7 @@ Both book and music pages double as editors for the items that were scanned in.
|
|||||||
|
|
||||||
## The file system browser
|
## The file system browser
|
||||||
|
|
||||||
Wherever Lumina needs a folder or a file from the server, it opens the file system browser: a modal that lists the drives, a tree of folders, a pane of the items in the current folder, and an address bar you can walk with. It offers icon view modes, generates thumbnails for images, and can show or hide hidden files. You will meet it when you pick the content locations of a library, and anywhere else the interface asks you to point at a path on the server.
|
Wherever Lumina needs a folder or a file from the server, it opens the file system browser: a modal that lists the drives, a tree of folders, a pane of the items in the current folder, and an address bar you can walk with. It offers icon view modes, generates thumbnails for images, and can show or hide hidden files. Hidden entries are dimmed by the bundled themes. You will meet it when you pick the content locations of a library, and anywhere else the interface asks you to point at a path on the server.
|
||||||
|
|
||||||
## Settings and language
|
## Settings and language
|
||||||
|
|
||||||
|
|||||||
@@ -32,14 +32,16 @@ GET api/v1/directories/get-directories?path=C%3A%5CUsers%5C&shouldIncludeHiddenE
|
|||||||
"path": "/media/movies/The Matrix (1999)/",
|
"path": "/media/movies/The Matrix (1999)/",
|
||||||
"name": "The Matrix",
|
"name": "The Matrix",
|
||||||
"dateCreated": "2025-01-01T13:50:38.3183787Z",
|
"dateCreated": "2025-01-01T13:50:38.3183787Z",
|
||||||
"dateModified": "2025-01-01T13:40:38.3183791Z"
|
"dateModified": "2025-01-01T13:40:38.3183791Z",
|
||||||
|
"isHidden": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"items": [],
|
"items": [],
|
||||||
"path": "/media/movies/The Lord of the Rings - The Fellowship of the Ring (2001)/",
|
"path": "/media/movies/The Lord of the Rings - The Fellowship of the Ring (2001)/",
|
||||||
"name": "The Lord of the Rings - The Fellowship of the Ring (2001)",
|
"name": "The Lord of the Rings - The Fellowship of the Ring (2001)",
|
||||||
"dateCreated": "2025-01-01T13:50:38.3184681Z",
|
"dateCreated": "2025-01-01T13:50:38.3184681Z",
|
||||||
"dateModified": "2025-01-01T13:40:38.3184683Z"
|
"dateModified": "2025-01-01T13:40:38.3184683Z",
|
||||||
|
"isHidden": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
@@ -31,6 +31,7 @@ GET api/v1/drives/get-drives
|
|||||||
"path": "C:\\",
|
"path": "C:\\",
|
||||||
"name": "C:\\",
|
"name": "C:\\",
|
||||||
"itemType": "Root",
|
"itemType": "Root",
|
||||||
|
"isHidden": false,
|
||||||
"isExpanded": false,
|
"isExpanded": false,
|
||||||
"childrenLoaded": false,
|
"childrenLoaded": false,
|
||||||
"children": []
|
"children": []
|
||||||
@@ -39,6 +40,7 @@ GET api/v1/drives/get-drives
|
|||||||
"path": "D:\\",
|
"path": "D:\\",
|
||||||
"name": "D:\\",
|
"name": "D:\\",
|
||||||
"itemType": "Root",
|
"itemType": "Root",
|
||||||
|
"isHidden": false,
|
||||||
"isExpanded": false,
|
"isExpanded": false,
|
||||||
"childrenLoaded": false,
|
"childrenLoaded": false,
|
||||||
"children": []
|
"children": []
|
||||||
|
|||||||
@@ -35,14 +35,16 @@ GET api/v1/files/get-files?path=C%3A%5CUsers%5C&shouldIncludeHiddenElements=true
|
|||||||
"path": "/media/movies/The Matrix (1999)/The Matrix.mkv",
|
"path": "/media/movies/The Matrix (1999)/The Matrix.mkv",
|
||||||
"name": "The Matrix.mkv",
|
"name": "The Matrix.mkv",
|
||||||
"dateCreated": "2025-01-01T13:50:38.3143711Z",
|
"dateCreated": "2025-01-01T13:50:38.3143711Z",
|
||||||
"dateModified": "2025-01-01T13:40:38.3143719Z"
|
"dateModified": "2025-01-01T13:40:38.3143719Z",
|
||||||
|
"isHidden": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size": 6897,
|
"size": 6897,
|
||||||
"path": "/media/movies/The Matrix (1999)/The Matrix.en.srt",
|
"path": "/media/movies/The Matrix (1999)/The Matrix.en.srt",
|
||||||
"name": "The Matrix.en.srt",
|
"name": "The Matrix.en.srt",
|
||||||
"dateCreated": "2025-01-01T13:50:38.3145606Z",
|
"dateCreated": "2025-01-01T13:50:38.3145606Z",
|
||||||
"dateModified": "2025-01-01T13:40:38.3145609Z"
|
"dateModified": "2025-01-01T13:40:38.3145609Z",
|
||||||
|
"isHidden": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
@@ -67,6 +69,7 @@ GET api/v1/files/get-tree-files?path=C%3A%5CUsers%5C&shouldIncludeHiddenElements
|
|||||||
"path": "/media/movies/The Matrix (1999)/The Matrix.mkv",
|
"path": "/media/movies/The Matrix (1999)/The Matrix.mkv",
|
||||||
"name": "The Matrix.mkv",
|
"name": "The Matrix.mkv",
|
||||||
"itemType": "File",
|
"itemType": "File",
|
||||||
|
"isHidden": false,
|
||||||
"isExpanded": false,
|
"isExpanded": false,
|
||||||
"childrenLoaded": false,
|
"childrenLoaded": false,
|
||||||
"children": []
|
"children": []
|
||||||
@@ -75,6 +78,7 @@ GET api/v1/files/get-tree-files?path=C%3A%5CUsers%5C&shouldIncludeHiddenElements
|
|||||||
"path": "/media/movies/The Matrix (1999)/The Matrix.en.srt",
|
"path": "/media/movies/The Matrix (1999)/The Matrix.en.srt",
|
||||||
"name": "The Matrix.en.srt",
|
"name": "The Matrix.en.srt",
|
||||||
"itemType": "File",
|
"itemType": "File",
|
||||||
|
"isHidden": false,
|
||||||
"isExpanded": false,
|
"isExpanded": false,
|
||||||
"childrenLoaded": false,
|
"childrenLoaded": false,
|
||||||
"children": []
|
"children": []
|
||||||
@@ -83,6 +87,7 @@ GET api/v1/files/get-tree-files?path=C%3A%5CUsers%5C&shouldIncludeHiddenElements
|
|||||||
"path": "/media/movies/The Matrix (1999)/poster.jpg",
|
"path": "/media/movies/The Matrix (1999)/poster.jpg",
|
||||||
"name": "poster.jpg",
|
"name": "poster.jpg",
|
||||||
"itemType": "File",
|
"itemType": "File",
|
||||||
|
"isHidden": false,
|
||||||
"isExpanded": false,
|
"isExpanded": false,
|
||||||
"childrenLoaded": false,
|
"childrenLoaded": false,
|
||||||
"children": []
|
"children": []
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ The manifest is a JSON object describing the theme. The example below is the man
|
|||||||
"name": "Editorial Paper",
|
"name": "Editorial Paper",
|
||||||
"description": "A clean, readable proof of concept theme.",
|
"description": "A clean, readable proof of concept theme.",
|
||||||
"author": "Lumina",
|
"author": "Lumina",
|
||||||
"version": "1.4.0",
|
"version": "1.5.61",
|
||||||
"preview": "assets/preview.svg",
|
"preview": "assets/preview.svg",
|
||||||
"templates": {
|
"templates": {
|
||||||
"default": "templates/index.html"
|
"default": "templates/index.html"
|
||||||
@@ -511,8 +511,8 @@ The sub templates are rendered client side by the application script for each dy
|
|||||||
|
|
||||||
| Template | Fields |
|
| Template | Fields |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `tree-node` | `path`, `name`, `itemType` (`Root`, `Directory` or `File`), `isRoot`, `isDirectory`, `isFile`, `isExpanded` and `icon`. The node must keep the `.tree-node` root with its `data-path`, the `.node-content`, `.expand-button` (or `.spacer` for files), `.node-icon` and `.node-name` elements, and the `.child-nodes` container. |
|
| `tree-node` | `path`, `name`, `itemType` (`Root`, `Directory` or `File`), `isRoot`, `isDirectory`, `isFile`, `isHidden`, `isExpanded` and `icon`. The node must keep the `.tree-node` root with its `data-path`, the `.node-content`, `.expand-button` (or `.spacer` for files), `.node-icon` and `.node-name` elements, and the `.child-nodes` container. When `isHidden` is true the application also adds the `is-hidden` class to the root, so a theme can dim hidden nodes. |
|
||||||
| `explorer-item` | `path`, `name`, `itemType` (`Directory` or `File`), `isDirectory`, `isFile`, `cssClass` (the active view mode, such as `large-icons`) and `iconUrl`. The item must keep the `.e` root with its `data-path` and `data-type`, and an `<img>` element, which the script replaces with thumbnails for image files. |
|
| `explorer-item` | `path`, `name`, `itemType` (`Directory` or `File`), `isDirectory`, `isFile`, `isHidden`, `cssClass` (the active view mode, such as `large-icons`) and `iconUrl`. The item must keep the `.e` root with its `data-path` and `data-type`, and an `<img>` element, which the script replaces with thumbnails for image files. When `isHidden` is true the application also adds the `is-hidden` class to the root, so a theme can dim hidden items. |
|
||||||
| `path-segment` | `id`, `path` (the segment name), `dataPath` (the full path up to and including the segment), `toggleId` and `dropdownId`. The segment must keep the combobox structure with its `.navigator-combobox` (`data-path`), `.navigator-toggle-checkbox`, `.navigator-selected-text`, `.navigator-arrow` and `.navigator-dropdown` elements. |
|
| `path-segment` | `id`, `path` (the segment name), `dataPath` (the full path up to and including the segment), `toggleId` and `dropdownId`. The segment must keep the combobox structure with its `.navigator-combobox` (`data-path`), `.navigator-toggle-checkbox`, `.navigator-selected-text`, `.navigator-arrow` and `.navigator-dropdown` elements. |
|
||||||
|
|
||||||
#### The file icons mapping (assets/file-icons.json)
|
#### The file icons mapping (assets/file-icons.json)
|
||||||
|
|||||||
+4
-4
@@ -26,10 +26,10 @@ public static class DirectoryMapping
|
|||||||
Name = domainEntity.Name,
|
Name = domainEntity.Name,
|
||||||
Path = domainEntity.Id.Path,
|
Path = domainEntity.Id.Path,
|
||||||
ItemType = domainEntity.Type,
|
ItemType = domainEntity.Type,
|
||||||
|
IsHidden = domainEntity.IsHidden,
|
||||||
IsExpanded = false,
|
IsExpanded = false,
|
||||||
ChildrenLoaded = false,
|
ChildrenLoaded = false,
|
||||||
Children = domainEntity.Items.Select(item => item.ToTreeNodeResponse())
|
Children = [.. domainEntity.Items.Select(item => item.ToTreeNodeResponse())]
|
||||||
.ToList()
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,8 +55,8 @@ public static class DirectoryMapping
|
|||||||
domainEntity.Name,
|
domainEntity.Name,
|
||||||
domainEntity.DateCreated.Value,
|
domainEntity.DateCreated.Value,
|
||||||
domainEntity.DateModified.Value,
|
domainEntity.DateModified.Value,
|
||||||
domainEntity.Items.Select(fileSystemItem => fileSystemItem.ToFileSystemItemDto())
|
[.. domainEntity.Items.Select(fileSystemItem => fileSystemItem.ToFileSystemItemDto())],
|
||||||
.ToList()
|
domainEntity.IsHidden
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -28,7 +28,8 @@ public static class FileSystemItemMapping
|
|||||||
domainEntity.Id.Path,
|
domainEntity.Id.Path,
|
||||||
domainEntity.Name,
|
domainEntity.Name,
|
||||||
DateTime.Now,
|
DateTime.Now,
|
||||||
DateTime.Now
|
DateTime.Now,
|
||||||
|
domainEntity.IsHidden
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ public static class FileMapping
|
|||||||
Name = domainEntity.Name,
|
Name = domainEntity.Name,
|
||||||
Path = domainEntity.Id.Path,
|
Path = domainEntity.Id.Path,
|
||||||
ItemType = domainEntity.Type,
|
ItemType = domainEntity.Type,
|
||||||
|
IsHidden = domainEntity.IsHidden,
|
||||||
IsExpanded = false,
|
IsExpanded = false,
|
||||||
ChildrenLoaded = false
|
ChildrenLoaded = false
|
||||||
};
|
};
|
||||||
@@ -52,7 +53,8 @@ public static class FileMapping
|
|||||||
domainEntity.Name,
|
domainEntity.Name,
|
||||||
domainEntity.DateCreated.HasValue ? domainEntity.DateCreated.Value : default,
|
domainEntity.DateCreated.HasValue ? domainEntity.DateCreated.Value : default,
|
||||||
domainEntity.DateModified.HasValue ? domainEntity.DateModified.Value : default,
|
domainEntity.DateModified.HasValue ? domainEntity.DateModified.Value : default,
|
||||||
domainEntity.Size
|
domainEntity.Size,
|
||||||
|
domainEntity.IsHidden
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,12 @@ namespace Lumina.Contracts.DTO.FileSystemManagement;
|
|||||||
/// <param name="Name">The name of the file system item.</param>
|
/// <param name="Name">The name of the file system item.</param>
|
||||||
/// <param name="DateCreated">The creation date of the file system item.</param>
|
/// <param name="DateCreated">The creation date of the file system item.</param>
|
||||||
/// <param name="DateModified">The modification date of the file system item.</param>
|
/// <param name="DateModified">The modification date of the file system item.</param>
|
||||||
|
/// <param name="IsHidden">Whether the file system item is hidden.</param>
|
||||||
[DebuggerDisplay("Name: {Name}")]
|
[DebuggerDisplay("Name: {Name}")]
|
||||||
public record FileSystemItemDto(
|
public record FileSystemItemDto(
|
||||||
string Path,
|
string Path,
|
||||||
string Name,
|
string Name,
|
||||||
DateTime DateCreated,
|
DateTime DateCreated,
|
||||||
DateTime DateModified
|
DateTime DateModified,
|
||||||
|
bool IsHidden
|
||||||
);
|
);
|
||||||
+5
@@ -27,6 +27,11 @@ public class FileSystemTreeNodeResponse
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public FileSystemItemType ItemType { get; set; }
|
public FileSystemItemType ItemType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether the file or directory is hidden.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsHidden { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether the node is expanded.
|
/// Gets or sets a value indicating whether the node is expanded.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
+4
-2
@@ -15,11 +15,13 @@ namespace Lumina.Contracts.Responses.FileSystemManagement.Directories;
|
|||||||
/// <param name="DateCreated">The creation date of the directory.</param>
|
/// <param name="DateCreated">The creation date of the directory.</param>
|
||||||
/// <param name="DateModified">The modification date of the directory.</param>
|
/// <param name="DateModified">The modification date of the directory.</param>
|
||||||
/// <param name="Items">The children items of the directory.</param>
|
/// <param name="Items">The children items of the directory.</param>
|
||||||
|
/// <param name="IsHidden">Whether the directory is hidden.</param>
|
||||||
[DebuggerDisplay("Name: {Name} (Directory)")]
|
[DebuggerDisplay("Name: {Name} (Directory)")]
|
||||||
public record DirectoryResponse(
|
public record DirectoryResponse(
|
||||||
string Path,
|
string Path,
|
||||||
string Name,
|
string Name,
|
||||||
DateTime DateCreated,
|
DateTime DateCreated,
|
||||||
DateTime DateModified,
|
DateTime DateModified,
|
||||||
List<FileSystemItemDto> Items
|
List<FileSystemItemDto> Items,
|
||||||
) : FileSystemItemDto(Path, Name, DateCreated, DateModified);
|
bool IsHidden
|
||||||
|
) : FileSystemItemDto(Path, Name, DateCreated, DateModified, IsHidden);
|
||||||
@@ -14,11 +14,13 @@ namespace Lumina.Contracts.Responses.FileSystemManagement.Files;
|
|||||||
/// <param name="DateCreated">The creation date of the file.</param>
|
/// <param name="DateCreated">The creation date of the file.</param>
|
||||||
/// <param name="DateModified">The modification date of the file.</param>
|
/// <param name="DateModified">The modification date of the file.</param>
|
||||||
/// <param name="Size">The size of the file, in bytes.</param>
|
/// <param name="Size">The size of the file, in bytes.</param>
|
||||||
|
/// <param name="IsHidden">Whether the file is hidden.</param>
|
||||||
[DebuggerDisplay("Name: {Name} (File, Size: {Size} bytes)")]
|
[DebuggerDisplay("Name: {Name} (File, Size: {Size} bytes)")]
|
||||||
public record FileResponse(
|
public record FileResponse(
|
||||||
string Path,
|
string Path,
|
||||||
string Name,
|
string Name,
|
||||||
DateTime DateCreated,
|
DateTime DateCreated,
|
||||||
DateTime DateModified,
|
DateTime DateModified,
|
||||||
long Size
|
long Size,
|
||||||
) : FileSystemItemDto(Path, Name, DateCreated, DateModified);
|
bool IsHidden
|
||||||
|
) : FileSystemItemDto(Path, Name, DateCreated, DateModified, IsHidden);
|
||||||
+14
-4
@@ -53,6 +53,7 @@ public sealed class Directory : FileSystemItem
|
|||||||
/// <param name="dateCreated">The date and time the directory was created. Can be optional if unknown.</param>
|
/// <param name="dateCreated">The date and time the directory was created. Can be optional if unknown.</param>
|
||||||
/// <param name="dateModified">The date and time the directory was last modified. Can be optional if unknown.</param>
|
/// <param name="dateModified">The date and time the directory was last modified. Can be optional if unknown.</param>
|
||||||
/// <param name="status">The status of the file system item.</param>
|
/// <param name="status">The status of the file system item.</param>
|
||||||
|
/// <param name="isHidden">Whether the directory is hidden.</param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="Directory"/>, or an error message.
|
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="Directory"/>, or an error message.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
@@ -61,9 +62,10 @@ public sealed class Directory : FileSystemItem
|
|||||||
string name,
|
string name,
|
||||||
Optional<DateTime> dateCreated,
|
Optional<DateTime> dateCreated,
|
||||||
Optional<DateTime> dateModified,
|
Optional<DateTime> dateModified,
|
||||||
FileSystemItemStatus status = FileSystemItemStatus.Accessible)
|
FileSystemItemStatus status = FileSystemItemStatus.Accessible,
|
||||||
|
bool isHidden = false)
|
||||||
{
|
{
|
||||||
// TODO: enforce invariants
|
// TODO: enforce invariants.
|
||||||
Result<FileSystemPathId> createPathResult = FileSystemPathId.Create(path);
|
Result<FileSystemPathId> createPathResult = FileSystemPathId.Create(path);
|
||||||
if (createPathResult.IsFailure)
|
if (createPathResult.IsFailure)
|
||||||
return createPathResult.Errors;
|
return createPathResult.Errors;
|
||||||
@@ -75,6 +77,9 @@ public sealed class Directory : FileSystemItem
|
|||||||
Result<Updated> setStatusResult = newDirectory.SetStatus(status);
|
Result<Updated> setStatusResult = newDirectory.SetStatus(status);
|
||||||
if (setStatusResult.IsFailure)
|
if (setStatusResult.IsFailure)
|
||||||
return setStatusResult.Errors;
|
return setStatusResult.Errors;
|
||||||
|
Result<Updated> setHiddenStateResult = newDirectory.SetHiddenState(isHidden);
|
||||||
|
if (setHiddenStateResult.IsFailure)
|
||||||
|
return setHiddenStateResult.Errors;
|
||||||
return newDirectory;
|
return newDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,6 +90,7 @@ public sealed class Directory : FileSystemItem
|
|||||||
/// <param name="dateCreated">The date and time the directory was created. Can be optional if unknown.</param>
|
/// <param name="dateCreated">The date and time the directory was created. Can be optional if unknown.</param>
|
||||||
/// <param name="dateModified">The date and time the directory was last modified. Can be optional if unknown.</param>
|
/// <param name="dateModified">The date and time the directory was last modified. Can be optional if unknown.</param>
|
||||||
/// <param name="status">The status of the file system item.</param>
|
/// <param name="status">The status of the file system item.</param>
|
||||||
|
/// <param name="isHidden">Whether the directory is hidden.</param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="Directory"/>, or an error message.
|
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="Directory"/>, or an error message.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
@@ -93,9 +99,10 @@ public sealed class Directory : FileSystemItem
|
|||||||
string name,
|
string name,
|
||||||
Optional<DateTime> dateCreated,
|
Optional<DateTime> dateCreated,
|
||||||
Optional<DateTime> dateModified,
|
Optional<DateTime> dateModified,
|
||||||
FileSystemItemStatus status = FileSystemItemStatus.Accessible)
|
FileSystemItemStatus status = FileSystemItemStatus.Accessible,
|
||||||
|
bool isHidden = false)
|
||||||
{
|
{
|
||||||
// TODO: enforce invariants
|
// TODO: enforce invariants.
|
||||||
Directory newDirectory = new(
|
Directory newDirectory = new(
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
@@ -104,6 +111,9 @@ public sealed class Directory : FileSystemItem
|
|||||||
Result<Updated> setStatusResult = newDirectory.SetStatus(status);
|
Result<Updated> setStatusResult = newDirectory.SetStatus(status);
|
||||||
if (setStatusResult.IsFailure)
|
if (setStatusResult.IsFailure)
|
||||||
return setStatusResult.Errors;
|
return setStatusResult.Errors;
|
||||||
|
Result<Updated> setHiddenStateResult = newDirectory.SetHiddenState(isHidden);
|
||||||
|
if (setHiddenStateResult.IsFailure)
|
||||||
|
return setHiddenStateResult.Errors;
|
||||||
return newDirectory;
|
return newDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-2
@@ -54,6 +54,7 @@ public sealed class File : FileSystemItem
|
|||||||
/// <param name="dateModified">The date and time the file was last modified. Can be optional if unknown.</param>
|
/// <param name="dateModified">The date and time the file was last modified. Can be optional if unknown.</param>
|
||||||
/// <param name="size">The size of the file in bytes.</param>
|
/// <param name="size">The size of the file in bytes.</param>
|
||||||
/// <param name="status">The status of the file system item.</param>
|
/// <param name="status">The status of the file system item.</param>
|
||||||
|
/// <param name="isHidden">Whether the file is hidden.</param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="File"/>, or an error message.
|
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="File"/>, or an error message.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
@@ -63,7 +64,8 @@ public sealed class File : FileSystemItem
|
|||||||
Optional<DateTime> dateCreated,
|
Optional<DateTime> dateCreated,
|
||||||
Optional<DateTime> dateModified,
|
Optional<DateTime> dateModified,
|
||||||
long size,
|
long size,
|
||||||
FileSystemItemStatus status = FileSystemItemStatus.Accessible)
|
FileSystemItemStatus status = FileSystemItemStatus.Accessible,
|
||||||
|
bool isHidden = false)
|
||||||
{
|
{
|
||||||
// TODO: enforce invariants
|
// TODO: enforce invariants
|
||||||
Result<FileSystemPathId> createPathResult = FileSystemPathId.Create(path);
|
Result<FileSystemPathId> createPathResult = FileSystemPathId.Create(path);
|
||||||
@@ -78,6 +80,9 @@ public sealed class File : FileSystemItem
|
|||||||
Result<Updated> setStatusResult = newFile.SetStatus(status);
|
Result<Updated> setStatusResult = newFile.SetStatus(status);
|
||||||
if (setStatusResult.IsFailure)
|
if (setStatusResult.IsFailure)
|
||||||
return setStatusResult.Errors;
|
return setStatusResult.Errors;
|
||||||
|
Result<Updated> setHiddenStateResult = newFile.SetHiddenState(isHidden);
|
||||||
|
if (setHiddenStateResult.IsFailure)
|
||||||
|
return setHiddenStateResult.Errors;
|
||||||
return newFile;
|
return newFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,6 +95,7 @@ public sealed class File : FileSystemItem
|
|||||||
/// <param name="dateModified">The date and time the file was last modified. Can be optional if unknown.</param>
|
/// <param name="dateModified">The date and time the file was last modified. Can be optional if unknown.</param>
|
||||||
/// <param name="size">The size of the file in bytes.</param>
|
/// <param name="size">The size of the file in bytes.</param>
|
||||||
/// <param name="status">The status of the file system item.</param>
|
/// <param name="status">The status of the file system item.</param>
|
||||||
|
/// <param name="isHidden">Whether the file is hidden.</param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="File"/>, or an error message.
|
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="File"/>, or an error message.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
@@ -99,7 +105,8 @@ public sealed class File : FileSystemItem
|
|||||||
Optional<DateTime> dateCreated,
|
Optional<DateTime> dateCreated,
|
||||||
Optional<DateTime> dateModified,
|
Optional<DateTime> dateModified,
|
||||||
long size,
|
long size,
|
||||||
FileSystemItemStatus status = FileSystemItemStatus.Accessible)
|
FileSystemItemStatus status = FileSystemItemStatus.Accessible,
|
||||||
|
bool isHidden = false)
|
||||||
{
|
{
|
||||||
// TODO: enforce invariants
|
// TODO: enforce invariants
|
||||||
File newFile = new(
|
File newFile = new(
|
||||||
@@ -111,6 +118,9 @@ public sealed class File : FileSystemItem
|
|||||||
Result<Updated> setStatusResult = newFile.SetStatus(status);
|
Result<Updated> setStatusResult = newFile.SetStatus(status);
|
||||||
if (setStatusResult.IsFailure)
|
if (setStatusResult.IsFailure)
|
||||||
return setStatusResult.Errors;
|
return setStatusResult.Errors;
|
||||||
|
Result<Updated> setHiddenStateResult = newFile.SetHiddenState(isHidden);
|
||||||
|
if (setHiddenStateResult.IsFailure)
|
||||||
|
return setHiddenStateResult.Errors;
|
||||||
return newFile;
|
return newFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+20
-5
@@ -1,10 +1,9 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Domain.Common.Primitives;
|
|
||||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
|
||||||
using Lumina.Domain.Common.Errors;
|
using Lumina.Domain.Common.Errors;
|
||||||
using Lumina.Domain.Common.Models.Core;
|
using Lumina.Domain.Common.Models.Core;
|
||||||
|
using Lumina.Domain.Common.Primitives;
|
||||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||||
|
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -36,6 +35,11 @@ public abstract class FileSystemItem : AggregateRoot<FileSystemPathId>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public FileSystemItemType Type { get; protected set; }
|
public FileSystemItemType Type { get; protected set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether the file system item is hidden.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsHidden { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="FileSystemItem"/> class.
|
/// Initializes a new instance of the <see cref="FileSystemItem"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -49,7 +53,7 @@ public abstract class FileSystemItem : AggregateRoot<FileSystemPathId>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the status of the filesystem item.
|
/// Sets the status of the file system item.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="status">The status to be set.</param>
|
/// <param name="status">The status to be set.</param>
|
||||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||||
@@ -60,7 +64,18 @@ public abstract class FileSystemItem : AggregateRoot<FileSystemPathId>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the parent of the filesystem item.
|
/// Sets the hidden state of the file system item.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="isHidden">Whether the file system item is hidden.</param>
|
||||||
|
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||||
|
public Result<Updated> SetHiddenState(bool isHidden)
|
||||||
|
{
|
||||||
|
IsHidden = isHidden;
|
||||||
|
return Result.Updated;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the parent of the file system item.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parent">The file system item to be set as parent.</param>
|
/// <param name="parent">The file system item to be set as parent.</param>
|
||||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||||
|
|||||||
+17
-4
@@ -1,10 +1,8 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Domain.Common.Primitives;
|
|
||||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
|
||||||
using Lumina.Domain.Common.Errors;
|
using Lumina.Domain.Common.Errors;
|
||||||
|
using Lumina.Domain.Common.Primitives;
|
||||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
|
||||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||||
|
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -54,6 +52,21 @@ internal class DirectoryProviderService : IDirectoryProviderService
|
|||||||
.AsEnumerable());
|
.AsEnumerable());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if the directory at the specified path is hidden.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">The path of the directory to check.</param>
|
||||||
|
/// <returns><see langword="true"/> when the directory is hidden, otherwise <see langword="false"/>, including when its attributes cannot be read.</returns>
|
||||||
|
public bool IsHidden(FileSystemPathId path)
|
||||||
|
{
|
||||||
|
// The hidden flag is metadata, so it follows the same read properties permission as the other metadata accessors.
|
||||||
|
if (!_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties, false))
|
||||||
|
return false;
|
||||||
|
// Child directory paths carry a trailing separator, which prevents the Unix file system from reporting the dot-prefixed hidden entry.
|
||||||
|
string directoryPath = path.Path.EndsWith(_fileSystem.Path.DirectorySeparatorChar) ? path.Path[..^1] : path.Path;
|
||||||
|
return (GetAttributes(directoryPath) & FileAttributes.Hidden) == FileAttributes.Hidden;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the attributes of a file system item identified by <paramref name="path"/>.
|
/// Gets the attributes of a file system item identified by <paramref name="path"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
+13
-10
@@ -1,12 +1,11 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Domain.Common.Primitives;
|
|
||||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
|
||||||
using Lumina.Domain.Common.Errors;
|
using Lumina.Domain.Common.Errors;
|
||||||
|
using Lumina.Domain.Common.Primitives;
|
||||||
|
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
|
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
|
||||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
|
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
|
||||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
#endregion
|
#endregion
|
||||||
@@ -76,13 +75,15 @@ public class DirectoryService : IDirectoryService
|
|||||||
Result<string> dirNameResult = _environmentContext.DirectoryProviderService.GetFileName(subPath);
|
Result<string> dirNameResult = _environmentContext.DirectoryProviderService.GetFileName(subPath);
|
||||||
Result<Optional<DateTime>> dateModifiedResult = _environmentContext.DirectoryProviderService.GetLastWriteTime(subPath);
|
Result<Optional<DateTime>> dateModifiedResult = _environmentContext.DirectoryProviderService.GetLastWriteTime(subPath);
|
||||||
Result<Optional<DateTime>> dateCreatedResult = _environmentContext.DirectoryProviderService.GetCreationTime(subPath);
|
Result<Optional<DateTime>> dateCreatedResult = _environmentContext.DirectoryProviderService.GetCreationTime(subPath);
|
||||||
|
// When hidden elements are excluded, the provider already filtered them out, so only an inclusive listing needs the attribute.
|
||||||
|
bool isHidden = shouldIncludeHiddenElements && _environmentContext.DirectoryProviderService.IsHidden(subPath);
|
||||||
|
|
||||||
// If any error occurred, mark the directory as inaccessible.
|
// If any error occurred, mark the directory as inaccessible.
|
||||||
if (dirNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure)
|
if (dirNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure)
|
||||||
{
|
{
|
||||||
Result<Directory> errorDirResult = Directory.Create(subPath, !dirNameResult.IsFailure ? dirNameResult.Value : null!,
|
Result<Directory> errorDirResult = Directory.Create(subPath, !dirNameResult.IsFailure ? dirNameResult.Value : null!,
|
||||||
!dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
!dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||||
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None());
|
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None(), isHidden: isHidden);
|
||||||
if (errorDirResult.IsFailure)
|
if (errorDirResult.IsFailure)
|
||||||
return errorDirResult.Errors;
|
return errorDirResult.Errors;
|
||||||
Result<Updated> setStatusResult = errorDirResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
Result<Updated> setStatusResult = errorDirResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
||||||
@@ -92,7 +93,7 @@ public class DirectoryService : IDirectoryService
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Result<Directory> subDirectoryResult = Directory.Create(subPath, dirNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value);
|
Result<Directory> subDirectoryResult = Directory.Create(subPath, dirNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, isHidden: isHidden);
|
||||||
if (subDirectoryResult.IsFailure)
|
if (subDirectoryResult.IsFailure)
|
||||||
return subDirectoryResult.Errors;
|
return subDirectoryResult.Errors;
|
||||||
result.Add(subDirectoryResult.Value);
|
result.Add(subDirectoryResult.Value);
|
||||||
@@ -141,12 +142,13 @@ public class DirectoryService : IDirectoryService
|
|||||||
Result<string> dirNameResult = _environmentContext.DirectoryProviderService.GetFileName(newDirectoryPathResult.Value);
|
Result<string> dirNameResult = _environmentContext.DirectoryProviderService.GetFileName(newDirectoryPathResult.Value);
|
||||||
Result<Optional<DateTime>> dateModifiedResult = _environmentContext.DirectoryProviderService.GetLastWriteTime(newDirectoryPathResult.Value);
|
Result<Optional<DateTime>> dateModifiedResult = _environmentContext.DirectoryProviderService.GetLastWriteTime(newDirectoryPathResult.Value);
|
||||||
Result<Optional<DateTime>> dateCreatedResult = _environmentContext.DirectoryProviderService.GetCreationTime(newDirectoryPathResult.Value);
|
Result<Optional<DateTime>> dateCreatedResult = _environmentContext.DirectoryProviderService.GetCreationTime(newDirectoryPathResult.Value);
|
||||||
|
bool isHidden = _environmentContext.DirectoryProviderService.IsHidden(newDirectoryPathResult.Value);
|
||||||
// If any error occurred, mark the directory as inaccessible.
|
// If any error occurred, mark the directory as inaccessible.
|
||||||
if (dirNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure)
|
if (dirNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure)
|
||||||
{
|
{
|
||||||
Result<Directory> errorDirResult = Directory.Create(newDirectoryPathResult.Value, !dirNameResult.IsFailure ? dirNameResult.Value : null!,
|
Result<Directory> errorDirResult = Directory.Create(newDirectoryPathResult.Value, !dirNameResult.IsFailure ? dirNameResult.Value : null!,
|
||||||
!dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
!dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||||
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None());
|
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None(), isHidden: isHidden);
|
||||||
if (errorDirResult.IsFailure)
|
if (errorDirResult.IsFailure)
|
||||||
return errorDirResult.Errors;
|
return errorDirResult.Errors;
|
||||||
Result<Updated> setStatusResult = errorDirResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
Result<Updated> setStatusResult = errorDirResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
||||||
@@ -155,7 +157,7 @@ public class DirectoryService : IDirectoryService
|
|||||||
return errorDirResult;
|
return errorDirResult;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return Directory.Create(newDirectoryPathResult.Value, dirNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value);
|
return Directory.Create(newDirectoryPathResult.Value, dirNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, isHidden: isHidden);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,12 +293,13 @@ public class DirectoryService : IDirectoryService
|
|||||||
Result<string> dirNameResult = _environmentContext.DirectoryProviderService.GetFileName(newDirectoryPathResult.Value);
|
Result<string> dirNameResult = _environmentContext.DirectoryProviderService.GetFileName(newDirectoryPathResult.Value);
|
||||||
Result<Optional<DateTime>> dateModifiedResult = _environmentContext.DirectoryProviderService.GetLastWriteTime(newDirectoryPathResult.Value);
|
Result<Optional<DateTime>> dateModifiedResult = _environmentContext.DirectoryProviderService.GetLastWriteTime(newDirectoryPathResult.Value);
|
||||||
Result<Optional<DateTime>> dateCreatedResult = _environmentContext.DirectoryProviderService.GetCreationTime(newDirectoryPathResult.Value);
|
Result<Optional<DateTime>> dateCreatedResult = _environmentContext.DirectoryProviderService.GetCreationTime(newDirectoryPathResult.Value);
|
||||||
|
bool isHidden = _environmentContext.DirectoryProviderService.IsHidden(newDirectoryPathResult.Value);
|
||||||
// If any error occurred, mark the directory as inaccessible.
|
// If any error occurred, mark the directory as inaccessible.
|
||||||
if (dirNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure)
|
if (dirNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure)
|
||||||
{
|
{
|
||||||
Result<Directory> errorDirResult = Directory.Create(newDirectoryPathResult.Value, !dirNameResult.IsFailure ? dirNameResult.Value : null!,
|
Result<Directory> errorDirResult = Directory.Create(newDirectoryPathResult.Value, !dirNameResult.IsFailure ? dirNameResult.Value : null!,
|
||||||
!dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
!dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||||
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None());
|
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None(), isHidden: isHidden);
|
||||||
if (errorDirResult.IsFailure)
|
if (errorDirResult.IsFailure)
|
||||||
return errorDirResult.Errors;
|
return errorDirResult.Errors;
|
||||||
Result<Updated> setStatusResult = errorDirResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
Result<Updated> setStatusResult = errorDirResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
||||||
@@ -305,7 +308,7 @@ public class DirectoryService : IDirectoryService
|
|||||||
return errorDirResult;
|
return errorDirResult;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return Directory.Create(newDirectoryPathResult.Value, dirNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value);
|
return Directory.Create(newDirectoryPathResult.Value, dirNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, isHidden: isHidden);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+15
-3
@@ -1,9 +1,8 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Domain.Common.Primitives;
|
|
||||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
|
||||||
using Lumina.Domain.Common.Errors;
|
using Lumina.Domain.Common.Errors;
|
||||||
|
using Lumina.Domain.Common.Primitives;
|
||||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||||
|
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -52,6 +51,19 @@ internal class FileProviderService : IFileProviderService
|
|||||||
.AsEnumerable());
|
.AsEnumerable());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if the file at the specified path is hidden.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">The path of the file to check.</param>
|
||||||
|
/// <returns><see langword="true"/> when the file is hidden, otherwise <see langword="false"/>, including when its attributes cannot be read.</returns>
|
||||||
|
public bool IsHidden(FileSystemPathId path)
|
||||||
|
{
|
||||||
|
// The hidden flag is metadata, so it follows the same read properties permission as the other metadata accessors.
|
||||||
|
if (!_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties))
|
||||||
|
return false;
|
||||||
|
return (GetAttributes(path.Path) & FileAttributes.Hidden) == FileAttributes.Hidden;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the attributes of a file system item identified by <paramref name="path"/>.
|
/// Gets the attributes of a file system item identified by <paramref name="path"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
+13
-8
@@ -78,12 +78,14 @@ public class FileService : IFileService
|
|||||||
Result<Optional<DateTime>> dateCreatedResult = _environmentContext.FileProviderService.GetCreationTime(filePath);
|
Result<Optional<DateTime>> dateCreatedResult = _environmentContext.FileProviderService.GetCreationTime(filePath);
|
||||||
Result<long?> sizeResult = _environmentContext.FileProviderService.GetSize(filePath);
|
Result<long?> sizeResult = _environmentContext.FileProviderService.GetSize(filePath);
|
||||||
long size = !sizeResult.IsFailure ? sizeResult.Value ?? 0 : 0;
|
long size = !sizeResult.IsFailure ? sizeResult.Value ?? 0 : 0;
|
||||||
|
// When hidden elements are excluded, the provider already filtered them out, so only an inclusive listing needs the attribute.
|
||||||
|
bool isHidden = shouldIncludeHiddenElements && _environmentContext.FileProviderService.IsHidden(filePath);
|
||||||
// If any of the details returned an error, set the inaccessible status.
|
// If any of the details returned an error, set the inaccessible status.
|
||||||
if (fileNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure || sizeResult.IsFailure)
|
if (fileNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure || sizeResult.IsFailure)
|
||||||
{
|
{
|
||||||
Result<File> errorFileResult = File.Create(filePath, !fileNameResult.IsFailure ? fileNameResult.Value : null!,
|
Result<File> errorFileResult = File.Create(filePath, !fileNameResult.IsFailure ? fileNameResult.Value : null!,
|
||||||
!dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
!dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||||
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None(), size);
|
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None(), size, isHidden: isHidden);
|
||||||
if (errorFileResult.IsFailure)
|
if (errorFileResult.IsFailure)
|
||||||
return errorFileResult.Errors;
|
return errorFileResult.Errors;
|
||||||
Result<Updated> setStatusResult = errorFileResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
Result<Updated> setStatusResult = errorFileResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
||||||
@@ -93,7 +95,7 @@ public class FileService : IFileService
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Result<File> fileResult = File.Create(filePath, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size);
|
Result<File> fileResult = File.Create(filePath, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size, isHidden: isHidden);
|
||||||
if (fileResult.IsFailure)
|
if (fileResult.IsFailure)
|
||||||
return fileResult.Errors;
|
return fileResult.Errors;
|
||||||
result.Add(fileResult.Value);
|
result.Add(fileResult.Value);
|
||||||
@@ -150,12 +152,13 @@ public class FileService : IFileService
|
|||||||
Result<Optional<DateTime>> dateCreatedResult = _environmentContext.FileProviderService.GetCreationTime(copyFileResult.Value);
|
Result<Optional<DateTime>> dateCreatedResult = _environmentContext.FileProviderService.GetCreationTime(copyFileResult.Value);
|
||||||
Result<long?> sizeResult = _environmentContext.FileProviderService.GetSize(copyFileResult.Value);
|
Result<long?> sizeResult = _environmentContext.FileProviderService.GetSize(copyFileResult.Value);
|
||||||
long size = !sizeResult.IsFailure ? sizeResult.Value ?? 0 : 0;
|
long size = !sizeResult.IsFailure ? sizeResult.Value ?? 0 : 0;
|
||||||
|
bool isHidden = _environmentContext.FileProviderService.IsHidden(copyFileResult.Value);
|
||||||
// If any of the details returned an error, set the inaccessible status.
|
// If any of the details returned an error, set the inaccessible status.
|
||||||
if (fileNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure || sizeResult.IsFailure)
|
if (fileNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure || sizeResult.IsFailure)
|
||||||
{
|
{
|
||||||
Result<File> errorFileResult = File.Create(copyFileResult.Value, !fileNameResult.IsFailure ? fileNameResult.Value : null!,
|
Result<File> errorFileResult = File.Create(copyFileResult.Value, !fileNameResult.IsFailure ? fileNameResult.Value : null!,
|
||||||
!dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
!dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||||
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None(), size);
|
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None(), size, isHidden: isHidden);
|
||||||
if (errorFileResult.IsFailure)
|
if (errorFileResult.IsFailure)
|
||||||
return errorFileResult.Errors;
|
return errorFileResult.Errors;
|
||||||
Result<Updated> setStatusResult = errorFileResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
Result<Updated> setStatusResult = errorFileResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
||||||
@@ -164,7 +167,7 @@ public class FileService : IFileService
|
|||||||
return errorFileResult;
|
return errorFileResult;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return File.Create(copyFileResult.Value, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size);
|
return File.Create(copyFileResult.Value, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size, isHidden: isHidden);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,12 +219,13 @@ public class FileService : IFileService
|
|||||||
Result<Optional<DateTime>> dateCreatedResult = _environmentContext.FileProviderService.GetCreationTime(moveFileResult.Value);
|
Result<Optional<DateTime>> dateCreatedResult = _environmentContext.FileProviderService.GetCreationTime(moveFileResult.Value);
|
||||||
Result<long?> sizeResult = _environmentContext.FileProviderService.GetSize(moveFileResult.Value);
|
Result<long?> sizeResult = _environmentContext.FileProviderService.GetSize(moveFileResult.Value);
|
||||||
long size = !sizeResult.IsFailure ? sizeResult.Value ?? 0 : 0;
|
long size = !sizeResult.IsFailure ? sizeResult.Value ?? 0 : 0;
|
||||||
|
bool isHidden = _environmentContext.FileProviderService.IsHidden(moveFileResult.Value);
|
||||||
// If any of the details returned an error, set the inaccessible status.
|
// If any of the details returned an error, set the inaccessible status.
|
||||||
if (fileNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure || sizeResult.IsFailure)
|
if (fileNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure || sizeResult.IsFailure)
|
||||||
{
|
{
|
||||||
Result<File> errorFileResult = File.Create(moveFileResult.Value, !fileNameResult.IsFailure ? fileNameResult.Value : null!,
|
Result<File> errorFileResult = File.Create(moveFileResult.Value, !fileNameResult.IsFailure ? fileNameResult.Value : null!,
|
||||||
!dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
!dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||||
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None(), size);
|
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None(), size, isHidden: isHidden);
|
||||||
if (errorFileResult.IsFailure)
|
if (errorFileResult.IsFailure)
|
||||||
return errorFileResult.Errors;
|
return errorFileResult.Errors;
|
||||||
Result<Updated> setStatusResult = errorFileResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
Result<Updated> setStatusResult = errorFileResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
||||||
@@ -230,7 +234,7 @@ public class FileService : IFileService
|
|||||||
return errorFileResult;
|
return errorFileResult;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return File.Create(moveFileResult.Value, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size);
|
return File.Create(moveFileResult.Value, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size, isHidden: isHidden);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,12 +280,13 @@ public class FileService : IFileService
|
|||||||
Result<Optional<DateTime>> dateCreatedResult = _environmentContext.FileProviderService.GetCreationTime(newFilePathResult.Value);
|
Result<Optional<DateTime>> dateCreatedResult = _environmentContext.FileProviderService.GetCreationTime(newFilePathResult.Value);
|
||||||
Result<long?> sizeResult = _environmentContext.FileProviderService.GetSize(newFilePathResult.Value);
|
Result<long?> sizeResult = _environmentContext.FileProviderService.GetSize(newFilePathResult.Value);
|
||||||
long size = !sizeResult.IsFailure ? sizeResult.Value ?? 0 : 0;
|
long size = !sizeResult.IsFailure ? sizeResult.Value ?? 0 : 0;
|
||||||
|
bool isHidden = _environmentContext.FileProviderService.IsHidden(newFilePathResult.Value);
|
||||||
// If any of the details returned an error, set the inaccessible status.
|
// If any of the details returned an error, set the inaccessible status.
|
||||||
if (fileNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure || sizeResult.IsFailure)
|
if (fileNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure || sizeResult.IsFailure)
|
||||||
{
|
{
|
||||||
Result<File> errorFileResult = File.Create(newFilePathResult.Value, !fileNameResult.IsFailure ? fileNameResult.Value : null!,
|
Result<File> errorFileResult = File.Create(newFilePathResult.Value, !fileNameResult.IsFailure ? fileNameResult.Value : null!,
|
||||||
!dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
!dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||||
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None(), size);
|
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None(), size, isHidden: isHidden);
|
||||||
if (errorFileResult.IsFailure)
|
if (errorFileResult.IsFailure)
|
||||||
return errorFileResult.Errors;
|
return errorFileResult.Errors;
|
||||||
Result<Updated> setStatusResult = errorFileResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
Result<Updated> setStatusResult = errorFileResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
||||||
@@ -290,7 +295,7 @@ public class FileService : IFileService
|
|||||||
return errorFileResult;
|
return errorFileResult;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return File.Create(newFilePathResult.Value, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size);
|
return File.Create(newFilePathResult.Value, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size, isHidden: isHidden);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
@@ -21,6 +21,13 @@ public interface IDirectoryProviderService
|
|||||||
/// <returns>An <see cref="Result{TValue}"/> containing either a collection of directory paths or an error.</returns>
|
/// <returns>An <see cref="Result{TValue}"/> containing either a collection of directory paths or an error.</returns>
|
||||||
Result<IEnumerable<FileSystemPathId>> GetSubdirectoryPaths(FileSystemPathId path, bool shouldIncludeHiddenElements);
|
Result<IEnumerable<FileSystemPathId>> GetSubdirectoryPaths(FileSystemPathId path, bool shouldIncludeHiddenElements);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if the directory at the specified path is hidden.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">The path of the directory to check.</param>
|
||||||
|
/// <returns><see langword="true"/> when the directory is hidden, otherwise <see langword="false"/>, including when its attributes cannot be read.</returns>
|
||||||
|
bool IsHidden(FileSystemPathId path);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if a directory with the specified path exists.
|
/// Checks if a directory with the specified path exists.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
+7
@@ -21,6 +21,13 @@ public interface IFileProviderService
|
|||||||
/// <returns>An <see cref="Result{TValue}"/> containing either a collection of file paths, or an error.</returns>
|
/// <returns>An <see cref="Result{TValue}"/> containing either a collection of file paths, or an error.</returns>
|
||||||
Result<IEnumerable<FileSystemPathId>> GetFilePaths(FileSystemPathId path, bool shouldIncludeHiddenElements);
|
Result<IEnumerable<FileSystemPathId>> GetFilePaths(FileSystemPathId path, bool shouldIncludeHiddenElements);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if the file at the specified path is hidden.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">The path of the file to check.</param>
|
||||||
|
/// <returns><see langword="true"/> when the file is hidden, otherwise <see langword="false"/>, including when its attributes cannot be read.</returns>
|
||||||
|
bool IsHidden(FileSystemPathId path);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves the contents of a file at the specified path.
|
/// Retrieves the contents of a file at the specified path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
+2
-2
@@ -37,8 +37,8 @@ public class GetDirectoriesEndpointSummary : Summary<GetDirectoriesEndpoint, Get
|
|||||||
|
|
||||||
Response(200, "The list of directories for the specified path is returned.",
|
Response(200, "The list of directories for the specified path is returned.",
|
||||||
example: new DirectoryResponse[] {
|
example: new DirectoryResponse[] {
|
||||||
new(Path: "/media/movies/The Matrix (1999)/", Name: "The Matrix", DateCreated: DateTime.UtcNow, DateModified: DateTime.UtcNow.AddMinutes(-10), Items: []),
|
new(Path: "/media/movies/The Matrix (1999)/", Name: "The Matrix", DateCreated: DateTime.UtcNow, DateModified: DateTime.UtcNow.AddMinutes(-10), Items: [], IsHidden: false),
|
||||||
new(Path: "/media/movies/The Lord of the Rings - The Fellowship of the Ring (2001)/", Name: "The Lord of the Rings - The Fellowship of the Ring (2001)", DateCreated: DateTime.UtcNow, DateModified: DateTime.UtcNow.AddMinutes(-10), Items: [])
|
new(Path: "/media/movies/The Lord of the Rings - The Fellowship of the Ring (2001)/", Name: "The Lord of the Rings - The Fellowship of the Ring (2001)", DateCreated: DateTime.UtcNow, DateModified: DateTime.UtcNow.AddMinutes(-10), Items: [], IsHidden: false)
|
||||||
});
|
});
|
||||||
|
|
||||||
Response(401, "Authentication required.", "application/problem+json",
|
Response(401, "Authentication required.", "application/problem+json",
|
||||||
|
|||||||
+2
-2
@@ -24,8 +24,8 @@ public class GetDrivesEndpointSummary : Summary<GetDrivesEndpoint, EmptyRequest>
|
|||||||
|
|
||||||
Response(200, "The list of file system drives is returned.",
|
Response(200, "The list of file system drives is returned.",
|
||||||
example: new FileSystemTreeNodeResponse[] {
|
example: new FileSystemTreeNodeResponse[] {
|
||||||
new() { Path = "C:\\", Name = "C:\\", ItemType = FileSystemItemType.Root, IsExpanded = false, ChildrenLoaded = false, Children = [] },
|
new() { Path = "C:\\", Name = "C:\\", ItemType = FileSystemItemType.Root, IsHidden = false, IsExpanded = false, ChildrenLoaded = false, Children = [] },
|
||||||
new() { Path = "D:\\", Name = "D:\\", ItemType = FileSystemItemType.Root, IsExpanded = false, ChildrenLoaded = false, Children = [] }
|
new() { Path = "D:\\", Name = "D:\\", ItemType = FileSystemItemType.Root, IsHidden = false, IsExpanded = false, ChildrenLoaded = false, Children = [] }
|
||||||
});
|
});
|
||||||
|
|
||||||
Response(401, "Authentication required.", "application/problem+json",
|
Response(401, "Authentication required.", "application/problem+json",
|
||||||
|
|||||||
+2
-3
@@ -1,7 +1,6 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Lumina.Contracts.Requests.FileSystemManagement.Files;
|
using Lumina.Contracts.Requests.FileSystemManagement.Files;
|
||||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
|
||||||
using Lumina.Contracts.Responses.FileSystemManagement.Files;
|
using Lumina.Contracts.Responses.FileSystemManagement.Files;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -38,8 +37,8 @@ public class GetFilesEndpointSummary : Summary<GetFilesEndpoint, GetFilesRequest
|
|||||||
|
|
||||||
Response(200, "The list of files is returned.",
|
Response(200, "The list of files is returned.",
|
||||||
example: new FileResponse[] {
|
example: new FileResponse[] {
|
||||||
new(Path: "/media/movies/The Matrix (1999)/The Matrix.mkv", Name: "The Matrix.mkv", DateCreated: DateTime.UtcNow, DateModified: DateTime.UtcNow.AddMinutes(-10), Size: 754045401),
|
new(Path: "/media/movies/The Matrix (1999)/The Matrix.mkv", Name: "The Matrix.mkv", DateCreated: DateTime.UtcNow, DateModified: DateTime.UtcNow.AddMinutes(-10), Size: 754045401, IsHidden: false),
|
||||||
new(Path: "/media/movies/The Matrix (1999)/The Matrix.en.srt", Name: "The Matrix.en.srt", DateCreated: DateTime.UtcNow, DateModified: DateTime.UtcNow.AddMinutes(-10), Size: 6897)
|
new(Path: "/media/movies/The Matrix (1999)/The Matrix.en.srt", Name: "The Matrix.en.srt", DateCreated: DateTime.UtcNow, DateModified: DateTime.UtcNow.AddMinutes(-10), Size: 6897, IsHidden: false)
|
||||||
});
|
});
|
||||||
|
|
||||||
Response(401, "Authentication required.", "application/problem+json",
|
Response(401, "Authentication required.", "application/problem+json",
|
||||||
|
|||||||
+3
-3
@@ -37,9 +37,9 @@ public class GetTreeFilesEndpointSummary : Summary<GetTreeFilesEndpoint, GetTree
|
|||||||
|
|
||||||
Response(200, "The tree structure of files is returned.",
|
Response(200, "The tree structure of files is returned.",
|
||||||
example: new FileSystemTreeNodeResponse[] {
|
example: new FileSystemTreeNodeResponse[] {
|
||||||
new() { Path = "/media/movies/The Matrix (1999)/The Matrix.mkv", Name = "The Matrix.mkv", ItemType = FileSystemItemType.File, IsExpanded = false, ChildrenLoaded = false, Children = [] },
|
new() { Path = "/media/movies/The Matrix (1999)/The Matrix.mkv", Name = "The Matrix.mkv", ItemType = FileSystemItemType.File, IsHidden = false, IsExpanded = false, ChildrenLoaded = false, Children = [] },
|
||||||
new() { Path = "/media/movies/The Matrix (1999)/The Matrix.en.srt", Name = "The Matrix.en.srt", ItemType = FileSystemItemType.File, IsExpanded = false, ChildrenLoaded = false, Children = [] },
|
new() { Path = "/media/movies/The Matrix (1999)/The Matrix.en.srt", Name = "The Matrix.en.srt", ItemType = FileSystemItemType.File, IsHidden = false, IsExpanded = false, ChildrenLoaded = false, Children = [] },
|
||||||
new() { Path = "/media/movies/The Matrix (1999)/poster.jpg", Name = "poster.jpg", ItemType = FileSystemItemType.File, IsExpanded = false, ChildrenLoaded = false, Children = [] },
|
new() { Path = "/media/movies/The Matrix (1999)/poster.jpg", Name = "poster.jpg", ItemType = FileSystemItemType.File, IsHidden = false, IsExpanded = false, ChildrenLoaded = false, Children = [] },
|
||||||
});
|
});
|
||||||
|
|
||||||
Response(401, "Authentication required.", "application/problem+json",
|
Response(401, "Authentication required.", "application/problem+json",
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -30,4 +30,9 @@ public abstract class FileSystemItemDto
|
|||||||
/// Gets or sets the modification date of the file system item.
|
/// Gets or sets the modification date of the file system item.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime DateModified { get; set; }
|
public DateTime DateModified { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether the file system item is hidden.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsHidden { get; set; }
|
||||||
}
|
}
|
||||||
@@ -27,6 +27,11 @@ public class FileSystemTreeNodeDto
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public FileSystemItemType ItemType { get; set; }
|
public FileSystemItemType ItemType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether the file or directory is hidden.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsHidden { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether the node is expanded.
|
/// Gets or sets a value indicating whether the node is expanded.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
+4
-2
@@ -19,14 +19,16 @@ public class FileSystemItemDtoFixture
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a random valid <see cref="FileSystemItemDto"/>.
|
/// Creates a random valid <see cref="FileSystemItemDto"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="isHidden">Optional. Whether the file system item is hidden. If not provided, a random value is generated.</param>
|
||||||
/// <returns>The created <see cref="FileSystemItemDto"/>.</returns>
|
/// <returns>The created <see cref="FileSystemItemDto"/>.</returns>
|
||||||
public FileSystemItemDto Create()
|
public FileSystemItemDto Create(bool? isHidden = null)
|
||||||
{
|
{
|
||||||
return new FileSystemItemDto(
|
return new FileSystemItemDto(
|
||||||
_faker.System.FilePath(),
|
_faker.System.FilePath(),
|
||||||
_faker.System.FileName(),
|
_faker.System.FileName(),
|
||||||
_faker.Date.Past(),
|
_faker.Date.Past(),
|
||||||
_faker.Date.Recent()
|
_faker.Date.Recent(),
|
||||||
|
isHidden ?? _faker.Random.Bool()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -23,14 +23,16 @@ public class FileSystemTreeNodeResponseFixture
|
|||||||
/// <param name="currentDepth">The current depth in the tree structure. Default is 0 (root level).</param>
|
/// <param name="currentDepth">The current depth in the tree structure. Default is 0 (root level).</param>
|
||||||
/// <param name="maxDepth">The maximum depth of the tree structure. Default is 2.</param>
|
/// <param name="maxDepth">The maximum depth of the tree structure. Default is 2.</param>
|
||||||
/// <param name="maxChildren">The maximum number of children for each node. Default is 3.</param>
|
/// <param name="maxChildren">The maximum number of children for each node. Default is 3.</param>
|
||||||
|
/// <param name="isHidden">Optional. Whether the node is hidden. If not provided, a random value is generated.</param>
|
||||||
/// <returns>A <see cref="FileSystemTreeNodeResponse"/> with a nested structure.</returns>
|
/// <returns>A <see cref="FileSystemTreeNodeResponse"/> with a nested structure.</returns>
|
||||||
public FileSystemTreeNodeResponse Create(int currentDepth = 0, int maxDepth = 2, int maxChildren = 3)
|
public FileSystemTreeNodeResponse Create(int currentDepth = 0, int maxDepth = 2, int maxChildren = 3, bool? isHidden = null)
|
||||||
{
|
{
|
||||||
FileSystemTreeNodeResponse response = new()
|
FileSystemTreeNodeResponse response = new()
|
||||||
{
|
{
|
||||||
Path = _faker.System.FilePath(),
|
Path = _faker.System.FilePath(),
|
||||||
Name = _faker.System.FileName(),
|
Name = _faker.System.FileName(),
|
||||||
ItemType = FileSystemItemType.Directory,
|
ItemType = FileSystemItemType.Directory,
|
||||||
|
IsHidden = isHidden ?? _faker.Random.Bool(),
|
||||||
IsExpanded = _faker.Random.Bool(),
|
IsExpanded = _faker.Random.Bool(),
|
||||||
ChildrenLoaded = true,
|
ChildrenLoaded = true,
|
||||||
Children = []
|
Children = []
|
||||||
|
|||||||
+4
-2
@@ -22,15 +22,17 @@ public class DirectoryResponseFixture
|
|||||||
/// Creates a random valid <see cref="DirectoryResponse"/>.
|
/// Creates a random valid <see cref="DirectoryResponse"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="itemCount">Optional. The number of children elements to create.</param>
|
/// <param name="itemCount">Optional. The number of children elements to create.</param>
|
||||||
|
/// <param name="isHidden">Optional. Whether the directory is hidden. If not provided, a random value is generated.</param>
|
||||||
/// <returns>The created <see cref="DirectoryResponse"/>.</returns>
|
/// <returns>The created <see cref="DirectoryResponse"/>.</returns>
|
||||||
public DirectoryResponse Create(int itemCount = 3)
|
public DirectoryResponse Create(int itemCount = 3, bool? isHidden = null)
|
||||||
{
|
{
|
||||||
return new DirectoryResponse(
|
return new DirectoryResponse(
|
||||||
_faker.System.FilePath(),
|
_faker.System.FilePath(),
|
||||||
_faker.System.FileName(),
|
_faker.System.FileName(),
|
||||||
_faker.Date.Past(),
|
_faker.Date.Past(),
|
||||||
_faker.Date.Recent(),
|
_faker.Date.Recent(),
|
||||||
_fileSystemItemDtoFixture.CreateMany(itemCount)
|
_fileSystemItemDtoFixture.CreateMany(itemCount),
|
||||||
|
isHidden ?? _faker.Random.Bool()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -19,15 +19,17 @@ public class FileResponseFixture
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a random valid <see cref="FileResponse"/>.
|
/// Creates a random valid <see cref="FileResponse"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="isHidden">Optional. Whether the file is hidden. If not provided, a random value is generated.</param>
|
||||||
/// <returns>The created <see cref="FileResponse"/>.</returns>
|
/// <returns>The created <see cref="FileResponse"/>.</returns>
|
||||||
public FileResponse Create()
|
public FileResponse Create(bool? isHidden = null)
|
||||||
{
|
{
|
||||||
return new FileResponse(
|
return new FileResponse(
|
||||||
_faker.System.FilePath(),
|
_faker.System.FilePath(),
|
||||||
_faker.System.FileName(),
|
_faker.System.FileName(),
|
||||||
_faker.Date.Past(),
|
_faker.Date.Past(),
|
||||||
_faker.Date.Recent(),
|
_faker.Date.Recent(),
|
||||||
_faker.Random.Long()
|
_faker.Random.Long(),
|
||||||
|
isHidden ?? _faker.Random.Bool()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -28,6 +28,7 @@ public class DirectoryFixture
|
|||||||
/// <param name="dateCreated">Optional. The directory's creation date. If not provided, a random past date is generated.</param>
|
/// <param name="dateCreated">Optional. The directory's creation date. If not provided, a random past date is generated.</param>
|
||||||
/// <param name="dateModified">Optional. The directory's modification date. If not provided, a recent date is generated.</param>
|
/// <param name="dateModified">Optional. The directory's modification date. If not provided, a recent date is generated.</param>
|
||||||
/// <param name="status">Optional. The directory's status. If not provided, a random status is assigned.</param>
|
/// <param name="status">Optional. The directory's status. If not provided, a random status is assigned.</param>
|
||||||
|
/// <param name="isHidden">Optional. Whether the directory is hidden. If not provided, a random value is generated.</param>
|
||||||
/// <param name="childItems">Optional. A list of child items to be added to the directory.</param>
|
/// <param name="childItems">Optional. A list of child items to be added to the directory.</param>
|
||||||
/// <returns>A newly created <see cref="Directory"/> instance.</returns>
|
/// <returns>A newly created <see cref="Directory"/> instance.</returns>
|
||||||
/// <exception cref="InvalidOperationException">Thrown if the <see cref="Directory"/> creation fails.</exception>
|
/// <exception cref="InvalidOperationException">Thrown if the <see cref="Directory"/> creation fails.</exception>
|
||||||
@@ -37,6 +38,7 @@ public class DirectoryFixture
|
|||||||
Optional<DateTime>? dateCreated = null,
|
Optional<DateTime>? dateCreated = null,
|
||||||
Optional<DateTime>? dateModified = null,
|
Optional<DateTime>? dateModified = null,
|
||||||
FileSystemItemStatus? status = null,
|
FileSystemItemStatus? status = null,
|
||||||
|
bool? isHidden = null,
|
||||||
List<FileSystemItem>? childItems = null)
|
List<FileSystemItem>? childItems = null)
|
||||||
{
|
{
|
||||||
path ??= _faker.System.FilePath();
|
path ??= _faker.System.FilePath();
|
||||||
@@ -44,8 +46,9 @@ public class DirectoryFixture
|
|||||||
dateCreated ??= Optional<DateTime>.Some(_faker.Date.Past());
|
dateCreated ??= Optional<DateTime>.Some(_faker.Date.Past());
|
||||||
dateModified ??= Optional<DateTime>.Some(_faker.Date.Recent());
|
dateModified ??= Optional<DateTime>.Some(_faker.Date.Recent());
|
||||||
status ??= _faker.PickRandom<FileSystemItemStatus>();
|
status ??= _faker.PickRandom<FileSystemItemStatus>();
|
||||||
|
isHidden ??= _faker.Random.Bool();
|
||||||
|
|
||||||
Result<Directory> directoryResult = Directory.Create(path, name, dateCreated.Value, dateModified.Value, status.Value);
|
Result<Directory> directoryResult = Directory.Create(path, name, dateCreated.Value, dateModified.Value, status.Value, isHidden.Value);
|
||||||
|
|
||||||
if (directoryResult.IsFailure)
|
if (directoryResult.IsFailure)
|
||||||
throw new InvalidOperationException("Failed to create Directory: " + string.Join(", ", directoryResult.Errors));
|
throw new InvalidOperationException("Failed to create Directory: " + string.Join(", ", directoryResult.Errors));
|
||||||
|
|||||||
+4
-1
@@ -28,6 +28,7 @@ public class FileFixture
|
|||||||
/// <param name="dateModified">Optional. The file's modification date. If not provided, a recent date is generated.</param>
|
/// <param name="dateModified">Optional. The file's modification date. If not provided, a recent date is generated.</param>
|
||||||
/// <param name="size">Optional. The file size. If not provided, a random size is generated.</param>
|
/// <param name="size">Optional. The file size. If not provided, a random size is generated.</param>
|
||||||
/// <param name="status">Optional. The file's status. If not provided, a random status is assigned.</param>
|
/// <param name="status">Optional. The file's status. If not provided, a random status is assigned.</param>
|
||||||
|
/// <param name="isHidden">Optional. Whether the file is hidden. If not provided, a random value is generated.</param>
|
||||||
/// <param name="includeDates">Whether the creation and modification dates should be included, or left unset.</param>
|
/// <param name="includeDates">Whether the creation and modification dates should be included, or left unset.</param>
|
||||||
/// <returns>The created <see cref="File"/>.</returns>
|
/// <returns>The created <see cref="File"/>.</returns>
|
||||||
public File Create(
|
public File Create(
|
||||||
@@ -37,6 +38,7 @@ public class FileFixture
|
|||||||
Optional<DateTime>? dateModified = null,
|
Optional<DateTime>? dateModified = null,
|
||||||
long? size = null,
|
long? size = null,
|
||||||
FileSystemItemStatus? status = null,
|
FileSystemItemStatus? status = null,
|
||||||
|
bool? isHidden = null,
|
||||||
bool includeDates = true)
|
bool includeDates = true)
|
||||||
{
|
{
|
||||||
path ??= _faker.System.FilePath();
|
path ??= _faker.System.FilePath();
|
||||||
@@ -45,8 +47,9 @@ public class FileFixture
|
|||||||
dateModified ??= includeDates ? Optional<DateTime>.Some(_faker.Date.Recent()) : Optional<DateTime>.None();
|
dateModified ??= includeDates ? Optional<DateTime>.Some(_faker.Date.Recent()) : Optional<DateTime>.None();
|
||||||
size ??= _faker.Random.Long();
|
size ??= _faker.Random.Long();
|
||||||
status ??= _faker.PickRandom<FileSystemItemStatus>();
|
status ??= _faker.PickRandom<FileSystemItemStatus>();
|
||||||
|
isHidden ??= _faker.Random.Bool();
|
||||||
|
|
||||||
Result<File> fileResult = File.Create(path, name, dateCreated.Value, dateModified.Value, size.Value, status.Value);
|
Result<File> fileResult = File.Create(path, name, dateCreated.Value, dateModified.Value, size.Value, status.Value, isHidden.Value);
|
||||||
|
|
||||||
if (fileResult.IsFailure)
|
if (fileResult.IsFailure)
|
||||||
throw new InvalidOperationException("Failed to create File: " + string.Join(", ", fileResult.Errors));
|
throw new InvalidOperationException("Failed to create File: " + string.Join(", ", fileResult.Errors));
|
||||||
|
|||||||
+3
@@ -22,12 +22,14 @@ public class DirectoryDtoFixture
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path">Optional. The full path to the directory.</param>
|
/// <param name="path">Optional. The full path to the directory.</param>
|
||||||
/// <param name="name">Optional. The name of the directory.</param>
|
/// <param name="name">Optional. The name of the directory.</param>
|
||||||
|
/// <param name="isHidden">Optional. Whether the directory is hidden. If not provided, a random value is generated.</param>
|
||||||
/// <param name="items">Optional. The children items of the directory.</param>
|
/// <param name="items">Optional. The children items of the directory.</param>
|
||||||
/// <param name="includeItems">Whether the children items should be included, or forced to an empty collection.</param>
|
/// <param name="includeItems">Whether the children items should be included, or forced to an empty collection.</param>
|
||||||
/// <returns>The created <see cref="DirectoryDto"/>.</returns>
|
/// <returns>The created <see cref="DirectoryDto"/>.</returns>
|
||||||
public DirectoryDto Create(
|
public DirectoryDto Create(
|
||||||
string? path = null,
|
string? path = null,
|
||||||
string? name = null,
|
string? name = null,
|
||||||
|
bool? isHidden = null,
|
||||||
List<FileSystemItemDto>? items = null,
|
List<FileSystemItemDto>? items = null,
|
||||||
bool includeItems = false)
|
bool includeItems = false)
|
||||||
{
|
{
|
||||||
@@ -38,6 +40,7 @@ public class DirectoryDtoFixture
|
|||||||
Name = name ?? Path.GetFileName(generatedPath),
|
Name = name ?? Path.GetFileName(generatedPath),
|
||||||
DateCreated = _faker.Date.Past(),
|
DateCreated = _faker.Date.Past(),
|
||||||
DateModified = _faker.Date.Recent(),
|
DateModified = _faker.Date.Recent(),
|
||||||
|
IsHidden = isHidden ?? _faker.Random.Bool(),
|
||||||
Items = includeItems ? (items ?? []) : []
|
Items = includeItems ? (items ?? []) : []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -23,11 +23,13 @@ public class FileDtoFixture
|
|||||||
/// <param name="path">Optional. The full path to the file.</param>
|
/// <param name="path">Optional. The full path to the file.</param>
|
||||||
/// <param name="name">Optional. The name of the file.</param>
|
/// <param name="name">Optional. The name of the file.</param>
|
||||||
/// <param name="size">Optional. The size of the file, in bytes.</param>
|
/// <param name="size">Optional. The size of the file, in bytes.</param>
|
||||||
|
/// <param name="isHidden">Optional. Whether the file is hidden. If not provided, a random value is generated.</param>
|
||||||
/// <returns>A configured <see cref="FileDto"/> instance.</returns>
|
/// <returns>A configured <see cref="FileDto"/> instance.</returns>
|
||||||
public FileDto Create(
|
public FileDto Create(
|
||||||
string? path = null,
|
string? path = null,
|
||||||
string? name = null,
|
string? name = null,
|
||||||
long? size = null)
|
long? size = null,
|
||||||
|
bool? isHidden = null)
|
||||||
{
|
{
|
||||||
string generatedPath = _faker.System.FilePath();
|
string generatedPath = _faker.System.FilePath();
|
||||||
return new FileDto
|
return new FileDto
|
||||||
@@ -36,6 +38,7 @@ public class FileDtoFixture
|
|||||||
Name = name ?? Path.GetFileName(generatedPath),
|
Name = name ?? Path.GetFileName(generatedPath),
|
||||||
DateCreated = _faker.Date.Past(),
|
DateCreated = _faker.Date.Past(),
|
||||||
DateModified = _faker.Date.Recent(),
|
DateModified = _faker.Date.Recent(),
|
||||||
|
IsHidden = isHidden ?? _faker.Random.Bool(),
|
||||||
Size = size ?? _faker.Random.Long(0, 10_000_000)
|
Size = size ?? _faker.Random.Long(0, 10_000_000)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -24,11 +24,13 @@ public class FileSystemTreeNodeDtoFixture
|
|||||||
/// <param name="path">Optional. The full path of the file or directory.</param>
|
/// <param name="path">Optional. The full path of the file or directory.</param>
|
||||||
/// <param name="name">Optional. The name of the file or directory.</param>
|
/// <param name="name">Optional. The name of the file or directory.</param>
|
||||||
/// <param name="itemType">Optional. The type of the item, indicating whether it is a file, directory, or drive.</param>
|
/// <param name="itemType">Optional. The type of the item, indicating whether it is a file, directory, or drive.</param>
|
||||||
|
/// <param name="isHidden">Optional. Whether the node is hidden. If not provided, a random value is generated.</param>
|
||||||
/// <returns>A configured <see cref="FileSystemTreeNodeDto"/> instance.</returns>
|
/// <returns>A configured <see cref="FileSystemTreeNodeDto"/> instance.</returns>
|
||||||
public FileSystemTreeNodeDto Create(
|
public FileSystemTreeNodeDto Create(
|
||||||
string? path = null,
|
string? path = null,
|
||||||
string? name = null,
|
string? name = null,
|
||||||
FileSystemItemType? itemType = null)
|
FileSystemItemType? itemType = null,
|
||||||
|
bool? isHidden = null)
|
||||||
{
|
{
|
||||||
string generatedPath = _faker.System.FilePath();
|
string generatedPath = _faker.System.FilePath();
|
||||||
return new FileSystemTreeNodeDto
|
return new FileSystemTreeNodeDto
|
||||||
@@ -36,6 +38,7 @@ public class FileSystemTreeNodeDtoFixture
|
|||||||
Path = path ?? generatedPath,
|
Path = path ?? generatedPath,
|
||||||
Name = name ?? Path.GetFileName(generatedPath),
|
Name = name ?? Path.GetFileName(generatedPath),
|
||||||
ItemType = itemType ?? _faker.PickRandom<FileSystemItemType>(),
|
ItemType = itemType ?? _faker.PickRandom<FileSystemItemType>(),
|
||||||
|
IsHidden = isHidden ?? _faker.Random.Bool(),
|
||||||
IsExpanded = _faker.Random.Bool(),
|
IsExpanded = _faker.Random.Bool(),
|
||||||
ChildrenLoaded = _faker.Random.Bool(),
|
ChildrenLoaded = _faker.Random.Bool(),
|
||||||
Children = []
|
Children = []
|
||||||
|
|||||||
+5
-4
@@ -58,7 +58,7 @@ public class GetDirectoriesEndpointTests : IClassFixture<AuthenticatedLuminaApiF
|
|||||||
// Arrange
|
// Arrange
|
||||||
string testPath = _fileSystemStructureFixture.CreateFileSystemStructure();
|
string testPath = _fileSystemStructureFixture.CreateFileSystemStructure();
|
||||||
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath;
|
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath;
|
||||||
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath; // two levels to get to the element that has a hidden element as child
|
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath; // Two levels to get to the element that has a hidden element as child.
|
||||||
string encodedPath = Uri.EscapeDataString(testPath);
|
string encodedPath = Uri.EscapeDataString(testPath);
|
||||||
bool shouldIncludeHiddenElements = false;
|
bool shouldIncludeHiddenElements = false;
|
||||||
try
|
try
|
||||||
@@ -82,13 +82,13 @@ public class GetDirectoriesEndpointTests : IClassFixture<AuthenticatedLuminaApiF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[SkipWhenHiddenAttributeNotSupportedFact]
|
||||||
public async Task GetDirectories_WhenCalledWithValidPathAndWithShouldIncludeHiddenElements_ShouldReturnDirectoriesWithHiddenElements()
|
public async Task GetDirectories_WhenCalledWithValidPathAndWithShouldIncludeHiddenElements_ShouldReturnDirectoriesWithHiddenElements()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
string testPath = _fileSystemStructureFixture.CreateFileSystemStructure();
|
string testPath = _fileSystemStructureFixture.CreateFileSystemStructure();
|
||||||
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath;
|
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath;
|
||||||
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath; // two levels to get to the element that has a hidden element as child
|
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath; // Two levels to get to the element that has a hidden element as child.
|
||||||
string encodedPath = Uri.EscapeDataString(testPath);
|
string encodedPath = Uri.EscapeDataString(testPath);
|
||||||
bool shouldIncludeHiddenElements = true;
|
bool shouldIncludeHiddenElements = true;
|
||||||
try
|
try
|
||||||
@@ -112,7 +112,8 @@ public class GetDirectoriesEndpointTests : IClassFixture<AuthenticatedLuminaApiF
|
|||||||
DirectoryResponse firstDirectory = directories!.First();
|
DirectoryResponse firstDirectory = directories!.First();
|
||||||
Assert.Equal((s_isUnix ? "." : string.Empty) + "NestedDirectory_2", directories!.First().Name);
|
Assert.Equal((s_isUnix ? "." : string.Empty) + "NestedDirectory_2", directories!.First().Name);
|
||||||
Assert.Equal(System.IO.Path.Combine(testPath, (s_isUnix ? "." : string.Empty) + "NestedDirectory_2" + System.IO.Path.DirectorySeparatorChar), directories.First().Path);
|
Assert.Equal(System.IO.Path.Combine(testPath, (s_isUnix ? "." : string.Empty) + "NestedDirectory_2" + System.IO.Path.DirectorySeparatorChar), directories.First().Path);
|
||||||
Assert.Single(directories); // only directories
|
Assert.True(firstDirectory.IsHidden);
|
||||||
|
Assert.Single(directories); // Only directories.
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|||||||
+8
-4
@@ -80,7 +80,8 @@ public class GetFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory
|
|||||||
FileResponse firstDirectory = files!.First();
|
FileResponse firstDirectory = files!.First();
|
||||||
Assert.Equal("TestFile_2.txt", firstDirectory.Name);
|
Assert.Equal("TestFile_2.txt", firstDirectory.Name);
|
||||||
Assert.Equal(System.IO.Path.Combine(testPath, "TestFile_2.txt"), firstDirectory.Path);
|
Assert.Equal(System.IO.Path.Combine(testPath, "TestFile_2.txt"), firstDirectory.Path);
|
||||||
Assert.Single(files); // only files
|
Assert.False(firstDirectory.IsHidden);
|
||||||
|
Assert.Single(files); // Only files.
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -94,7 +95,7 @@ public class GetFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory
|
|||||||
// Arrange
|
// Arrange
|
||||||
string testPath = _fileSystemStructureFixture.CreateFileSystemStructure();
|
string testPath = _fileSystemStructureFixture.CreateFileSystemStructure();
|
||||||
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath;
|
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath;
|
||||||
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath; // two levels to get to the element that has a hidden element as child
|
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath; // Two levels to get to the element that has a hidden element as child.
|
||||||
bool shouldIncludeHiddenElements = false;
|
bool shouldIncludeHiddenElements = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -112,6 +113,7 @@ public class GetFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory
|
|||||||
FileResponse firstDirectory = files!.First();
|
FileResponse firstDirectory = files!.First();
|
||||||
Assert.Equal("TestFile_2.txt", firstDirectory.Name);
|
Assert.Equal("TestFile_2.txt", firstDirectory.Name);
|
||||||
Assert.Equal(System.IO.Path.Combine(testPath, "TestFile_2.txt"), firstDirectory.Path);
|
Assert.Equal(System.IO.Path.Combine(testPath, "TestFile_2.txt"), firstDirectory.Path);
|
||||||
|
Assert.False(firstDirectory.IsHidden);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -119,13 +121,13 @@ public class GetFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[SkipWhenHiddenAttributeNotSupportedFact]
|
||||||
public async Task GetFiles_WhenCalledWithValidPathAndWithShouldIncludeHiddenElements_ShouldReturnFilesWithHiddenElements()
|
public async Task GetFiles_WhenCalledWithValidPathAndWithShouldIncludeHiddenElements_ShouldReturnFilesWithHiddenElements()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
string testPath = _fileSystemStructureFixture.CreateFileSystemStructure();
|
string testPath = _fileSystemStructureFixture.CreateFileSystemStructure();
|
||||||
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath;
|
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath;
|
||||||
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath; // two levels to get to the element that has a hidden element as child
|
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath; // Two levels to get to the element that has a hidden element as child.
|
||||||
bool shouldIncludeHiddenElements = true;
|
bool shouldIncludeHiddenElements = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -147,10 +149,12 @@ public class GetFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory
|
|||||||
FileResponse firstDirectory = files!.First();
|
FileResponse firstDirectory = files!.First();
|
||||||
Assert.Equal((s_isUnix ? "." : string.Empty) + "TestFile_1.txt", firstDirectory.Name);
|
Assert.Equal((s_isUnix ? "." : string.Empty) + "TestFile_1.txt", firstDirectory.Name);
|
||||||
Assert.Equal(System.IO.Path.Combine(testPath, (s_isUnix ? "." : string.Empty) + "TestFile_1.txt"), firstDirectory.Path);
|
Assert.Equal(System.IO.Path.Combine(testPath, (s_isUnix ? "." : string.Empty) + "TestFile_1.txt"), firstDirectory.Path);
|
||||||
|
Assert.True(firstDirectory.IsHidden);
|
||||||
|
|
||||||
FileResponse secondDirectory = files!.Last();
|
FileResponse secondDirectory = files!.Last();
|
||||||
Assert.Equal("TestFile_2.txt", secondDirectory.Name);
|
Assert.Equal("TestFile_2.txt", secondDirectory.Name);
|
||||||
Assert.Equal(System.IO.Path.Combine(testPath, "TestFile_2.txt"), secondDirectory.Path);
|
Assert.Equal(System.IO.Path.Combine(testPath, "TestFile_2.txt"), secondDirectory.Path);
|
||||||
|
Assert.False(secondDirectory.IsHidden);
|
||||||
Assert.Equal(2, files.Count);
|
Assert.Equal(2, files.Count);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|||||||
+6
-4
@@ -80,7 +80,7 @@ public class GetTreeFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFac
|
|||||||
FileSystemTreeNodeResponse firstDirectory = files!.First();
|
FileSystemTreeNodeResponse firstDirectory = files!.First();
|
||||||
Assert.Equal("TestFile_2.txt", firstDirectory.Name);
|
Assert.Equal("TestFile_2.txt", firstDirectory.Name);
|
||||||
Assert.Equal(System.IO.Path.Combine(testPath, "TestFile_2.txt"), firstDirectory.Path);
|
Assert.Equal(System.IO.Path.Combine(testPath, "TestFile_2.txt"), firstDirectory.Path);
|
||||||
Assert.Single(files); // only files
|
Assert.Single(files); // Only files.
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -94,7 +94,7 @@ public class GetTreeFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFac
|
|||||||
// Arrange
|
// Arrange
|
||||||
string testPath = _fileSystemStructureFixture.CreateFileSystemStructure();
|
string testPath = _fileSystemStructureFixture.CreateFileSystemStructure();
|
||||||
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath;
|
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath;
|
||||||
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath; // two levels to get to the element that has a hidden element as child
|
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath; // Two levels to get to the element that has a hidden element as child.
|
||||||
bool shouldIncludeHiddenElements = false;
|
bool shouldIncludeHiddenElements = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -120,13 +120,13 @@ public class GetTreeFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[SkipWhenHiddenAttributeNotSupportedFact]
|
||||||
public async Task GetTreeFiles_WhenCalledWithValidPathAndWithShouldIncludeHiddenElements_ShouldReturnTreeFilesWithHiddenElements()
|
public async Task GetTreeFiles_WhenCalledWithValidPathAndWithShouldIncludeHiddenElements_ShouldReturnTreeFilesWithHiddenElements()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
string testPath = _fileSystemStructureFixture.CreateFileSystemStructure();
|
string testPath = _fileSystemStructureFixture.CreateFileSystemStructure();
|
||||||
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath;
|
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath;
|
||||||
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath; // two levels to get to the element that has a hidden element as child
|
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath; // Two levels to get to the element that has a hidden element as child.
|
||||||
bool shouldIncludeHiddenElements = true;
|
bool shouldIncludeHiddenElements = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -148,10 +148,12 @@ public class GetTreeFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFac
|
|||||||
FileSystemTreeNodeResponse firstDirectory = files!.First();
|
FileSystemTreeNodeResponse firstDirectory = files!.First();
|
||||||
Assert.Equal((s_isUnix ? "." : string.Empty) + "TestFile_1.txt", firstDirectory.Name);
|
Assert.Equal((s_isUnix ? "." : string.Empty) + "TestFile_1.txt", firstDirectory.Name);
|
||||||
Assert.Equal(System.IO.Path.Combine(testPath, (s_isUnix ? "." : string.Empty) + "TestFile_1.txt"), firstDirectory.Path);
|
Assert.Equal(System.IO.Path.Combine(testPath, (s_isUnix ? "." : string.Empty) + "TestFile_1.txt"), firstDirectory.Path);
|
||||||
|
Assert.True(firstDirectory.IsHidden);
|
||||||
|
|
||||||
FileSystemTreeNodeResponse secondDirectory = files!.Last();
|
FileSystemTreeNodeResponse secondDirectory = files!.Last();
|
||||||
Assert.Equal("TestFile_2.txt", secondDirectory.Name);
|
Assert.Equal("TestFile_2.txt", secondDirectory.Name);
|
||||||
Assert.Equal(System.IO.Path.Combine(testPath, "TestFile_2.txt"), secondDirectory.Path);
|
Assert.Equal(System.IO.Path.Combine(testPath, "TestFile_2.txt"), secondDirectory.Path);
|
||||||
|
Assert.False(secondDirectory.IsHidden);
|
||||||
Assert.Equal(2, files.Count);
|
Assert.Equal(2, files.Count);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|||||||
+2
-1
@@ -39,7 +39,7 @@ public class GetDirectoriesEndpointTests : IClassFixture<LuminaWebFactory>
|
|||||||
// Arrange
|
// Arrange
|
||||||
_apiFactory.ApiClientStub.Reset();
|
_apiFactory.ApiClientStub.Reset();
|
||||||
string path = @"C:\Users\test";
|
string path = @"C:\Users\test";
|
||||||
DirectoryDto[] expectedDirectories = [_directoryDtoFixture.Create(path: path, name: "test")];
|
DirectoryDto[] expectedDirectories = [_directoryDtoFixture.Create(path: path, name: "test", isHidden: true)];
|
||||||
string expectedEndpoint = $"directories/get-directories?path={Uri.EscapeDataString(path)}&shouldIncludeHiddenElements=True";
|
string expectedEndpoint = $"directories/get-directories?path={Uri.EscapeDataString(path)}&shouldIncludeHiddenElements=True";
|
||||||
_apiFactory.ApiClientStub.RegisterGetResponse(expectedEndpoint, expectedDirectories);
|
_apiFactory.ApiClientStub.RegisterGetResponse(expectedEndpoint, expectedDirectories);
|
||||||
AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
|
AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
|
||||||
@@ -56,6 +56,7 @@ public class GetDirectoriesEndpointTests : IClassFixture<LuminaWebFactory>
|
|||||||
using JsonDocument json = JsonDocument.Parse(content);
|
using JsonDocument json = JsonDocument.Parse(content);
|
||||||
Assert.True(json.RootElement.GetProperty("success").GetBoolean());
|
Assert.True(json.RootElement.GetProperty("success").GetBoolean());
|
||||||
Assert.Equal(expectedDirectories.Length, json.RootElement.GetProperty("data").GetArrayLength());
|
Assert.Equal(expectedDirectories.Length, json.RootElement.GetProperty("data").GetArrayLength());
|
||||||
|
Assert.True(json.RootElement.GetProperty("data")[0].GetProperty("isHidden").GetBoolean());
|
||||||
Assert.Contains(expectedEndpoint, _apiFactory.ApiClientStub.GetEndpointsCalled);
|
Assert.Contains(expectedEndpoint, _apiFactory.ApiClientStub.GetEndpointsCalled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-1
@@ -39,7 +39,7 @@ public class GetFilesEndpointTests : IClassFixture<LuminaWebFactory>
|
|||||||
// Arrange
|
// Arrange
|
||||||
_apiFactory.ApiClientStub.Reset();
|
_apiFactory.ApiClientStub.Reset();
|
||||||
string path = @"C:\Users\test";
|
string path = @"C:\Users\test";
|
||||||
FileDto[] expectedFiles = [_fileDtoFixture.Create(path: path, name: "book.pdf")];
|
FileDto[] expectedFiles = [_fileDtoFixture.Create(path: path, name: "book.pdf", isHidden: true)];
|
||||||
string expectedEndpoint = $"files/get-files?path={Uri.EscapeDataString(path)}&shouldIncludeHiddenElements=True";
|
string expectedEndpoint = $"files/get-files?path={Uri.EscapeDataString(path)}&shouldIncludeHiddenElements=True";
|
||||||
_apiFactory.ApiClientStub.RegisterGetResponse(expectedEndpoint, expectedFiles);
|
_apiFactory.ApiClientStub.RegisterGetResponse(expectedEndpoint, expectedFiles);
|
||||||
AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
|
AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
|
||||||
@@ -56,6 +56,7 @@ public class GetFilesEndpointTests : IClassFixture<LuminaWebFactory>
|
|||||||
using JsonDocument json = JsonDocument.Parse(content);
|
using JsonDocument json = JsonDocument.Parse(content);
|
||||||
Assert.True(json.RootElement.GetProperty("success").GetBoolean());
|
Assert.True(json.RootElement.GetProperty("success").GetBoolean());
|
||||||
Assert.Equal(expectedFiles.Length, json.RootElement.GetProperty("data").GetArrayLength());
|
Assert.Equal(expectedFiles.Length, json.RootElement.GetProperty("data").GetArrayLength());
|
||||||
|
Assert.True(json.RootElement.GetProperty("data")[0].GetProperty("isHidden").GetBoolean());
|
||||||
Assert.Contains(expectedEndpoint, _apiFactory.ApiClientStub.GetEndpointsCalled);
|
Assert.Contains(expectedEndpoint, _apiFactory.ApiClientStub.GetEndpointsCalled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-1
@@ -39,7 +39,7 @@ public class GetTreeFilesEndpointTests : IClassFixture<LuminaWebFactory>
|
|||||||
// Arrange
|
// Arrange
|
||||||
_apiFactory.ApiClientStub.Reset();
|
_apiFactory.ApiClientStub.Reset();
|
||||||
string path = @"C:\Users\test";
|
string path = @"C:\Users\test";
|
||||||
FileSystemTreeNodeDto[] expectedNodes = [_fileSystemTreeNodeDtoFixture.Create(path: path, name: "test")];
|
FileSystemTreeNodeDto[] expectedNodes = [_fileSystemTreeNodeDtoFixture.Create(path: path, name: "test", isHidden: true)];
|
||||||
string expectedEndpoint = $"files/get-tree-files?path={Uri.EscapeDataString(path)}&shouldIncludeHiddenElements=True";
|
string expectedEndpoint = $"files/get-tree-files?path={Uri.EscapeDataString(path)}&shouldIncludeHiddenElements=True";
|
||||||
_apiFactory.ApiClientStub.RegisterGetResponse(expectedEndpoint, expectedNodes);
|
_apiFactory.ApiClientStub.RegisterGetResponse(expectedEndpoint, expectedNodes);
|
||||||
AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
|
AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
|
||||||
@@ -56,6 +56,7 @@ public class GetTreeFilesEndpointTests : IClassFixture<LuminaWebFactory>
|
|||||||
using JsonDocument json = JsonDocument.Parse(content);
|
using JsonDocument json = JsonDocument.Parse(content);
|
||||||
Assert.True(json.RootElement.GetProperty("success").GetBoolean());
|
Assert.True(json.RootElement.GetProperty("success").GetBoolean());
|
||||||
Assert.Equal(expectedNodes.Length, json.RootElement.GetProperty("data").GetArrayLength());
|
Assert.Equal(expectedNodes.Length, json.RootElement.GetProperty("data").GetArrayLength());
|
||||||
|
Assert.True(json.RootElement.GetProperty("data")[0].GetProperty("isHidden").GetBoolean());
|
||||||
Assert.Contains(expectedEndpoint, _apiFactory.ApiClientStub.GetEndpointsCalled);
|
Assert.Contains(expectedEndpoint, _apiFactory.ApiClientStub.GetEndpointsCalled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+30
-12
@@ -20,15 +20,17 @@ public class DirectoryMappingTests
|
|||||||
{
|
{
|
||||||
private readonly DirectoryFixture _directoryFixture = new();
|
private readonly DirectoryFixture _directoryFixture = new();
|
||||||
|
|
||||||
[Fact]
|
[Theory]
|
||||||
public void ToFileSystemTreeNodeResponse_WhenMappingDirectory_ShouldMapCorrectly()
|
[InlineData(true)] // hidden directory
|
||||||
|
[InlineData(false)] // visible directory
|
||||||
|
public void ToFileSystemTreeNodeResponse_WhenMappingDirectory_ShouldMapCorrectly(bool isHidden)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Directory directory = _directoryFixture.Create();
|
Directory directory = _directoryFixture.Create(isHidden: isHidden);
|
||||||
List<FileSystemItem> childItems =
|
List<FileSystemItem> childItems =
|
||||||
[
|
[
|
||||||
_directoryFixture.Create(),
|
_directoryFixture.Create(isHidden: true),
|
||||||
_directoryFixture.Create()
|
_directoryFixture.Create(isHidden: false)
|
||||||
];
|
];
|
||||||
foreach (FileSystemItem item in childItems)
|
foreach (FileSystemItem item in childItems)
|
||||||
directory.AddItem(item);
|
directory.AddItem(item);
|
||||||
@@ -41,6 +43,7 @@ public class DirectoryMappingTests
|
|||||||
Assert.Equal(directory.Name, result.Name);
|
Assert.Equal(directory.Name, result.Name);
|
||||||
Assert.Equal(directory.Id.Path, result.Path);
|
Assert.Equal(directory.Id.Path, result.Path);
|
||||||
Assert.Equal(directory.Type, result.ItemType);
|
Assert.Equal(directory.Type, result.ItemType);
|
||||||
|
Assert.Equal(directory.IsHidden, result.IsHidden);
|
||||||
Assert.False(result.IsExpanded);
|
Assert.False(result.IsExpanded);
|
||||||
Assert.False(result.ChildrenLoaded);
|
Assert.False(result.ChildrenLoaded);
|
||||||
Assert.NotNull(result.Children);
|
Assert.NotNull(result.Children);
|
||||||
@@ -51,6 +54,7 @@ public class DirectoryMappingTests
|
|||||||
Assert.Equal(childItems[i].Name, result.Children[i].Name);
|
Assert.Equal(childItems[i].Name, result.Children[i].Name);
|
||||||
Assert.Equal(childItems[i].Id.Path, result.Children[i].Path);
|
Assert.Equal(childItems[i].Id.Path, result.Children[i].Path);
|
||||||
Assert.Equal(childItems[i].Type, result.Children[i].ItemType);
|
Assert.Equal(childItems[i].Type, result.Children[i].ItemType);
|
||||||
|
Assert.Equal(childItems[i].IsHidden, result.Children[i].IsHidden);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +62,11 @@ public class DirectoryMappingTests
|
|||||||
public void ToFileSystemTreeNodeResponses_WhenMappingMultipleDirectories_ShouldMapCorrectly()
|
public void ToFileSystemTreeNodeResponses_WhenMappingMultipleDirectories_ShouldMapCorrectly()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
List<Directory> directories = _directoryFixture.CreateMany(2);
|
List<Directory> directories =
|
||||||
|
[
|
||||||
|
_directoryFixture.Create(isHidden: true),
|
||||||
|
_directoryFixture.Create(isHidden: false)
|
||||||
|
];
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
IEnumerable<FileSystemTreeNodeResponse> result = directories.ToFileSystemTreeNodeResponses();
|
IEnumerable<FileSystemTreeNodeResponse> result = directories.ToFileSystemTreeNodeResponses();
|
||||||
@@ -73,18 +81,21 @@ public class DirectoryMappingTests
|
|||||||
Assert.Equal(directories[i].Name, resultList[i].Name);
|
Assert.Equal(directories[i].Name, resultList[i].Name);
|
||||||
Assert.Equal(directories[i].Id.Path, resultList[i].Path);
|
Assert.Equal(directories[i].Id.Path, resultList[i].Path);
|
||||||
Assert.Equal(directories[i].Type, resultList[i].ItemType);
|
Assert.Equal(directories[i].Type, resultList[i].ItemType);
|
||||||
|
Assert.Equal(directories[i].IsHidden, resultList[i].IsHidden);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Theory]
|
||||||
public void ToResponse_WhenMappingDirectory_ShouldMapCorrectly()
|
[InlineData(true)] // hidden directory
|
||||||
|
[InlineData(false)] // visible directory
|
||||||
|
public void ToResponse_WhenMappingDirectory_ShouldMapCorrectly(bool isHidden)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Directory directory = _directoryFixture.Create();
|
Directory directory = _directoryFixture.Create(isHidden: isHidden);
|
||||||
List<FileSystemItem> childItems =
|
List<FileSystemItem> childItems =
|
||||||
[
|
[
|
||||||
_directoryFixture.Create(),
|
_directoryFixture.Create(isHidden: true),
|
||||||
_directoryFixture.Create()
|
_directoryFixture.Create(isHidden: false)
|
||||||
];
|
];
|
||||||
foreach (FileSystemItem item in childItems)
|
foreach (FileSystemItem item in childItems)
|
||||||
directory.AddItem(item);
|
directory.AddItem(item);
|
||||||
@@ -98,6 +109,7 @@ public class DirectoryMappingTests
|
|||||||
Assert.Equal(directory.Name, result.Name);
|
Assert.Equal(directory.Name, result.Name);
|
||||||
Assert.Equal(directory.DateCreated.Value, result.DateCreated);
|
Assert.Equal(directory.DateCreated.Value, result.DateCreated);
|
||||||
Assert.Equal(directory.DateModified.Value, result.DateModified);
|
Assert.Equal(directory.DateModified.Value, result.DateModified);
|
||||||
|
Assert.Equal(directory.IsHidden, result.IsHidden);
|
||||||
Assert.NotNull(result.Items);
|
Assert.NotNull(result.Items);
|
||||||
Assert.Equal(childItems.Count, result.Items.Count);
|
Assert.Equal(childItems.Count, result.Items.Count);
|
||||||
|
|
||||||
@@ -105,6 +117,7 @@ public class DirectoryMappingTests
|
|||||||
{
|
{
|
||||||
Assert.Equal(childItems[i].Name, result.Items[i].Name);
|
Assert.Equal(childItems[i].Name, result.Items[i].Name);
|
||||||
Assert.Equal(childItems[i].Id.Path, result.Items[i].Path);
|
Assert.Equal(childItems[i].Id.Path, result.Items[i].Path);
|
||||||
|
Assert.Equal(childItems[i].IsHidden, result.Items[i].IsHidden);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +125,11 @@ public class DirectoryMappingTests
|
|||||||
public void ToResponses_WhenMappingMultipleDirectories_ShouldMapCorrectly()
|
public void ToResponses_WhenMappingMultipleDirectories_ShouldMapCorrectly()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
List<Directory> directories = _directoryFixture.CreateMany(2);
|
List<Directory> directories =
|
||||||
|
[
|
||||||
|
_directoryFixture.Create(isHidden: true),
|
||||||
|
_directoryFixture.Create(isHidden: false)
|
||||||
|
];
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
IEnumerable<DirectoryResponse> result = directories.ToResponses();
|
IEnumerable<DirectoryResponse> result = directories.ToResponses();
|
||||||
@@ -128,6 +145,7 @@ public class DirectoryMappingTests
|
|||||||
Assert.Equal(directories[i].Name, resultList[i].Name);
|
Assert.Equal(directories[i].Name, resultList[i].Name);
|
||||||
Assert.Equal(directories[i].DateCreated.Value, resultList[i].DateCreated);
|
Assert.Equal(directories[i].DateCreated.Value, resultList[i].DateCreated);
|
||||||
Assert.Equal(directories[i].DateModified.Value, resultList[i].DateModified);
|
Assert.Equal(directories[i].DateModified.Value, resultList[i].DateModified);
|
||||||
|
Assert.Equal(directories[i].IsHidden, resultList[i].IsHidden);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+34
-16
@@ -29,17 +29,18 @@ public class FileSystemItemMappingTests
|
|||||||
private readonly WindowsRootItemFixture _windowsRootItemFixture = new();
|
private readonly WindowsRootItemFixture _windowsRootItemFixture = new();
|
||||||
private readonly UnixRootItemFixture _unixRootItemFixture = new();
|
private readonly UnixRootItemFixture _unixRootItemFixture = new();
|
||||||
|
|
||||||
[Fact]
|
[Theory]
|
||||||
public void ToFileSystemItemModel_WhenMappingFileSystemItem_ShouldMapCorrectly()
|
[InlineData(true)] // hidden file system item
|
||||||
|
[InlineData(false)] // visible file system item
|
||||||
|
public void ToFileSystemItemModel_WhenMappingFileSystemItem_ShouldMapCorrectly(bool isHidden)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
FileSystemPathId id = _fileSystemPathIdFixture.Create();
|
FileSystemPathId id = _fileSystemPathIdFixture.Create();
|
||||||
string name = "TestItem";
|
string name = "TestItem";
|
||||||
FileSystemItemType type = FileSystemItemType.File;
|
FileSystemItemType type = FileSystemItemType.File;
|
||||||
FileSystemItemFixture domainModel = new(id, name, type);
|
FileSystemItemFixture domainModel = new(id, name, type);
|
||||||
|
domainModel.SetHiddenState(isHidden);
|
||||||
|
|
||||||
// Arrange
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
FileSystemItemDto result = domainModel.ToFileSystemItemDto();
|
FileSystemItemDto result = domainModel.ToFileSystemItemDto();
|
||||||
|
|
||||||
@@ -47,15 +48,18 @@ public class FileSystemItemMappingTests
|
|||||||
Assert.NotNull(result);
|
Assert.NotNull(result);
|
||||||
Assert.Equal(domainModel.Id.Path, result.Path);
|
Assert.Equal(domainModel.Id.Path, result.Path);
|
||||||
Assert.Equal(domainModel.Name, result.Name);
|
Assert.Equal(domainModel.Name, result.Name);
|
||||||
|
Assert.Equal(domainModel.IsHidden, result.IsHidden);
|
||||||
Assert.True((DateTime.Now - result.DateCreated) < TimeSpan.FromSeconds(1));
|
Assert.True((DateTime.Now - result.DateCreated) < TimeSpan.FromSeconds(1));
|
||||||
Assert.True((DateTime.Now - result.DateModified) < TimeSpan.FromSeconds(1));
|
Assert.True((DateTime.Now - result.DateModified) < TimeSpan.FromSeconds(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Theory]
|
||||||
public void ToTreeNodeResponse_WhenMappingDirectory_ShouldMapCorrectly()
|
[InlineData(true)] // hidden directory
|
||||||
|
[InlineData(false)] // visible directory
|
||||||
|
public void ToTreeNodeResponse_WhenMappingDirectory_ShouldMapCorrectly(bool isHidden)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Directory directory = _directoryFixture.Create();
|
Directory directory = _directoryFixture.Create(isHidden: isHidden);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
FileSystemTreeNodeResponse result = directory.ToTreeNodeResponse();
|
FileSystemTreeNodeResponse result = directory.ToTreeNodeResponse();
|
||||||
@@ -65,13 +69,16 @@ public class FileSystemItemMappingTests
|
|||||||
Assert.Equal(directory.Name, result.Name);
|
Assert.Equal(directory.Name, result.Name);
|
||||||
Assert.Equal(directory.Id.Path, result.Path);
|
Assert.Equal(directory.Id.Path, result.Path);
|
||||||
Assert.Equal(directory.Type, result.ItemType);
|
Assert.Equal(directory.Type, result.ItemType);
|
||||||
|
Assert.Equal(directory.IsHidden, result.IsHidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Theory]
|
||||||
public void ToTreeNodeResponse_WhenMappingFile_ShouldMapCorrectly()
|
[InlineData(true)] // hidden file
|
||||||
|
[InlineData(false)] // visible file
|
||||||
|
public void ToTreeNodeResponse_WhenMappingFile_ShouldMapCorrectly(bool isHidden)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
File file = _fileFixture.Create();
|
File file = _fileFixture.Create(isHidden: isHidden);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
FileSystemTreeNodeResponse result = file.ToTreeNodeResponse();
|
FileSystemTreeNodeResponse result = file.ToTreeNodeResponse();
|
||||||
@@ -81,6 +88,7 @@ public class FileSystemItemMappingTests
|
|||||||
Assert.Equal(file.Name, result.Name);
|
Assert.Equal(file.Name, result.Name);
|
||||||
Assert.Equal(file.Id.Path, result.Path);
|
Assert.Equal(file.Id.Path, result.Path);
|
||||||
Assert.Equal(file.Type, result.ItemType);
|
Assert.Equal(file.Type, result.ItemType);
|
||||||
|
Assert.Equal(file.IsHidden, result.IsHidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -97,6 +105,7 @@ public class FileSystemItemMappingTests
|
|||||||
Assert.Equal(windowsRootItem.Name, result.Name);
|
Assert.Equal(windowsRootItem.Name, result.Name);
|
||||||
Assert.Equal(windowsRootItem.Id.Path, result.Path);
|
Assert.Equal(windowsRootItem.Id.Path, result.Path);
|
||||||
Assert.Equal(windowsRootItem.Type, result.ItemType);
|
Assert.Equal(windowsRootItem.Type, result.ItemType);
|
||||||
|
Assert.False(result.IsHidden);
|
||||||
Assert.False(result.IsExpanded);
|
Assert.False(result.IsExpanded);
|
||||||
Assert.False(result.ChildrenLoaded);
|
Assert.False(result.ChildrenLoaded);
|
||||||
Assert.Empty(result.Children);
|
Assert.Empty(result.Children);
|
||||||
@@ -116,19 +125,21 @@ public class FileSystemItemMappingTests
|
|||||||
Assert.Equal(unixRootItem.Name, result.Name);
|
Assert.Equal(unixRootItem.Name, result.Name);
|
||||||
Assert.Equal(unixRootItem.Id.Path, result.Path);
|
Assert.Equal(unixRootItem.Id.Path, result.Path);
|
||||||
Assert.Equal(unixRootItem.Type, result.ItemType);
|
Assert.Equal(unixRootItem.Type, result.ItemType);
|
||||||
|
Assert.False(result.IsHidden);
|
||||||
Assert.False(result.IsExpanded);
|
Assert.False(result.IsExpanded);
|
||||||
Assert.False(result.ChildrenLoaded);
|
Assert.False(result.ChildrenLoaded);
|
||||||
Assert.Empty(result.Children);
|
Assert.Empty(result.Children);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("TestFile.txt", FileSystemItemType.File)]
|
[InlineData("TestFile.txt", FileSystemItemType.File, true)] // hidden file
|
||||||
[InlineData("TestFolder", FileSystemItemType.Directory)]
|
[InlineData("TestFolder", FileSystemItemType.Directory, false)] // visible directory
|
||||||
public void ToFileSystemItemModel_WhenMappingDifferentFileSystemItems_ShouldMapCorrectly(string name, FileSystemItemType type)
|
public void ToFileSystemItemModel_WhenMappingDifferentFileSystemItems_ShouldMapCorrectly(string name, FileSystemItemType type, bool isHidden)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
FileSystemPathId id = _fileSystemPathIdFixture.Create();
|
FileSystemPathId id = _fileSystemPathIdFixture.Create();
|
||||||
FileSystemItemFixture domainModel = new(id, name, type);
|
FileSystemItemFixture domainModel = new(id, name, type);
|
||||||
|
domainModel.SetHiddenState(isHidden);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
FileSystemItemDto result = domainModel.ToFileSystemItemDto();
|
FileSystemItemDto result = domainModel.ToFileSystemItemDto();
|
||||||
@@ -137,6 +148,7 @@ public class FileSystemItemMappingTests
|
|||||||
Assert.NotNull(result);
|
Assert.NotNull(result);
|
||||||
Assert.Equal(domainModel.Id.Path, result.Path);
|
Assert.Equal(domainModel.Id.Path, result.Path);
|
||||||
Assert.Equal(domainModel.Name, result.Name);
|
Assert.Equal(domainModel.Name, result.Name);
|
||||||
|
Assert.Equal(domainModel.IsHidden, result.IsHidden);
|
||||||
Assert.True((DateTime.Now - result.DateCreated) < TimeSpan.FromSeconds(1));
|
Assert.True((DateTime.Now - result.DateCreated) < TimeSpan.FromSeconds(1));
|
||||||
Assert.True((DateTime.Now - result.DateModified) < TimeSpan.FromSeconds(1));
|
Assert.True((DateTime.Now - result.DateModified) < TimeSpan.FromSeconds(1));
|
||||||
}
|
}
|
||||||
@@ -147,8 +159,8 @@ public class FileSystemItemMappingTests
|
|||||||
// Arrange
|
// Arrange
|
||||||
List<FileSystemItem> domainModels =
|
List<FileSystemItem> domainModels =
|
||||||
[
|
[
|
||||||
_directoryFixture.Create(),
|
_directoryFixture.Create(isHidden: true),
|
||||||
_fileFixture.Create(),
|
_fileFixture.Create(isHidden: false),
|
||||||
_windowsRootItemFixture.Create(),
|
_windowsRootItemFixture.Create(),
|
||||||
_unixRootItemFixture.Create()
|
_unixRootItemFixture.Create()
|
||||||
];
|
];
|
||||||
@@ -166,6 +178,7 @@ public class FileSystemItemMappingTests
|
|||||||
Assert.Equal(domainModels[i].Name, resultList[i].Name);
|
Assert.Equal(domainModels[i].Name, resultList[i].Name);
|
||||||
Assert.Equal(domainModels[i].Id.Path, resultList[i].Path);
|
Assert.Equal(domainModels[i].Id.Path, resultList[i].Path);
|
||||||
Assert.Equal(domainModels[i].Type, resultList[i].ItemType);
|
Assert.Equal(domainModels[i].Type, resultList[i].ItemType);
|
||||||
|
Assert.Equal(domainModels[i].IsHidden, resultList[i].IsHidden);
|
||||||
Assert.False(resultList[i].IsExpanded);
|
Assert.False(resultList[i].IsExpanded);
|
||||||
Assert.False(resultList[i].ChildrenLoaded);
|
Assert.False(resultList[i].ChildrenLoaded);
|
||||||
}
|
}
|
||||||
@@ -189,7 +202,11 @@ public class FileSystemItemMappingTests
|
|||||||
public void ToTreeNodeResponses_WhenMappingMultipleFileSystemItems_ShouldMapCorrectly()
|
public void ToTreeNodeResponses_WhenMappingMultipleFileSystemItems_ShouldMapCorrectly()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
IEnumerable<FileSystemItem> domainModels = _directoryFixture.CreateMany();
|
IEnumerable<FileSystemItem> domainModels =
|
||||||
|
[
|
||||||
|
_directoryFixture.Create(isHidden: true),
|
||||||
|
_directoryFixture.Create(isHidden: false)
|
||||||
|
];
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
IEnumerable<FileSystemTreeNodeResponse> result = domainModels.ToTreeNodeResponses();
|
IEnumerable<FileSystemTreeNodeResponse> result = domainModels.ToTreeNodeResponses();
|
||||||
@@ -205,6 +222,7 @@ public class FileSystemItemMappingTests
|
|||||||
Assert.Equal(domainModelsList[i].Name, resultList[i].Name);
|
Assert.Equal(domainModelsList[i].Name, resultList[i].Name);
|
||||||
Assert.Equal(domainModelsList[i].Id.Path, resultList[i].Path);
|
Assert.Equal(domainModelsList[i].Id.Path, resultList[i].Path);
|
||||||
Assert.Equal(domainModelsList[i].Type, resultList[i].ItemType);
|
Assert.Equal(domainModelsList[i].Type, resultList[i].ItemType);
|
||||||
|
Assert.Equal(domainModelsList[i].IsHidden, resultList[i].IsHidden);
|
||||||
Assert.False(resultList[i].IsExpanded);
|
Assert.False(resultList[i].IsExpanded);
|
||||||
Assert.False(resultList[i].ChildrenLoaded);
|
Assert.False(resultList[i].ChildrenLoaded);
|
||||||
Assert.Empty(resultList[i].Children);
|
Assert.Empty(resultList[i].Children);
|
||||||
|
|||||||
+24
-8
@@ -20,11 +20,13 @@ public class FileMappingTests
|
|||||||
{
|
{
|
||||||
private readonly FileFixture _fileFixture = new();
|
private readonly FileFixture _fileFixture = new();
|
||||||
|
|
||||||
[Fact]
|
[Theory]
|
||||||
public void ToFileSystemTreeNodeResponse_WhenMappingFile_ShouldMapCorrectly()
|
[InlineData(true)] // hidden file
|
||||||
|
[InlineData(false)] // visible file
|
||||||
|
public void ToFileSystemTreeNodeResponse_WhenMappingFile_ShouldMapCorrectly(bool isHidden)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
File domainModel = _fileFixture.Create();
|
File domainModel = _fileFixture.Create(isHidden: isHidden);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
FileSystemTreeNodeResponse result = domainModel.ToFileSystemTreeNodeResponse();
|
FileSystemTreeNodeResponse result = domainModel.ToFileSystemTreeNodeResponse();
|
||||||
@@ -34,6 +36,7 @@ public class FileMappingTests
|
|||||||
Assert.Equal(domainModel.Name, result.Name);
|
Assert.Equal(domainModel.Name, result.Name);
|
||||||
Assert.Equal(domainModel.Id.Path, result.Path);
|
Assert.Equal(domainModel.Id.Path, result.Path);
|
||||||
Assert.Equal(domainModel.Type, result.ItemType);
|
Assert.Equal(domainModel.Type, result.ItemType);
|
||||||
|
Assert.Equal(domainModel.IsHidden, result.IsHidden);
|
||||||
Assert.False(result.IsExpanded);
|
Assert.False(result.IsExpanded);
|
||||||
Assert.False(result.ChildrenLoaded);
|
Assert.False(result.ChildrenLoaded);
|
||||||
}
|
}
|
||||||
@@ -42,7 +45,11 @@ public class FileMappingTests
|
|||||||
public void ToFileSystemTreeNodeResponses_WhenMappingMultipleFiles_ShouldMapCorrectly()
|
public void ToFileSystemTreeNodeResponses_WhenMappingMultipleFiles_ShouldMapCorrectly()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
IEnumerable<File> domainModels = _fileFixture.CreateMany();
|
IEnumerable<File> domainModels =
|
||||||
|
[
|
||||||
|
_fileFixture.Create(isHidden: true),
|
||||||
|
_fileFixture.Create(isHidden: false)
|
||||||
|
];
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
IEnumerable<FileSystemTreeNodeResponse> result = domainModels.ToFileSystemTreeNodeResponses();
|
IEnumerable<FileSystemTreeNodeResponse> result = domainModels.ToFileSystemTreeNodeResponses();
|
||||||
@@ -58,17 +65,20 @@ public class FileMappingTests
|
|||||||
Assert.Equal(domainModelsList[i].Name, resultList[i].Name);
|
Assert.Equal(domainModelsList[i].Name, resultList[i].Name);
|
||||||
Assert.Equal(domainModelsList[i].Id.Path, resultList[i].Path);
|
Assert.Equal(domainModelsList[i].Id.Path, resultList[i].Path);
|
||||||
Assert.Equal(domainModelsList[i].Type, resultList[i].ItemType);
|
Assert.Equal(domainModelsList[i].Type, resultList[i].ItemType);
|
||||||
|
Assert.Equal(domainModelsList[i].IsHidden, resultList[i].IsHidden);
|
||||||
Assert.False(resultList[i].IsExpanded);
|
Assert.False(resultList[i].IsExpanded);
|
||||||
Assert.False(resultList[i].ChildrenLoaded);
|
Assert.False(resultList[i].ChildrenLoaded);
|
||||||
Assert.Empty(resultList[i].Children);
|
Assert.Empty(resultList[i].Children);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Theory]
|
||||||
public void ToResponse_WhenMappingFile_ShouldMapCorrectly()
|
[InlineData(true)] // hidden file
|
||||||
|
[InlineData(false)] // visible file
|
||||||
|
public void ToResponse_WhenMappingFile_ShouldMapCorrectly(bool isHidden)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
File domainModel = _fileFixture.Create();
|
File domainModel = _fileFixture.Create(isHidden: isHidden);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
FileResponse result = domainModel.ToResponse();
|
FileResponse result = domainModel.ToResponse();
|
||||||
@@ -80,13 +90,18 @@ public class FileMappingTests
|
|||||||
Assert.Equal(domainModel.DateCreated.Value, result.DateCreated);
|
Assert.Equal(domainModel.DateCreated.Value, result.DateCreated);
|
||||||
Assert.Equal(domainModel.DateModified.Value, result.DateModified);
|
Assert.Equal(domainModel.DateModified.Value, result.DateModified);
|
||||||
Assert.Equal(domainModel.Size, result.Size);
|
Assert.Equal(domainModel.Size, result.Size);
|
||||||
|
Assert.Equal(domainModel.IsHidden, result.IsHidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ToResponses_WhenMappingMultipleFiles_ShouldMapCorrectly()
|
public void ToResponses_WhenMappingMultipleFiles_ShouldMapCorrectly()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
IEnumerable<File> domainModels = _fileFixture.CreateMany();
|
IEnumerable<File> domainModels =
|
||||||
|
[
|
||||||
|
_fileFixture.Create(isHidden: true),
|
||||||
|
_fileFixture.Create(isHidden: false)
|
||||||
|
];
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
IEnumerable<FileResponse> result = domainModels.ToResponses();
|
IEnumerable<FileResponse> result = domainModels.ToResponses();
|
||||||
@@ -104,6 +119,7 @@ public class FileMappingTests
|
|||||||
Assert.Equal(domainModelsList[i].Size, resultList[i].Size);
|
Assert.Equal(domainModelsList[i].Size, resultList[i].Size);
|
||||||
Assert.Equal(domainModelsList[i].DateCreated.Value, resultList[i].DateCreated);
|
Assert.Equal(domainModelsList[i].DateCreated.Value, resultList[i].DateCreated);
|
||||||
Assert.Equal(domainModelsList[i].DateModified.Value, resultList[i].DateModified);
|
Assert.Equal(domainModelsList[i].DateModified.Value, resultList[i].DateModified);
|
||||||
|
Assert.Equal(domainModelsList[i].IsHidden, resultList[i].IsHidden);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+13
-3
@@ -51,7 +51,11 @@ public class GetDirectoriesQueryHandlerTests
|
|||||||
// Arrange
|
// Arrange
|
||||||
GetDirectoriesQuery getDirectoriesQuery = _getDirectoriesQueryFixture.Create(shouldIncludeHiddenElements: false);
|
GetDirectoriesQuery getDirectoriesQuery = _getDirectoriesQueryFixture.Create(shouldIncludeHiddenElements: false);
|
||||||
|
|
||||||
IEnumerable<Directory> directories = _directoryFixture.CreateMany();
|
IEnumerable<Directory> directories =
|
||||||
|
[
|
||||||
|
_directoryFixture.Create(isHidden: true),
|
||||||
|
_directoryFixture.Create(isHidden: false)
|
||||||
|
];
|
||||||
|
|
||||||
_mockDirectoryService.GetSubdirectories(getDirectoriesQuery.Path!, getDirectoriesQuery.ShouldIncludeHiddenElements)
|
_mockDirectoryService.GetSubdirectories(getDirectoriesQuery.Path!, getDirectoriesQuery.ShouldIncludeHiddenElements)
|
||||||
.Returns(Result.From(directories));
|
.Returns(Result.From(directories));
|
||||||
@@ -73,7 +77,8 @@ public class GetDirectoriesQueryHandlerTests
|
|||||||
Assert.Equal(directoriesList[i].Name, resultList[i].Name);
|
Assert.Equal(directoriesList[i].Name, resultList[i].Name);
|
||||||
Assert.Equal(directoriesList[i].DateCreated.Value, resultList[i].DateCreated);
|
Assert.Equal(directoriesList[i].DateCreated.Value, resultList[i].DateCreated);
|
||||||
Assert.Equal(directoriesList[i].DateModified.Value, resultList[i].DateModified);
|
Assert.Equal(directoriesList[i].DateModified.Value, resultList[i].DateModified);
|
||||||
Assert.Empty(resultList[i].Items); // since files are not included
|
Assert.Equal(directoriesList[i].IsHidden, resultList[i].IsHidden);
|
||||||
|
Assert.Empty(resultList[i].Items); // Since files are not included.
|
||||||
}
|
}
|
||||||
|
|
||||||
_mockDirectoryService.Received(1).GetSubdirectories(getDirectoriesQuery.Path!, getDirectoriesQuery.ShouldIncludeHiddenElements);
|
_mockDirectoryService.Received(1).GetSubdirectories(getDirectoriesQuery.Path!, getDirectoriesQuery.ShouldIncludeHiddenElements);
|
||||||
@@ -85,7 +90,11 @@ public class GetDirectoriesQueryHandlerTests
|
|||||||
// Arrange
|
// Arrange
|
||||||
GetDirectoriesQuery getDirectoriesQuery = _getDirectoriesQueryFixture.Create(shouldIncludeHiddenElements: true);
|
GetDirectoriesQuery getDirectoriesQuery = _getDirectoriesQueryFixture.Create(shouldIncludeHiddenElements: true);
|
||||||
|
|
||||||
IEnumerable<Directory> directories = _directoryFixture.CreateMany();
|
IEnumerable<Directory> directories =
|
||||||
|
[
|
||||||
|
_directoryFixture.Create(isHidden: true),
|
||||||
|
_directoryFixture.Create(isHidden: false)
|
||||||
|
];
|
||||||
|
|
||||||
_mockDirectoryService.GetSubdirectories(getDirectoriesQuery.Path!, getDirectoriesQuery.ShouldIncludeHiddenElements)
|
_mockDirectoryService.GetSubdirectories(getDirectoriesQuery.Path!, getDirectoriesQuery.ShouldIncludeHiddenElements)
|
||||||
.Returns(Result.From(directories));
|
.Returns(Result.From(directories));
|
||||||
@@ -107,6 +116,7 @@ public class GetDirectoriesQueryHandlerTests
|
|||||||
Assert.Equal(directoriesList[i].Name, resultList[i].Name);
|
Assert.Equal(directoriesList[i].Name, resultList[i].Name);
|
||||||
Assert.Equal(directoriesList[i].DateCreated.Value, resultList[i].DateCreated);
|
Assert.Equal(directoriesList[i].DateCreated.Value, resultList[i].DateCreated);
|
||||||
Assert.Equal(directoriesList[i].DateModified.Value, resultList[i].DateModified);
|
Assert.Equal(directoriesList[i].DateModified.Value, resultList[i].DateModified);
|
||||||
|
Assert.Equal(directoriesList[i].IsHidden, resultList[i].IsHidden);
|
||||||
Assert.Equal(directoriesList[i].Items.Count, resultList[i].Items.Count);
|
Assert.Equal(directoriesList[i].Items.Count, resultList[i].Items.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-2
@@ -51,7 +51,11 @@ public class GetFilesQueryHandlerTests
|
|||||||
// Arrange
|
// Arrange
|
||||||
GetFilesQuery getFilesQuery = _getFilesQueryFixture.Create(shouldIncludeHiddenElements: false);
|
GetFilesQuery getFilesQuery = _getFilesQueryFixture.Create(shouldIncludeHiddenElements: false);
|
||||||
|
|
||||||
IEnumerable<File> files = _fileFixture.CreateMany();
|
IEnumerable<File> files =
|
||||||
|
[
|
||||||
|
_fileFixture.Create(isHidden: true),
|
||||||
|
_fileFixture.Create(isHidden: false)
|
||||||
|
];
|
||||||
|
|
||||||
_mockFileService.GetFiles(getFilesQuery.Path!, getFilesQuery.ShouldIncludeHiddenElements)
|
_mockFileService.GetFiles(getFilesQuery.Path!, getFilesQuery.ShouldIncludeHiddenElements)
|
||||||
.Returns(Result.From(files));
|
.Returns(Result.From(files));
|
||||||
@@ -74,6 +78,7 @@ public class GetFilesQueryHandlerTests
|
|||||||
Assert.Equal(filesList[i].DateCreated.Value, resultList[i].DateCreated);
|
Assert.Equal(filesList[i].DateCreated.Value, resultList[i].DateCreated);
|
||||||
Assert.Equal(filesList[i].DateModified.Value, resultList[i].DateModified);
|
Assert.Equal(filesList[i].DateModified.Value, resultList[i].DateModified);
|
||||||
Assert.Equal(filesList[i].Size, resultList[i].Size);
|
Assert.Equal(filesList[i].Size, resultList[i].Size);
|
||||||
|
Assert.Equal(filesList[i].IsHidden, resultList[i].IsHidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
_mockFileService.Received(1).GetFiles(getFilesQuery.Path!, getFilesQuery.ShouldIncludeHiddenElements);
|
_mockFileService.Received(1).GetFiles(getFilesQuery.Path!, getFilesQuery.ShouldIncludeHiddenElements);
|
||||||
@@ -85,7 +90,11 @@ public class GetFilesQueryHandlerTests
|
|||||||
// Arrange
|
// Arrange
|
||||||
GetFilesQuery getFilesQuery = _getFilesQueryFixture.Create(shouldIncludeHiddenElements: true);
|
GetFilesQuery getFilesQuery = _getFilesQueryFixture.Create(shouldIncludeHiddenElements: true);
|
||||||
|
|
||||||
IEnumerable<File> files = _fileFixture.CreateMany();
|
IEnumerable<File> files =
|
||||||
|
[
|
||||||
|
_fileFixture.Create(isHidden: true),
|
||||||
|
_fileFixture.Create(isHidden: false)
|
||||||
|
];
|
||||||
|
|
||||||
_mockFileService.GetFiles(getFilesQuery.Path!, getFilesQuery.ShouldIncludeHiddenElements)
|
_mockFileService.GetFiles(getFilesQuery.Path!, getFilesQuery.ShouldIncludeHiddenElements)
|
||||||
.Returns(Result.From(files));
|
.Returns(Result.From(files));
|
||||||
@@ -108,6 +117,7 @@ public class GetFilesQueryHandlerTests
|
|||||||
Assert.Equal(filesList[i].DateCreated.Value, resultList[i].DateCreated);
|
Assert.Equal(filesList[i].DateCreated.Value, resultList[i].DateCreated);
|
||||||
Assert.Equal(filesList[i].DateModified.Value, resultList[i].DateModified);
|
Assert.Equal(filesList[i].DateModified.Value, resultList[i].DateModified);
|
||||||
Assert.Equal(filesList[i].Size, resultList[i].Size);
|
Assert.Equal(filesList[i].Size, resultList[i].Size);
|
||||||
|
Assert.Equal(filesList[i].IsHidden, resultList[i].IsHidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
_mockFileService.Received(1).GetFiles(getFilesQuery.Path!, getFilesQuery.ShouldIncludeHiddenElements);
|
_mockFileService.Received(1).GetFiles(getFilesQuery.Path!, getFilesQuery.ShouldIncludeHiddenElements);
|
||||||
|
|||||||
+12
-6
@@ -1,6 +1,4 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using AutoFixture;
|
|
||||||
using AutoFixture.AutoNSubstitute;
|
|
||||||
using Lumina.Application.Common.Infrastructure.Validation;
|
using Lumina.Application.Common.Infrastructure.Validation;
|
||||||
using Lumina.Application.Core.FileSystemManagement.Files.Queries.GetTreeFiles;
|
using Lumina.Application.Core.FileSystemManagement.Files.Queries.GetTreeFiles;
|
||||||
using Lumina.Application.Fixtures.Core.FileSystemManagement.Files.Queries.GetTreeFiles;
|
using Lumina.Application.Fixtures.Core.FileSystemManagement.Files.Queries.GetTreeFiles;
|
||||||
@@ -26,7 +24,6 @@ namespace Lumina.Application.UnitTests.Core.FileSystemManagement.Files.Queries.G
|
|||||||
[ExcludeFromCodeCoverage]
|
[ExcludeFromCodeCoverage]
|
||||||
public class GetTreeFilesQueryHandlerTests
|
public class GetTreeFilesQueryHandlerTests
|
||||||
{
|
{
|
||||||
private readonly IFixture _fixture;
|
|
||||||
private readonly IFileService _mockFileService;
|
private readonly IFileService _mockFileService;
|
||||||
private readonly GetTreeFilesQueryHandler _sut;
|
private readonly GetTreeFilesQueryHandler _sut;
|
||||||
private readonly FileFixture _fileFixture = new();
|
private readonly FileFixture _fileFixture = new();
|
||||||
@@ -37,7 +34,6 @@ public class GetTreeFilesQueryHandlerTests
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public GetTreeFilesQueryHandlerTests()
|
public GetTreeFilesQueryHandlerTests()
|
||||||
{
|
{
|
||||||
_fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
|
|
||||||
_mockFileService = Substitute.For<IFileService>();
|
_mockFileService = Substitute.For<IFileService>();
|
||||||
IValidator<GetTreeFilesQuery> mockValidator = Substitute.For<IValidator<GetTreeFilesQuery>>();
|
IValidator<GetTreeFilesQuery> mockValidator = Substitute.For<IValidator<GetTreeFilesQuery>>();
|
||||||
mockValidator.Validate(Arg.Any<GetTreeFilesQuery>())
|
mockValidator.Validate(Arg.Any<GetTreeFilesQuery>())
|
||||||
@@ -51,7 +47,11 @@ public class GetTreeFilesQueryHandlerTests
|
|||||||
// Arrange
|
// Arrange
|
||||||
GetTreeFilesQuery getFilesQuery = _getTreeFilesQueryFixture.Create(shouldIncludeHiddenElements: false);
|
GetTreeFilesQuery getFilesQuery = _getTreeFilesQueryFixture.Create(shouldIncludeHiddenElements: false);
|
||||||
|
|
||||||
IEnumerable<File> files = _fileFixture.CreateMany();
|
IEnumerable<File> files =
|
||||||
|
[
|
||||||
|
_fileFixture.Create(isHidden: true),
|
||||||
|
_fileFixture.Create(isHidden: false)
|
||||||
|
];
|
||||||
|
|
||||||
_mockFileService.GetFiles(getFilesQuery.Path!, getFilesQuery.ShouldIncludeHiddenElements)
|
_mockFileService.GetFiles(getFilesQuery.Path!, getFilesQuery.ShouldIncludeHiddenElements)
|
||||||
.Returns(Result.From(files));
|
.Returns(Result.From(files));
|
||||||
@@ -72,6 +72,7 @@ public class GetTreeFilesQueryHandlerTests
|
|||||||
Assert.Equal(filesList[i].Id.Path, resultList[i].Path);
|
Assert.Equal(filesList[i].Id.Path, resultList[i].Path);
|
||||||
Assert.Equal(filesList[i].Name, resultList[i].Name);
|
Assert.Equal(filesList[i].Name, resultList[i].Name);
|
||||||
Assert.Equal(FileSystemItemType.File, resultList[i].ItemType);
|
Assert.Equal(FileSystemItemType.File, resultList[i].ItemType);
|
||||||
|
Assert.Equal(filesList[i].IsHidden, resultList[i].IsHidden);
|
||||||
Assert.False(resultList[i].IsExpanded);
|
Assert.False(resultList[i].IsExpanded);
|
||||||
Assert.False(resultList[i].ChildrenLoaded);
|
Assert.False(resultList[i].ChildrenLoaded);
|
||||||
Assert.Empty(resultList[i].Children);
|
Assert.Empty(resultList[i].Children);
|
||||||
@@ -86,7 +87,11 @@ public class GetTreeFilesQueryHandlerTests
|
|||||||
// Arrange
|
// Arrange
|
||||||
GetTreeFilesQuery getFilesQuery = _getTreeFilesQueryFixture.Create(shouldIncludeHiddenElements: true);
|
GetTreeFilesQuery getFilesQuery = _getTreeFilesQueryFixture.Create(shouldIncludeHiddenElements: true);
|
||||||
|
|
||||||
IEnumerable<File> files = _fileFixture.CreateMany();
|
IEnumerable<File> files =
|
||||||
|
[
|
||||||
|
_fileFixture.Create(isHidden: true),
|
||||||
|
_fileFixture.Create(isHidden: false)
|
||||||
|
];
|
||||||
|
|
||||||
_mockFileService.GetFiles(getFilesQuery.Path!, getFilesQuery.ShouldIncludeHiddenElements)
|
_mockFileService.GetFiles(getFilesQuery.Path!, getFilesQuery.ShouldIncludeHiddenElements)
|
||||||
.Returns(Result.From(files));
|
.Returns(Result.From(files));
|
||||||
@@ -107,6 +112,7 @@ public class GetTreeFilesQueryHandlerTests
|
|||||||
Assert.Equal(filesList[i].Id.Path, resultList[i].Path);
|
Assert.Equal(filesList[i].Id.Path, resultList[i].Path);
|
||||||
Assert.Equal(filesList[i].Name, resultList[i].Name);
|
Assert.Equal(filesList[i].Name, resultList[i].Name);
|
||||||
Assert.Equal(FileSystemItemType.File, resultList[i].ItemType);
|
Assert.Equal(FileSystemItemType.File, resultList[i].ItemType);
|
||||||
|
Assert.Equal(filesList[i].IsHidden, resultList[i].IsHidden);
|
||||||
Assert.False(resultList[i].IsExpanded);
|
Assert.False(resultList[i].IsExpanded);
|
||||||
Assert.False(resultList[i].ChildrenLoaded);
|
Assert.False(resultList[i].ChildrenLoaded);
|
||||||
Assert.Empty(resultList[i].Children);
|
Assert.Empty(resultList[i].Children);
|
||||||
|
|||||||
+18
-1
@@ -1,7 +1,6 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Domain.Common.Errors;
|
using Lumina.Domain.Common.Errors;
|
||||||
using Lumina.Domain.Common.Primitives;
|
using Lumina.Domain.Common.Primitives;
|
||||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
|
|
||||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||||
@@ -42,6 +41,24 @@ public class DirectoryTests
|
|||||||
Assert.Equal(dateCreated, result.Value.DateCreated);
|
Assert.Equal(dateCreated, result.Value.DateCreated);
|
||||||
Assert.Equal(dateModified, result.Value.DateModified);
|
Assert.Equal(dateModified, result.Value.DateModified);
|
||||||
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
|
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
|
||||||
|
Assert.False(result.Value.IsHidden);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Create_WhenCalledWithHiddenDirectory_ShouldSetHiddenState()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
string path = "/valid/path";
|
||||||
|
string name = "TestDirectory";
|
||||||
|
Optional<DateTime> dateCreated = DateTime.Now;
|
||||||
|
Optional<DateTime> dateModified = DateTime.Now;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
Result<Directory> result = Directory.Create(path, name, dateCreated, dateModified, isHidden: true);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.False(result.IsFailure);
|
||||||
|
Assert.True(result.Value.IsHidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|||||||
+19
@@ -42,6 +42,25 @@ public class FileTests
|
|||||||
Assert.Equal(dateModified, result.Value.DateModified);
|
Assert.Equal(dateModified, result.Value.DateModified);
|
||||||
Assert.Equal(size, result.Value.Size);
|
Assert.Equal(size, result.Value.Size);
|
||||||
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
|
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
|
||||||
|
Assert.False(result.Value.IsHidden);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Create_WhenCalledWithHiddenFile_ShouldSetHiddenState()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
string path = "/valid/path/file.txt";
|
||||||
|
string name = "file.txt";
|
||||||
|
Optional<DateTime> dateCreated = DateTime.Now;
|
||||||
|
Optional<DateTime> dateModified = DateTime.Now;
|
||||||
|
long size = 1024;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
Result<File> result = File.Create(path, name, dateCreated, dateModified, size, isHidden: true);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.False(result.IsFailure);
|
||||||
|
Assert.True(result.Value.IsHidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|||||||
+16
@@ -46,6 +46,7 @@ public class FileSystemItemTests
|
|||||||
Assert.Equal(name, item.Name);
|
Assert.Equal(name, item.Name);
|
||||||
Assert.Equal(type, item.Type);
|
Assert.Equal(type, item.Type);
|
||||||
Assert.Equal(FileSystemItemStatus.Accessible, item.Status);
|
Assert.Equal(FileSystemItemStatus.Accessible, item.Status);
|
||||||
|
Assert.False(item.IsHidden);
|
||||||
Assert.Equal(Optional<FileSystemItem>.None(), item.Parent);
|
Assert.Equal(Optional<FileSystemItem>.None(), item.Parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,6 +66,21 @@ public class FileSystemItemTests
|
|||||||
Assert.Equal(newStatus, item.Status);
|
Assert.Equal(newStatus, item.Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void SetHiddenState_WhenCalled_ShouldUpdateHiddenStateAndReturnUpdated()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
FileSystemItemFixture item = CreateFileSystemItemFixture();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
Result<Updated> result = item.SetHiddenState(true);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.False(result.IsFailure);
|
||||||
|
Assert.Equal(Result.Updated, result.Value);
|
||||||
|
Assert.True(item.IsHidden);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void SetParent_WithValidParent_ShouldUpdateParentAndReturnUpdated()
|
public void SetParent_WithValidParent_ShouldUpdateParentAndReturnUpdated()
|
||||||
{
|
{
|
||||||
|
|||||||
+76
@@ -211,6 +211,82 @@ public class DirectoryProviderServiceTests
|
|||||||
Assert.Empty(result.Value);
|
Assert.Empty(result.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void IsHidden_WhenDirectoryHasHiddenAttribute_ShouldReturnTrue()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
FileSystemPathId path = _fileSystemPathIdFixture.Create(_pathHidden1);
|
||||||
|
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties, false).Returns(true);
|
||||||
|
_mockFileSystem.File.GetAttributes(path.Path).Returns(FileAttributes.Directory | FileAttributes.Hidden);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
bool result = _sut.IsHidden(path);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.True(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void IsHidden_WhenDirectoryPathEndsWithSeparator_ShouldCheckAttributesWithoutSeparator()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
FileSystemPathId path = _fileSystemPathIdFixture.Create(_pathHidden2);
|
||||||
|
_mockFileSystem.Path.DirectorySeparatorChar.Returns(_dirSeparator);
|
||||||
|
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties, false).Returns(true);
|
||||||
|
_mockFileSystem.File.GetAttributes(_pathHidden1).Returns(FileAttributes.Directory | FileAttributes.Hidden);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
bool result = _sut.IsHidden(path);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.True(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void IsHidden_WhenDirectoryDoesNotHaveHiddenAttribute_ShouldReturnFalse()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
FileSystemPathId path = _fileSystemPathIdFixture.Create(_pathVisible1);
|
||||||
|
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties, false).Returns(true);
|
||||||
|
_mockFileSystem.File.GetAttributes(path.Path).Returns(FileAttributes.Directory);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
bool result = _sut.IsHidden(path);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.False(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void IsHidden_WhenGetAttributesThrowsException_ShouldReturnFalse()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
FileSystemPathId path = _fileSystemPathIdFixture.Create(_pathInvalid1);
|
||||||
|
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties, false).Returns(true);
|
||||||
|
_mockFileSystem.File.GetAttributes(path.Path).Throws(new Exception("Access denied"));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
bool result = _sut.IsHidden(path);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.False(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void IsHidden_WhenUserHasNoAccess_ShouldReturnFalseWithoutReadingAttributes()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
FileSystemPathId path = _fileSystemPathIdFixture.Create(_pathHidden1);
|
||||||
|
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties, false).Returns(false);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
bool result = _sut.IsHidden(path);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.False(result);
|
||||||
|
_mockFileSystem.File.DidNotReceive().GetAttributes(Arg.Any<string>());
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void DirectoryExists_WhenDirectoryExists_ShouldReturnTrue()
|
public void DirectoryExists_WhenDirectoryExists_ShouldReturnTrue()
|
||||||
{
|
{
|
||||||
|
|||||||
+45
-4
@@ -83,6 +83,37 @@ public class DirectoryServiceTests
|
|||||||
Assert.False(result.IsFailure);
|
Assert.False(result.IsFailure);
|
||||||
Assert.Equal(2, result.Value.Count());
|
Assert.Equal(2, result.Value.Count());
|
||||||
Assert.Equal(["Sub1", "Sub2"], result.Value.Select(d => d.Name));
|
Assert.Equal(["Sub1", "Sub2"], result.Value.Select(d => d.Name));
|
||||||
|
_mockEnvironmentContext.DirectoryProviderService.DidNotReceive().IsHidden(Arg.Any<FileSystemPathId>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GetSubdirectories_WhenDirectoryIsHidden_ShouldReturnDirectoryWithHiddenState()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
string path = _pathDirTest;
|
||||||
|
bool shouldIncludeHiddenElements = true;
|
||||||
|
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||||
|
FileSystemPathId subPath = _fileSystemPathIdFixture.Create(_pathDirTestSubDir1);
|
||||||
|
|
||||||
|
_mockEnvironmentContext.DirectoryProviderService.GetSubdirectoryPaths(pathId, shouldIncludeHiddenElements)
|
||||||
|
.Returns(Result.From(new[] { subPath }.AsEnumerable()));
|
||||||
|
_mockEnvironmentContext.DirectoryProviderService.GetFileName(subPath)
|
||||||
|
.Returns(Result.From(System.IO.Path.GetFileName(subPath.Path)));
|
||||||
|
_mockEnvironmentContext.DirectoryProviderService.GetLastWriteTime(subPath)
|
||||||
|
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||||
|
_mockEnvironmentContext.DirectoryProviderService.GetCreationTime(subPath)
|
||||||
|
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now.AddDays(-1))));
|
||||||
|
_mockEnvironmentContext.DirectoryProviderService.IsHidden(subPath)
|
||||||
|
.Returns(true);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
Result<IEnumerable<Directory>> result = _sut.GetSubdirectories(path, shouldIncludeHiddenElements);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.False(result.IsFailure);
|
||||||
|
Directory directory = Assert.Single(result.Value);
|
||||||
|
Assert.True(directory.IsHidden);
|
||||||
|
_mockEnvironmentContext.DirectoryProviderService.Received(1).IsHidden(subPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -124,7 +155,7 @@ public class DirectoryServiceTests
|
|||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
string path = _pathDirTest;
|
string path = _pathDirTest;
|
||||||
bool shouldIncludeHiddenElements = false;
|
bool shouldIncludeHiddenElements = true;
|
||||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||||
FileSystemPathId subPath = _fileSystemPathIdFixture.Create(
|
FileSystemPathId subPath = _fileSystemPathIdFixture.Create(
|
||||||
s_isUnix ? "/TestDir/InaccessibleSub" : @"C:\TestDir\InaccessibleSub"
|
s_isUnix ? "/TestDir/InaccessibleSub" : @"C:\TestDir\InaccessibleSub"
|
||||||
@@ -139,6 +170,7 @@ public class DirectoryServiceTests
|
|||||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||||
_mockEnvironmentContext.DirectoryProviderService.GetCreationTime(subPath)
|
_mockEnvironmentContext.DirectoryProviderService.GetCreationTime(subPath)
|
||||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||||
|
_mockEnvironmentContext.DirectoryProviderService.IsHidden(subPath).Returns(true);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
Result<IEnumerable<Directory>> result = _sut.GetSubdirectories(path, shouldIncludeHiddenElements);
|
Result<IEnumerable<Directory>> result = _sut.GetSubdirectories(path, shouldIncludeHiddenElements);
|
||||||
@@ -147,6 +179,7 @@ public class DirectoryServiceTests
|
|||||||
Assert.False(result.IsFailure);
|
Assert.False(result.IsFailure);
|
||||||
Assert.Single(result.Value);
|
Assert.Single(result.Value);
|
||||||
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.First().Status);
|
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.First().Status);
|
||||||
|
Assert.True(result.Value.First().IsHidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -331,6 +364,7 @@ public class DirectoryServiceTests
|
|||||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||||
_mockEnvironmentContext.DirectoryProviderService.GetCreationTime(newDirPathId)
|
_mockEnvironmentContext.DirectoryProviderService.GetCreationTime(newDirPathId)
|
||||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||||
|
_mockEnvironmentContext.DirectoryProviderService.IsHidden(newDirPathId).Returns(true);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
Result<Directory> result = _sut.CreateDirectory(parentPath, newDirName);
|
Result<Directory> result = _sut.CreateDirectory(parentPath, newDirName);
|
||||||
@@ -338,6 +372,7 @@ public class DirectoryServiceTests
|
|||||||
// Assert
|
// Assert
|
||||||
Assert.False(result.IsFailure);
|
Assert.False(result.IsFailure);
|
||||||
Assert.Equal(newDirPathId, result.Value.Id);
|
Assert.Equal(newDirPathId, result.Value.Id);
|
||||||
|
Assert.True(result.Value.IsHidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -425,6 +460,7 @@ public class DirectoryServiceTests
|
|||||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||||
_mockEnvironmentContext.DirectoryProviderService.GetCreationTime(newDirPathId)
|
_mockEnvironmentContext.DirectoryProviderService.GetCreationTime(newDirPathId)
|
||||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||||
|
_mockEnvironmentContext.DirectoryProviderService.IsHidden(newDirPathId).Returns(true);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
Result<Directory> result = _sut.CreateDirectory(parentPathId, newDirName);
|
Result<Directory> result = _sut.CreateDirectory(parentPathId, newDirName);
|
||||||
@@ -435,6 +471,7 @@ public class DirectoryServiceTests
|
|||||||
Assert.Equal(newDirPathId, result.Value.Id);
|
Assert.Equal(newDirPathId, result.Value.Id);
|
||||||
Assert.False(result.Value.DateCreated.HasValue);
|
Assert.False(result.Value.DateCreated.HasValue);
|
||||||
Assert.False(result.Value.DateModified.HasValue);
|
Assert.False(result.Value.DateModified.HasValue);
|
||||||
|
Assert.True(result.Value.IsHidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -493,7 +530,7 @@ public class DirectoryServiceTests
|
|||||||
Assert.True(result.IsFailure);
|
Assert.True(result.IsFailure);
|
||||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||||
|
|
||||||
// Verify that DirectoryExists was not called
|
// Verify that DirectoryExists was not called.
|
||||||
_mockEnvironmentContext.DirectoryProviderService.DidNotReceive().DirectoryExists(Arg.Any<FileSystemPathId>());
|
_mockEnvironmentContext.DirectoryProviderService.DidNotReceive().DirectoryExists(Arg.Any<FileSystemPathId>());
|
||||||
_mockEnvironmentContext.DirectoryProviderService.DidNotReceive().CreateDirectory(Arg.Any<FileSystemPathId>(), Arg.Any<string>());
|
_mockEnvironmentContext.DirectoryProviderService.DidNotReceive().CreateDirectory(Arg.Any<FileSystemPathId>(), Arg.Any<string>());
|
||||||
}
|
}
|
||||||
@@ -664,6 +701,7 @@ public class DirectoryServiceTests
|
|||||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||||
_mockEnvironmentContext.DirectoryProviderService.GetCreationTime(newPathId)
|
_mockEnvironmentContext.DirectoryProviderService.GetCreationTime(newPathId)
|
||||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||||
|
_mockEnvironmentContext.DirectoryProviderService.IsHidden(newPathId).Returns(true);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
Result<Directory> result = _sut.RenameDirectory(oldPath, newName);
|
Result<Directory> result = _sut.RenameDirectory(oldPath, newName);
|
||||||
@@ -672,6 +710,7 @@ public class DirectoryServiceTests
|
|||||||
Assert.False(result.IsFailure);
|
Assert.False(result.IsFailure);
|
||||||
Assert.Equal(newPathId, result.Value.Id);
|
Assert.Equal(newPathId, result.Value.Id);
|
||||||
Assert.Equal(newName, result.Value.Name);
|
Assert.Equal(newName, result.Value.Name);
|
||||||
|
Assert.True(result.Value.IsHidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -772,6 +811,7 @@ public class DirectoryServiceTests
|
|||||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||||
_mockEnvironmentContext.DirectoryProviderService.GetCreationTime(newPathId)
|
_mockEnvironmentContext.DirectoryProviderService.GetCreationTime(newPathId)
|
||||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||||
|
_mockEnvironmentContext.DirectoryProviderService.IsHidden(newPathId).Returns(true);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
Result<Directory> result = _sut.RenameDirectory(oldPathId, newName);
|
Result<Directory> result = _sut.RenameDirectory(oldPathId, newName);
|
||||||
@@ -780,6 +820,7 @@ public class DirectoryServiceTests
|
|||||||
Assert.False(result.IsFailure);
|
Assert.False(result.IsFailure);
|
||||||
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.Status);
|
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.Status);
|
||||||
Assert.Equal(newPathId, result.Value.Id);
|
Assert.Equal(newPathId, result.Value.Id);
|
||||||
|
Assert.True(result.Value.IsHidden);
|
||||||
Assert.False(result.Value.DateCreated.HasValue);
|
Assert.False(result.Value.DateCreated.HasValue);
|
||||||
Assert.False(result.Value.DateModified.HasValue);
|
Assert.False(result.Value.DateModified.HasValue);
|
||||||
}
|
}
|
||||||
@@ -828,7 +869,7 @@ public class DirectoryServiceTests
|
|||||||
Assert.True(result.IsFailure);
|
Assert.True(result.IsFailure);
|
||||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||||
|
|
||||||
// Verify that DirectoryExists and RenameDirectory were not called
|
// Verify that DirectoryExists and RenameDirectory were not called.
|
||||||
_mockEnvironmentContext.DirectoryProviderService.DidNotReceive().DirectoryExists(Arg.Any<FileSystemPathId>());
|
_mockEnvironmentContext.DirectoryProviderService.DidNotReceive().DirectoryExists(Arg.Any<FileSystemPathId>());
|
||||||
_mockEnvironmentContext.DirectoryProviderService.DidNotReceive().RenameDirectory(Arg.Any<FileSystemPathId>(), Arg.Any<string>());
|
_mockEnvironmentContext.DirectoryProviderService.DidNotReceive().RenameDirectory(Arg.Any<FileSystemPathId>(), Arg.Any<string>());
|
||||||
}
|
}
|
||||||
@@ -857,7 +898,7 @@ public class DirectoryServiceTests
|
|||||||
Assert.True(result.IsFailure);
|
Assert.True(result.IsFailure);
|
||||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||||
|
|
||||||
// Verify that RenameDirectory was not called
|
// Verify that RenameDirectory was not called.
|
||||||
_mockEnvironmentContext.DirectoryProviderService.DidNotReceive().RenameDirectory(Arg.Any<FileSystemPathId>(), Arg.Any<string>());
|
_mockEnvironmentContext.DirectoryProviderService.DidNotReceive().RenameDirectory(Arg.Any<FileSystemPathId>(), Arg.Any<string>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+60
@@ -190,6 +190,66 @@ public class FileProviderServiceTests
|
|||||||
Assert.Empty(result.Value);
|
Assert.Empty(result.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void IsHidden_WhenFileHasHiddenAttribute_ShouldReturnTrue()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
FileSystemPathId path = _fileSystemPathIdFixture.Create(_pathHidden1);
|
||||||
|
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties).Returns(true);
|
||||||
|
_mockFileSystem.File.GetAttributes(path.Path).Returns(FileAttributes.Hidden);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
bool result = _sut.IsHidden(path);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.True(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void IsHidden_WhenFileDoesNotHaveHiddenAttribute_ShouldReturnFalse()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
FileSystemPathId path = _fileSystemPathIdFixture.Create(_pathVisible1);
|
||||||
|
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties).Returns(true);
|
||||||
|
_mockFileSystem.File.GetAttributes(path.Path).Returns(FileAttributes.Normal);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
bool result = _sut.IsHidden(path);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.False(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void IsHidden_WhenGetAttributesThrowsException_ShouldReturnFalse()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
FileSystemPathId path = _fileSystemPathIdFixture.Create(_pathInvalid1);
|
||||||
|
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties).Returns(true);
|
||||||
|
_mockFileSystem.File.GetAttributes(path.Path).Throws(new Exception("Access denied"));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
bool result = _sut.IsHidden(path);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.False(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void IsHidden_WhenUserHasNoAccess_ShouldReturnFalseWithoutReadingAttributes()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
FileSystemPathId path = _fileSystemPathIdFixture.Create(_pathHidden1);
|
||||||
|
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties).Returns(false);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
bool result = _sut.IsHidden(path);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.False(result);
|
||||||
|
_mockFileSystem.File.DidNotReceive().GetAttributes(Arg.Any<string>());
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void FileExists_WhenFileExists_ShouldReturnTrue()
|
public void FileExists_WhenFileExists_ShouldReturnTrue()
|
||||||
{
|
{
|
||||||
|
|||||||
+48
-1
@@ -94,6 +94,39 @@ public class FileServiceTests
|
|||||||
Assert.False(result.IsFailure);
|
Assert.False(result.IsFailure);
|
||||||
Assert.Equal(2, result.Value.Count());
|
Assert.Equal(2, result.Value.Count());
|
||||||
Assert.Equal(["File1.txt", "File2.txt"], result.Value.Select(f => f.Name));
|
Assert.Equal(["File1.txt", "File2.txt"], result.Value.Select(f => f.Name));
|
||||||
|
_mockEnvironmentContext.FileProviderService.DidNotReceive().IsHidden(Arg.Any<FileSystemPathId>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GetFiles_WhenFileIsHidden_ShouldReturnFileWithHiddenState()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
string path = _pathTestDir;
|
||||||
|
bool shouldIncludeHiddenElements = true;
|
||||||
|
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||||
|
FileSystemPathId filePath = _fileSystemPathIdFixture.Create(_pathTestDirFile1);
|
||||||
|
|
||||||
|
_mockEnvironmentContext.FileProviderService.GetFilePaths(pathId, shouldIncludeHiddenElements)
|
||||||
|
.Returns(Result.From(new[] { filePath }.AsEnumerable()));
|
||||||
|
_mockEnvironmentContext.FileProviderService.GetFileName(filePath)
|
||||||
|
.Returns(Result.From(System.IO.Path.GetFileName(filePath.Path)));
|
||||||
|
_mockEnvironmentContext.FileProviderService.GetLastWriteTime(filePath)
|
||||||
|
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now)));
|
||||||
|
_mockEnvironmentContext.FileProviderService.GetCreationTime(filePath)
|
||||||
|
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now.AddDays(-1))));
|
||||||
|
_mockEnvironmentContext.FileProviderService.GetSize(filePath)
|
||||||
|
.Returns(Result.From((long?)1024));
|
||||||
|
_mockEnvironmentContext.FileProviderService.IsHidden(filePath)
|
||||||
|
.Returns(true);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
Result<IEnumerable<File>> result = _sut.GetFiles(path, shouldIncludeHiddenElements);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.False(result.IsFailure);
|
||||||
|
File file = Assert.Single(result.Value);
|
||||||
|
Assert.True(file.IsHidden);
|
||||||
|
_mockEnvironmentContext.FileProviderService.Received(1).IsHidden(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -135,7 +168,7 @@ public class FileServiceTests
|
|||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
string path = _pathTestDir;
|
string path = _pathTestDir;
|
||||||
bool shouldIncludeHiddenElements = false;
|
bool shouldIncludeHiddenElements = true;
|
||||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||||
FileSystemPathId filePath = _fileSystemPathIdFixture.Create(_pathTestDirInaccessible);
|
FileSystemPathId filePath = _fileSystemPathIdFixture.Create(_pathTestDirInaccessible);
|
||||||
|
|
||||||
@@ -150,6 +183,7 @@ public class FileServiceTests
|
|||||||
.Returns(Errors.Permission.UnauthorizedAccess);
|
.Returns(Errors.Permission.UnauthorizedAccess);
|
||||||
_mockEnvironmentContext.FileProviderService.GetSize(filePath)
|
_mockEnvironmentContext.FileProviderService.GetSize(filePath)
|
||||||
.Returns(Result.From((long?)null));
|
.Returns(Result.From((long?)null));
|
||||||
|
_mockEnvironmentContext.FileProviderService.IsHidden(filePath).Returns(true);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
Result<IEnumerable<File>> result = _sut.GetFiles(path, shouldIncludeHiddenElements);
|
Result<IEnumerable<File>> result = _sut.GetFiles(path, shouldIncludeHiddenElements);
|
||||||
@@ -158,6 +192,7 @@ public class FileServiceTests
|
|||||||
Assert.False(result.IsFailure);
|
Assert.False(result.IsFailure);
|
||||||
Assert.Single(result.Value);
|
Assert.Single(result.Value);
|
||||||
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.First().Status);
|
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.First().Status);
|
||||||
|
Assert.True(result.Value.First().IsHidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -378,6 +413,7 @@ public class FileServiceTests
|
|||||||
_mockEnvironmentContext.FileProviderService.GetCreationTime(copiedFilePathId)
|
_mockEnvironmentContext.FileProviderService.GetCreationTime(copiedFilePathId)
|
||||||
.Returns(Optional<DateTime>.FromNullable(DateTime.Now.AddDays(-1)));
|
.Returns(Optional<DateTime>.FromNullable(DateTime.Now.AddDays(-1)));
|
||||||
_mockEnvironmentContext.FileProviderService.GetSize(copiedFilePathId).Returns((long?)1024);
|
_mockEnvironmentContext.FileProviderService.GetSize(copiedFilePathId).Returns((long?)1024);
|
||||||
|
_mockEnvironmentContext.FileProviderService.IsHidden(copiedFilePathId).Returns(true);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
Result<File> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
|
Result<File> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
|
||||||
@@ -387,6 +423,7 @@ public class FileServiceTests
|
|||||||
Assert.NotNull(result.Value);
|
Assert.NotNull(result.Value);
|
||||||
Assert.Equal("file.txt", result.Value.Name);
|
Assert.Equal("file.txt", result.Value.Name);
|
||||||
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
|
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
|
||||||
|
Assert.True(result.Value.IsHidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -451,6 +488,7 @@ public class FileServiceTests
|
|||||||
_mockEnvironmentContext.FileProviderService.GetLastWriteTime(copiedFilePathId).Returns(Errors.Permission.UnauthorizedAccess);
|
_mockEnvironmentContext.FileProviderService.GetLastWriteTime(copiedFilePathId).Returns(Errors.Permission.UnauthorizedAccess);
|
||||||
_mockEnvironmentContext.FileProviderService.GetCreationTime(copiedFilePathId).Returns(Errors.Permission.UnauthorizedAccess);
|
_mockEnvironmentContext.FileProviderService.GetCreationTime(copiedFilePathId).Returns(Errors.Permission.UnauthorizedAccess);
|
||||||
_mockEnvironmentContext.FileProviderService.GetSize(copiedFilePathId).Returns(Result.From((long?)null));
|
_mockEnvironmentContext.FileProviderService.GetSize(copiedFilePathId).Returns(Result.From((long?)null));
|
||||||
|
_mockEnvironmentContext.FileProviderService.IsHidden(copiedFilePathId).Returns(true);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
Result<File> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
|
Result<File> result = _sut.CopyFile(sourcePath, destinationPath, overrideExisting);
|
||||||
@@ -459,6 +497,7 @@ public class FileServiceTests
|
|||||||
Assert.False(result.IsFailure);
|
Assert.False(result.IsFailure);
|
||||||
Assert.NotNull(result.Value);
|
Assert.NotNull(result.Value);
|
||||||
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.Status);
|
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.Status);
|
||||||
|
Assert.True(result.Value.IsHidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -681,6 +720,7 @@ public class FileServiceTests
|
|||||||
_mockEnvironmentContext.FileProviderService.GetCreationTime(movedFilePathId)
|
_mockEnvironmentContext.FileProviderService.GetCreationTime(movedFilePathId)
|
||||||
.Returns(Optional<DateTime>.FromNullable(DateTime.Now.AddDays(-1)));
|
.Returns(Optional<DateTime>.FromNullable(DateTime.Now.AddDays(-1)));
|
||||||
_mockEnvironmentContext.FileProviderService.GetSize(movedFilePathId).Returns((long?)1024);
|
_mockEnvironmentContext.FileProviderService.GetSize(movedFilePathId).Returns((long?)1024);
|
||||||
|
_mockEnvironmentContext.FileProviderService.IsHidden(movedFilePathId).Returns(true);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
Result<File> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
|
Result<File> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
|
||||||
@@ -690,6 +730,7 @@ public class FileServiceTests
|
|||||||
Assert.NotNull(result.Value);
|
Assert.NotNull(result.Value);
|
||||||
Assert.Equal("file.txt", result.Value.Name);
|
Assert.Equal("file.txt", result.Value.Name);
|
||||||
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
|
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
|
||||||
|
Assert.True(result.Value.IsHidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -757,6 +798,7 @@ public class FileServiceTests
|
|||||||
_mockEnvironmentContext.FileProviderService.GetLastWriteTime(movedFilePathId).Returns(Errors.Permission.UnauthorizedAccess);
|
_mockEnvironmentContext.FileProviderService.GetLastWriteTime(movedFilePathId).Returns(Errors.Permission.UnauthorizedAccess);
|
||||||
_mockEnvironmentContext.FileProviderService.GetCreationTime(movedFilePathId).Returns(Errors.Permission.UnauthorizedAccess);
|
_mockEnvironmentContext.FileProviderService.GetCreationTime(movedFilePathId).Returns(Errors.Permission.UnauthorizedAccess);
|
||||||
_mockEnvironmentContext.FileProviderService.GetSize(movedFilePathId).Returns(Result.From((long?)null));
|
_mockEnvironmentContext.FileProviderService.GetSize(movedFilePathId).Returns(Result.From((long?)null));
|
||||||
|
_mockEnvironmentContext.FileProviderService.IsHidden(movedFilePathId).Returns(true);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
Result<File> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
|
Result<File> result = _sut.MoveFile(sourcePath, destinationPath, overrideExisting);
|
||||||
@@ -765,6 +807,7 @@ public class FileServiceTests
|
|||||||
Assert.False(result.IsFailure);
|
Assert.False(result.IsFailure);
|
||||||
Assert.NotNull(result.Value);
|
Assert.NotNull(result.Value);
|
||||||
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.Status);
|
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.Status);
|
||||||
|
Assert.True(result.Value.IsHidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -971,6 +1014,7 @@ public class FileServiceTests
|
|||||||
_mockEnvironmentContext.FileProviderService.GetCreationTime(newPathId)
|
_mockEnvironmentContext.FileProviderService.GetCreationTime(newPathId)
|
||||||
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now.AddDays(-1))));
|
.Returns(Result.From(Optional<DateTime>.FromNullable(DateTime.Now.AddDays(-1))));
|
||||||
_mockEnvironmentContext.FileProviderService.GetSize(newPathId).Returns(Result.From((long?)1024));
|
_mockEnvironmentContext.FileProviderService.GetSize(newPathId).Returns(Result.From((long?)1024));
|
||||||
|
_mockEnvironmentContext.FileProviderService.IsHidden(newPathId).Returns(true);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
Result<File> result = _sut.RenameFile(path, newName);
|
Result<File> result = _sut.RenameFile(path, newName);
|
||||||
@@ -980,6 +1024,7 @@ public class FileServiceTests
|
|||||||
Assert.NotNull(result.Value);
|
Assert.NotNull(result.Value);
|
||||||
Assert.Equal(newName, result.Value.Name);
|
Assert.Equal(newName, result.Value.Name);
|
||||||
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
|
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
|
||||||
|
Assert.True(result.Value.IsHidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -1047,6 +1092,7 @@ public class FileServiceTests
|
|||||||
_mockEnvironmentContext.FileProviderService.GetLastWriteTime(newPathId).Returns(Errors.Permission.UnauthorizedAccess);
|
_mockEnvironmentContext.FileProviderService.GetLastWriteTime(newPathId).Returns(Errors.Permission.UnauthorizedAccess);
|
||||||
_mockEnvironmentContext.FileProviderService.GetCreationTime(newPathId).Returns(Errors.Permission.UnauthorizedAccess);
|
_mockEnvironmentContext.FileProviderService.GetCreationTime(newPathId).Returns(Errors.Permission.UnauthorizedAccess);
|
||||||
_mockEnvironmentContext.FileProviderService.GetSize(newPathId).Returns(Result.From((long?)null));
|
_mockEnvironmentContext.FileProviderService.GetSize(newPathId).Returns(Result.From((long?)null));
|
||||||
|
_mockEnvironmentContext.FileProviderService.IsHidden(newPathId).Returns(true);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
Result<File> result = _sut.RenameFile(path, newName);
|
Result<File> result = _sut.RenameFile(path, newName);
|
||||||
@@ -1055,6 +1101,7 @@ public class FileServiceTests
|
|||||||
Assert.False(result.IsFailure);
|
Assert.False(result.IsFailure);
|
||||||
Assert.NotNull(result.Value);
|
Assert.NotNull(result.Value);
|
||||||
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.Status);
|
Assert.Equal(FileSystemItemStatus.Inaccessible, result.Value.Status);
|
||||||
|
Assert.True(result.Value.IsHidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|||||||
Reference in new issue
Block a user