mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 07:11:10 +00:00
Standardizes the remaining boolean names across the stack
This commit is contained in:
1 parent
3e0c3b624f
commit
39f4a04459
40 files changed
+1062
-448
No files matched your search
+14
-15
@@ -29,7 +29,6 @@ public class GetDirectoriesEndpointTests : IClassFixture<AuthenticatedLuminaApiF
|
||||
private readonly FileSystemStructureFixture _fileSystemStructureFixture = new();
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
ReferenceHandler = ReferenceHandler.Preserve,
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
@@ -54,18 +53,18 @@ public class GetDirectoriesEndpointTests : IClassFixture<AuthenticatedLuminaApiF
|
||||
}
|
||||
|
||||
[SkipWhenHiddenAttributeNotSupportedFact]
|
||||
public async Task GetDirectories_WhenCalledWithValidPathAndHiddenChildrenAndNotIncludeHiddenElements_ShouldReturnNoDirectories()
|
||||
public async Task GetDirectories_WhenCalledWithValidPathAndHiddenChildrenAndNotShouldIncludeHiddenElements_ShouldReturnNoDirectories()
|
||||
{
|
||||
// Arrange
|
||||
string testPath = _fileSystemStructureFixture.CreateFileSystemStructure();
|
||||
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
|
||||
string encodedPath = Uri.EscapeDataString(testPath);
|
||||
bool includeHiddenElements = false;
|
||||
bool shouldIncludeHiddenElements = false;
|
||||
try
|
||||
{
|
||||
// Act
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/directories/get-directories?path={encodedPath}&includeHiddenElements={includeHiddenElements}");
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/directories/get-directories?path={encodedPath}&shouldIncludeHiddenElements={shouldIncludeHiddenElements}");
|
||||
|
||||
// Assert
|
||||
string content = await response.Content.ReadAsStringAsync();
|
||||
@@ -84,18 +83,18 @@ public class GetDirectoriesEndpointTests : IClassFixture<AuthenticatedLuminaApiF
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetDirectories_WhenCalledWithValidPathAndWithIncludeHiddenElements_ShouldReturnDirectoriesWithHiddenElements()
|
||||
public async Task GetDirectories_WhenCalledWithValidPathAndWithShouldIncludeHiddenElements_ShouldReturnDirectoriesWithHiddenElements()
|
||||
{
|
||||
// Arrange
|
||||
string testPath = _fileSystemStructureFixture.CreateFileSystemStructure();
|
||||
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
|
||||
string encodedPath = Uri.EscapeDataString(testPath);
|
||||
bool includeHiddenElements = true;
|
||||
bool shouldIncludeHiddenElements = true;
|
||||
try
|
||||
{
|
||||
// Act
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/directories/get-directories?path={encodedPath}&includeHiddenElements={includeHiddenElements}");
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/directories/get-directories?path={encodedPath}&shouldIncludeHiddenElements={shouldIncludeHiddenElements}");
|
||||
|
||||
// Assert
|
||||
response.EnsureSuccessStatusCode();
|
||||
@@ -127,10 +126,10 @@ public class GetDirectoriesEndpointTests : IClassFixture<AuthenticatedLuminaApiF
|
||||
// Arrange
|
||||
string invalidPath = "invalid:path";
|
||||
string encodedPath = Uri.EscapeDataString(invalidPath);
|
||||
bool includeHiddenElements = true;
|
||||
bool shouldIncludeHiddenElements = true;
|
||||
|
||||
// Act
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/directories/get-directories?path={encodedPath}&includeHiddenElements={includeHiddenElements}");
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/directories/get-directories?path={encodedPath}&shouldIncludeHiddenElements={shouldIncludeHiddenElements}");
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
|
||||
@@ -153,10 +152,10 @@ public class GetDirectoriesEndpointTests : IClassFixture<AuthenticatedLuminaApiF
|
||||
// Arrange
|
||||
string emptyPath = "";
|
||||
string encodedPath = Uri.EscapeDataString(emptyPath);
|
||||
bool includeHiddenElements = true;
|
||||
bool shouldIncludeHiddenElements = true;
|
||||
|
||||
// Act
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/directories/get-directories?path={encodedPath}&includeHiddenElements={includeHiddenElements}");
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/directories/get-directories?path={encodedPath}&shouldIncludeHiddenElements={shouldIncludeHiddenElements}");
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.UnprocessableContent, response.StatusCode);
|
||||
@@ -184,12 +183,12 @@ public class GetDirectoriesEndpointTests : IClassFixture<AuthenticatedLuminaApiF
|
||||
// Arrange
|
||||
string testPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "testDirectory");
|
||||
string encodedPath = Uri.EscapeDataString(testPath);
|
||||
bool includeHiddenElements = true;
|
||||
bool shouldIncludeHiddenElements = true;
|
||||
using CancellationTokenSource cts = new(TimeSpan.FromSeconds(5));
|
||||
|
||||
// Act & Assert
|
||||
Exception? exception = await Record.ExceptionAsync(async () =>
|
||||
await _client.GetAsync($"/api/v1/directories/get-directories?path={encodedPath}&includeHiddenElements={includeHiddenElements}", cts.Token)
|
||||
await _client.GetAsync($"/api/v1/directories/get-directories?path={encodedPath}&shouldIncludeHiddenElements={shouldIncludeHiddenElements}", cts.Token)
|
||||
);
|
||||
Assert.Null(exception);
|
||||
}
|
||||
@@ -200,14 +199,14 @@ public class GetDirectoriesEndpointTests : IClassFixture<AuthenticatedLuminaApiF
|
||||
// Arrange
|
||||
string testPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "testDirectory");
|
||||
string encodedPath = Uri.EscapeDataString(testPath);
|
||||
bool includeHiddenElements = true;
|
||||
bool shouldIncludeHiddenElements = true;
|
||||
using CancellationTokenSource cts = new();
|
||||
|
||||
// Act & Assert
|
||||
await Assert.ThrowsAsync<TaskCanceledException>(async () =>
|
||||
{
|
||||
cts.Cancel();
|
||||
await _client.GetAsync($"/api/v1/directories/get-directories?path={encodedPath}&includeHiddenElements={includeHiddenElements}", cts.Token);
|
||||
await _client.GetAsync($"/api/v1/directories/get-directories?path={encodedPath}&shouldIncludeHiddenElements={shouldIncludeHiddenElements}", cts.Token);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+17
-18
@@ -29,7 +29,6 @@ public class GetFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory
|
||||
private readonly FileSystemStructureFixture _fileSystemStructureFixture = new();
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
ReferenceHandler = ReferenceHandler.Preserve,
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
@@ -54,16 +53,16 @@ public class GetFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory
|
||||
}
|
||||
|
||||
[SkipWhenHiddenAttributeNotSupportedFact]
|
||||
public async Task GetFiles_WhenCalledWithValidPathAndNotIncludeHiddenElements_ShouldReturnFilesWithoutHiddenElements()
|
||||
public async Task GetFiles_WhenCalledWithValidPathAndNotShouldIncludeHiddenElements_ShouldReturnFilesWithoutHiddenElements()
|
||||
{
|
||||
// Arrange
|
||||
string testPath = _fileSystemStructureFixture.CreateFileSystemStructure();
|
||||
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath;
|
||||
bool includeHiddenElements = false;
|
||||
bool shouldIncludeHiddenElements = false;
|
||||
try
|
||||
{
|
||||
// Act
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/files/get-files?path={Uri.EscapeDataString(testPath)}&includeHiddenElements={includeHiddenElements}");
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/files/get-files?path={Uri.EscapeDataString(testPath)}&shouldIncludeHiddenElements={shouldIncludeHiddenElements}");
|
||||
|
||||
// Assert
|
||||
response.EnsureSuccessStatusCode();
|
||||
@@ -90,17 +89,17 @@ public class GetFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory
|
||||
}
|
||||
|
||||
[SkipWhenHiddenAttributeNotSupportedFact]
|
||||
public async Task GetFiles_WhenCalledWithValidPathAndHiddenChildrenAndNotIncludeHiddenElements_ShouldReturnNoFiles()
|
||||
public async Task GetFiles_WhenCalledWithValidPathAndHiddenChildrenAndNotShouldIncludeHiddenElements_ShouldReturnNoFiles()
|
||||
{
|
||||
// Arrange
|
||||
string testPath = _fileSystemStructureFixture.CreateFileSystemStructure();
|
||||
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
|
||||
bool includeHiddenElements = false;
|
||||
bool shouldIncludeHiddenElements = false;
|
||||
try
|
||||
{
|
||||
// Act
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/files/get-files?path={Uri.EscapeDataString(testPath)}&includeHiddenElements={includeHiddenElements}");
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/files/get-files?path={Uri.EscapeDataString(testPath)}&shouldIncludeHiddenElements={shouldIncludeHiddenElements}");
|
||||
|
||||
// Assert
|
||||
response.EnsureSuccessStatusCode();
|
||||
@@ -121,17 +120,17 @@ public class GetFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetFiles_WhenCalledWithValidPathAndWithIncludeHiddenElements_ShouldReturnFilesWithHiddenElements()
|
||||
public async Task GetFiles_WhenCalledWithValidPathAndWithShouldIncludeHiddenElements_ShouldReturnFilesWithHiddenElements()
|
||||
{
|
||||
// Arrange
|
||||
string testPath = _fileSystemStructureFixture.CreateFileSystemStructure();
|
||||
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
|
||||
bool includeHiddenElements = true;
|
||||
bool shouldIncludeHiddenElements = true;
|
||||
try
|
||||
{
|
||||
// Act
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/files/get-files?path={Uri.EscapeDataString(testPath)}&includeHiddenElements={includeHiddenElements}");
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/files/get-files?path={Uri.EscapeDataString(testPath)}&shouldIncludeHiddenElements={shouldIncludeHiddenElements}");
|
||||
|
||||
// Assert
|
||||
response.EnsureSuccessStatusCode();
|
||||
@@ -166,10 +165,10 @@ public class GetFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory
|
||||
// Arrange
|
||||
string invalidPath = "invalid:path";
|
||||
string encodedPath = Uri.EscapeDataString(invalidPath);
|
||||
bool includeHiddenElements = true;
|
||||
bool shouldIncludeHiddenElements = true;
|
||||
|
||||
// Act
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/files/get-files?path={encodedPath}&includeHiddenElements={includeHiddenElements}");
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/files/get-files?path={encodedPath}&shouldIncludeHiddenElements={shouldIncludeHiddenElements}");
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
|
||||
@@ -192,10 +191,10 @@ public class GetFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory
|
||||
// Arrange
|
||||
string emptyPath = "";
|
||||
string encodedPath = Uri.EscapeDataString(emptyPath);
|
||||
bool includeHiddenElements = true;
|
||||
bool shouldIncludeHiddenElements = true;
|
||||
|
||||
// Act
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/files/get-files?path={encodedPath}&includeHiddenElements={includeHiddenElements}");
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/files/get-files?path={encodedPath}&shouldIncludeHiddenElements={shouldIncludeHiddenElements}");
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.UnprocessableContent, response.StatusCode);
|
||||
@@ -223,12 +222,12 @@ public class GetFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory
|
||||
// Arrange
|
||||
string testPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "testDirectory");
|
||||
string encodedPath = Uri.EscapeDataString(testPath);
|
||||
bool includeHiddenElements = true;
|
||||
bool shouldIncludeHiddenElements = true;
|
||||
using CancellationTokenSource cts = new(TimeSpan.FromSeconds(5));
|
||||
|
||||
// Act & Assert
|
||||
Exception? exception = await Record.ExceptionAsync(async () =>
|
||||
await _client.GetAsync($"/api/v1/files/get-files?path={encodedPath}&includeHiddenElements={includeHiddenElements}", cts.Token)
|
||||
await _client.GetAsync($"/api/v1/files/get-files?path={encodedPath}&shouldIncludeHiddenElements={shouldIncludeHiddenElements}", cts.Token)
|
||||
);
|
||||
Assert.Null(exception);
|
||||
}
|
||||
@@ -239,14 +238,14 @@ public class GetFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory
|
||||
// Arrange
|
||||
string testPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "testDirectory");
|
||||
string encodedPath = Uri.EscapeDataString(testPath);
|
||||
bool includeHiddenElements = true;
|
||||
bool shouldIncludeHiddenElements = true;
|
||||
using CancellationTokenSource cts = new();
|
||||
|
||||
// Act & Assert
|
||||
Exception? exception = await Record.ExceptionAsync(async () =>
|
||||
{
|
||||
cts.Cancel();
|
||||
await _client.GetAsync($"/api/v1/files/get-files?path={encodedPath}&includeHiddenElements={includeHiddenElements}", cts.Token);
|
||||
await _client.GetAsync($"/api/v1/files/get-files?path={encodedPath}&shouldIncludeHiddenElements={shouldIncludeHiddenElements}", cts.Token);
|
||||
});
|
||||
Assert.IsType<TaskCanceledException>(exception);
|
||||
}
|
||||
|
||||
+17
-18
@@ -29,7 +29,6 @@ public class GetTreeFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFac
|
||||
private readonly FileSystemStructureFixture _fileSystemStructureFixture = new();
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
ReferenceHandler = ReferenceHandler.Preserve,
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
@@ -54,16 +53,16 @@ public class GetTreeFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFac
|
||||
}
|
||||
|
||||
[SkipWhenHiddenAttributeNotSupportedFact]
|
||||
public async Task GetTreeFiles_WhenCalledWithValidPathAndNotIncludeHiddenElements_ShouldReturnTreeFilesWithoutHiddenElements()
|
||||
public async Task GetTreeFiles_WhenCalledWithValidPathAndNotShouldIncludeHiddenElements_ShouldReturnTreeFilesWithoutHiddenElements()
|
||||
{
|
||||
// Arrange
|
||||
string testPath = _fileSystemStructureFixture.CreateFileSystemStructure();
|
||||
testPath = System.IO.Path.GetDirectoryName(testPath) ?? testPath;
|
||||
bool includeHiddenElements = false;
|
||||
bool shouldIncludeHiddenElements = false;
|
||||
try
|
||||
{
|
||||
// Act
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/files/get-tree-files?path={Uri.EscapeDataString(testPath)}&includeHiddenElements={includeHiddenElements}");
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/files/get-tree-files?path={Uri.EscapeDataString(testPath)}&shouldIncludeHiddenElements={shouldIncludeHiddenElements}");
|
||||
|
||||
// Assert
|
||||
response.EnsureSuccessStatusCode();
|
||||
@@ -90,17 +89,17 @@ public class GetTreeFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFac
|
||||
}
|
||||
|
||||
[SkipWhenHiddenAttributeNotSupportedFact]
|
||||
public async Task GetTreeFiles_WhenCalledWithValidPathAndHiddenChildrenAndNotIncludeHiddenElements_ShouldReturnNoTreeFiles()
|
||||
public async Task GetTreeFiles_WhenCalledWithValidPathAndHiddenChildrenAndNotShouldIncludeHiddenElements_ShouldReturnNoTreeFiles()
|
||||
{
|
||||
// Arrange
|
||||
string testPath = _fileSystemStructureFixture.CreateFileSystemStructure();
|
||||
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
|
||||
bool includeHiddenElements = false;
|
||||
bool shouldIncludeHiddenElements = false;
|
||||
try
|
||||
{
|
||||
// Act
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/files/get-tree-files?path={Uri.EscapeDataString(testPath)}&includeHiddenElements={includeHiddenElements}");
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/files/get-tree-files?path={Uri.EscapeDataString(testPath)}&shouldIncludeHiddenElements={shouldIncludeHiddenElements}");
|
||||
|
||||
// Assert
|
||||
response.EnsureSuccessStatusCode();
|
||||
@@ -122,17 +121,17 @@ public class GetTreeFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFac
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetTreeFiles_WhenCalledWithValidPathAndWithIncludeHiddenElements_ShouldReturnTreeFilesWithHiddenElements()
|
||||
public async Task GetTreeFiles_WhenCalledWithValidPathAndWithShouldIncludeHiddenElements_ShouldReturnTreeFilesWithHiddenElements()
|
||||
{
|
||||
// Arrange
|
||||
string testPath = _fileSystemStructureFixture.CreateFileSystemStructure();
|
||||
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
|
||||
bool includeHiddenElements = true;
|
||||
bool shouldIncludeHiddenElements = true;
|
||||
try
|
||||
{
|
||||
// Act
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/files/get-tree-files?path={Uri.EscapeDataString(testPath)}&includeHiddenElements={includeHiddenElements}");
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/files/get-tree-files?path={Uri.EscapeDataString(testPath)}&shouldIncludeHiddenElements={shouldIncludeHiddenElements}");
|
||||
|
||||
// Assert
|
||||
response.EnsureSuccessStatusCode();
|
||||
@@ -166,10 +165,10 @@ public class GetTreeFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFac
|
||||
// Arrange
|
||||
string invalidPath = "invalid:path";
|
||||
string encodedPath = Uri.EscapeDataString(invalidPath);
|
||||
bool includeHiddenElements = true;
|
||||
bool shouldIncludeHiddenElements = true;
|
||||
|
||||
// Act
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/files/get-tree-files?path={encodedPath}&includeHiddenElements={includeHiddenElements}");
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/files/get-tree-files?path={encodedPath}&shouldIncludeHiddenElements={shouldIncludeHiddenElements}");
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
|
||||
@@ -192,10 +191,10 @@ public class GetTreeFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFac
|
||||
// Arrange
|
||||
string emptyPath = "";
|
||||
string encodedPath = Uri.EscapeDataString(emptyPath);
|
||||
bool includeHiddenElements = true;
|
||||
bool shouldIncludeHiddenElements = true;
|
||||
|
||||
// Act
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/files/get-tree-files?path={encodedPath}&includeHiddenElements={includeHiddenElements}");
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/files/get-tree-files?path={encodedPath}&shouldIncludeHiddenElements={shouldIncludeHiddenElements}");
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.UnprocessableContent, response.StatusCode);
|
||||
@@ -223,12 +222,12 @@ public class GetTreeFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFac
|
||||
// Arrange
|
||||
string testPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "testDirectory");
|
||||
string encodedPath = Uri.EscapeDataString(testPath);
|
||||
bool includeHiddenElements = true;
|
||||
bool shouldIncludeHiddenElements = true;
|
||||
using CancellationTokenSource cts = new(TimeSpan.FromSeconds(5));
|
||||
|
||||
// Act & Assert
|
||||
Exception? exception = await Record.ExceptionAsync(async () =>
|
||||
await _client.GetAsync($"/api/v1/files/get-tree-files?path={encodedPath}&includeHiddenElements={includeHiddenElements}", cts.Token)
|
||||
await _client.GetAsync($"/api/v1/files/get-tree-files?path={encodedPath}&shouldIncludeHiddenElements={shouldIncludeHiddenElements}", cts.Token)
|
||||
);
|
||||
Assert.Null(exception);
|
||||
}
|
||||
@@ -239,14 +238,14 @@ public class GetTreeFilesEndpointTests : IClassFixture<AuthenticatedLuminaApiFac
|
||||
// Arrange
|
||||
string testPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "testDirectory");
|
||||
string encodedPath = Uri.EscapeDataString(testPath);
|
||||
bool includeHiddenElements = true;
|
||||
bool shouldIncludeHiddenElements = true;
|
||||
using CancellationTokenSource cts = new();
|
||||
|
||||
// Act & Assert
|
||||
Exception? exception = await Record.ExceptionAsync(async () =>
|
||||
{
|
||||
cts.Cancel();
|
||||
await _client.GetAsync($"/api/v1/files/get-tree-files?path={encodedPath}&includeHiddenElements={includeHiddenElements}", cts.Token);
|
||||
await _client.GetAsync($"/api/v1/files/get-tree-files?path={encodedPath}&shouldIncludeHiddenElements={shouldIncludeHiddenElements}", cts.Token);
|
||||
});
|
||||
Assert.IsType<TaskCanceledException>(exception);
|
||||
}
|
||||
|
||||
+5
-6
@@ -25,7 +25,6 @@ public class CheckPathExistsEndpointTests : IClassFixture<AuthenticatedLuminaApi
|
||||
private readonly AuthenticatedLuminaApiFactory _apiFactory;
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
ReferenceHandler = ReferenceHandler.Preserve,
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
@@ -55,7 +54,7 @@ public class CheckPathExistsEndpointTests : IClassFixture<AuthenticatedLuminaApi
|
||||
string tempPath = System.IO.Path.GetTempPath();
|
||||
|
||||
// Act
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/path/check-path-exists?path={Uri.EscapeDataString(tempPath)}&includeHiddenElements=false");
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/path/check-path-exists?path={Uri.EscapeDataString(tempPath)}&shouldIncludeHiddenElements=false");
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
@@ -72,7 +71,7 @@ public class CheckPathExistsEndpointTests : IClassFixture<AuthenticatedLuminaApi
|
||||
string nonExistingPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
|
||||
// Act
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/path/check-path-exists?path={Uri.EscapeDataString(nonExistingPath)}&includeHiddenElements=false");
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/path/check-path-exists?path={Uri.EscapeDataString(nonExistingPath)}&shouldIncludeHiddenElements=false");
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
@@ -89,7 +88,7 @@ public class CheckPathExistsEndpointTests : IClassFixture<AuthenticatedLuminaApi
|
||||
string path = "";
|
||||
|
||||
// Act
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/path/check-path-exists?path={Uri.EscapeDataString(path)}&includeHiddenElements=false");
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/path/check-path-exists?path={Uri.EscapeDataString(path)}&shouldIncludeHiddenElements=false");
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.UnprocessableContent, response.StatusCode);
|
||||
@@ -117,7 +116,7 @@ public class CheckPathExistsEndpointTests : IClassFixture<AuthenticatedLuminaApi
|
||||
string invalidPath = "invalid:path";
|
||||
|
||||
// Act
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/path/check-path-exists?path={Uri.EscapeDataString(invalidPath)}&includeHiddenElements=false");
|
||||
HttpResponseMessage response = await _client.GetAsync($"/api/v1/path/check-path-exists?path={Uri.EscapeDataString(invalidPath)}&shouldIncludeHiddenElements=false");
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
@@ -139,7 +138,7 @@ public class CheckPathExistsEndpointTests : IClassFixture<AuthenticatedLuminaApi
|
||||
Exception? exception = await Record.ExceptionAsync(async () =>
|
||||
{
|
||||
cts.Cancel();
|
||||
await _client.GetAsync($"/api/v1/path/check-path-exists?path={encodedPath}&includeHiddenElements=false", cts.Token);
|
||||
await _client.GetAsync($"/api/v1/path/check-path-exists?path={encodedPath}&shouldIncludeHiddenElements=false", cts.Token);
|
||||
});
|
||||
Assert.IsType<TaskCanceledException>(exception);
|
||||
}
|
||||
|
||||
+4
-4
@@ -76,11 +76,11 @@ public class GetDirectoriesQueryValidatorTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Validate_WhenIncludeHiddenElementsIsTrue_ShouldNotHaveValidationError()
|
||||
public void Validate_WhenShouldIncludeHiddenElementsIsTrue_ShouldNotHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
GetDirectoriesQuery query = _getDirectoriesQueryFixture.Create();
|
||||
query = query with { IncludeHiddenElements = true };
|
||||
query = query with { ShouldIncludeHiddenElements = true };
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(query);
|
||||
@@ -90,11 +90,11 @@ public class GetDirectoriesQueryValidatorTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Validate_WhenIncludeHiddenElementsIsFalse_ShouldNotHaveValidationError()
|
||||
public void Validate_WhenShouldIncludeHiddenElementsIsFalse_ShouldNotHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
GetDirectoriesQuery query = _getDirectoriesQueryFixture.Create();
|
||||
query = query with { IncludeHiddenElements = false };
|
||||
query = query with { ShouldIncludeHiddenElements = false };
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(query);
|
||||
|
||||
+4
-4
@@ -76,11 +76,11 @@ public class GetFilesQueryValidatorTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Validate_WhenIncludeHiddenElementsIsTrue_ShouldNotHaveValidationError()
|
||||
public void Validate_WhenShouldIncludeHiddenElementsIsTrue_ShouldNotHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
GetFilesQuery query = _getFilesQueryFixture.Create();
|
||||
query = query with { IncludeHiddenElements = true };
|
||||
query = query with { ShouldIncludeHiddenElements = true };
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(query);
|
||||
@@ -90,11 +90,11 @@ public class GetFilesQueryValidatorTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Validate_WhenIncludeHiddenElementsIsFalse_ShouldNotHaveValidationError()
|
||||
public void Validate_WhenShouldIncludeHiddenElementsIsFalse_ShouldNotHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
GetFilesQuery query = _getFilesQueryFixture.Create();
|
||||
query = query with { IncludeHiddenElements = false };
|
||||
query = query with { ShouldIncludeHiddenElements = false };
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(query);
|
||||
|
||||
+4
-4
@@ -76,11 +76,11 @@ public class GetTreeFilesQueryValidatorTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Validate_WhenIncludeHiddenElementsIsTrue_ShouldNotHaveValidationError()
|
||||
public void Validate_WhenShouldIncludeHiddenElementsIsTrue_ShouldNotHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
GetTreeFilesQuery query = _getTreeFilesQueryFixture.Create();
|
||||
query = query with { IncludeHiddenElements = true };
|
||||
query = query with { ShouldIncludeHiddenElements = true };
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(query);
|
||||
@@ -90,11 +90,11 @@ public class GetTreeFilesQueryValidatorTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Validate_WhenIncludeHiddenElementsIsFalse_ShouldNotHaveValidationError()
|
||||
public void Validate_WhenShouldIncludeHiddenElementsIsFalse_ShouldNotHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
GetTreeFilesQuery query = _getTreeFilesQueryFixture.Create();
|
||||
query = query with { IncludeHiddenElements = false };
|
||||
query = query with { ShouldIncludeHiddenElements = false };
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(query);
|
||||
|
||||
+4
-4
@@ -52,10 +52,10 @@ public class CheckPathExistsQueryHandlerTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task HandleAsync_WhenPathExistsAndIsHiddenAndIncludeHiddenElementsIsTrue_ShouldReturnTrueResponse()
|
||||
public async Task HandleAsync_WhenPathExistsAndIsHiddenAndShouldIncludeHiddenElementsIsTrue_ShouldReturnTrueResponse()
|
||||
{
|
||||
// Arrange
|
||||
CheckPathExistsQuery query = _checkPathExistsQueryFixture.Create(includeHiddenElements: true);
|
||||
CheckPathExistsQuery query = _checkPathExistsQueryFixture.Create(shouldIncludeHiddenElements: true);
|
||||
_mockPathService.Exists(query.Path!).Returns(true);
|
||||
|
||||
// Act
|
||||
@@ -68,10 +68,10 @@ public class CheckPathExistsQueryHandlerTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task HandleAsync_WhenPathExistsAndIsHiddenAndIncludeHiddenElementsIsFalse_ShouldReturnFalseResponse()
|
||||
public async Task HandleAsync_WhenPathExistsAndIsHiddenAndShouldIncludeHiddenElementsIsFalse_ShouldReturnFalseResponse()
|
||||
{
|
||||
// Arrange
|
||||
CheckPathExistsQuery query = _checkPathExistsQueryFixture.Create(includeHiddenElements: false);
|
||||
CheckPathExistsQuery query = _checkPathExistsQueryFixture.Create(shouldIncludeHiddenElements: false);
|
||||
_mockPathService.Exists(query.Path!, false).Returns(false);
|
||||
|
||||
// Act
|
||||
|
||||
+2
-2
@@ -105,7 +105,7 @@ public class DirectoryProviderServiceTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetSubdirectoryPaths_WhenIncludeHiddenElementsIsFalse_ShouldExcludeHiddenDirectories()
|
||||
public void GetSubdirectoryPaths_WhenShouldIncludeHiddenElementsIsFalse_ShouldExcludeHiddenDirectories()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
@@ -126,7 +126,7 @@ public class DirectoryProviderServiceTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetSubdirectoryPaths_WhenIncludeHiddenElementsIsTrue_ShouldIncludeHiddenDirectories()
|
||||
public void GetSubdirectoryPaths_WhenShouldIncludeHiddenElementsIsTrue_ShouldIncludeHiddenDirectories()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
|
||||
+2
-2
@@ -89,7 +89,7 @@ public class FileProviderServiceTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetFilePaths_WhenIncludeHiddenElementsIsFalse_ShouldExcludeHiddenFiles()
|
||||
public void GetFilePaths_WhenShouldIncludeHiddenElementsIsFalse_ShouldExcludeHiddenFiles()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
@@ -109,7 +109,7 @@ public class FileProviderServiceTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetFilePaths_WhenIncludeHiddenElementsIsTrue_ShouldIncludeHiddenFiles()
|
||||
public void GetFilePaths_WhenShouldIncludeHiddenElementsIsTrue_ShouldIncludeHiddenFiles()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
|
||||
+48
-2
@@ -131,7 +131,7 @@ public class PathServiceTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Exists_WhenPathIsHiddenAndIncludeHiddenElementsIsTrue_ShouldReturnTrue()
|
||||
public void Exists_WhenPathIsHiddenAndShouldIncludeHiddenElementsIsTrue_ShouldReturnTrue()
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = @"C:\ExistingPath";
|
||||
@@ -147,7 +147,7 @@ public class PathServiceTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Exists_WhenPathIsHiddenAndIncludeHiddenElementsIsFalse_ShouldReturnFalse()
|
||||
public void Exists_WhenPathIsHiddenAndShouldIncludeHiddenElementsIsFalse_ShouldReturnFalse()
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = @"C:\ExistingPath";
|
||||
@@ -771,4 +771,50 @@ public class PathServiceTests
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(100, result.Value.Name.Length);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsPathWithin_WhenBothPathsAreValid_ShouldCreatePathIdsAndDelegateToTheStrategy()
|
||||
{
|
||||
// Arrange
|
||||
string path = @"C:\Media\Books\book.epub";
|
||||
string parentPath = @"C:\Media\Books";
|
||||
_mockPathStrategy.IsPathWithin(Arg.Any<FileSystemPathId>(), Arg.Any<FileSystemPathId>()).Returns(true);
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsPathWithin(path, parentPath);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
_mockPathStrategy.Received(1).IsPathWithin(
|
||||
Arg.Is<FileSystemPathId>(pathId => pathId.Path == path),
|
||||
Arg.Is<FileSystemPathId>(pathId => pathId.Path == parentPath));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
public void IsPathWithin_WhenPathIsNotValid_ShouldReturnFalseWithoutCallingTheStrategy(string? invalidPath)
|
||||
{
|
||||
// Act
|
||||
bool result = _sut.IsPathWithin(invalidPath!, @"C:\Media");
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
_mockPathStrategy.DidNotReceive().IsPathWithin(Arg.Any<FileSystemPathId>(), Arg.Any<FileSystemPathId>());
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
public void IsPathWithin_WhenParentPathIsNotValid_ShouldReturnFalseWithoutCallingTheStrategy(string? invalidParentPath)
|
||||
{
|
||||
// Act
|
||||
bool result = _sut.IsPathWithin(@"C:\Media\Books\book.epub", invalidParentPath!);
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
_mockPathStrategy.DidNotReceive().IsPathWithin(Arg.Any<FileSystemPathId>(), Arg.Any<FileSystemPathId>());
|
||||
}
|
||||
}
|
||||
+40
-2
@@ -120,7 +120,7 @@ public class UnixPathStrategyTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Exists_WhenPathExistsAndIsHiddenAndIncludeHiddenElementsIsTrue_ShouldReturnTrue()
|
||||
public void Exists_WhenPathExistsAndIsHiddenAndShouldIncludeHiddenElementsIsTrue_ShouldReturnTrue()
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = "/home/user/existing_file.txt";
|
||||
@@ -138,7 +138,7 @@ public class UnixPathStrategyTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Exists_WhenPathExistsAndIsHiddenAndIncludeHiddenElementsIsFalse_ShouldReturnFalse()
|
||||
public void Exists_WhenPathExistsAndIsHiddenAndShouldIncludeHiddenElementsIsFalse_ShouldReturnFalse()
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = "/home/user/existing_file.txt";
|
||||
@@ -596,4 +596,42 @@ public class UnixPathStrategyTests
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("/media/books", "/media/books/book.epub")] // direct child
|
||||
[InlineData("/media", "/media/books/book.epub")] // nested descendant
|
||||
[InlineData("/media/books/", "/media/books/book.epub")] // trailing separator on the parent
|
||||
[InlineData("/media/books", "/media/books/sub/../book.epub")] // relative segments that stay inside
|
||||
public void IsPathWithin_WithContainedPaths_ShouldReturnTrue(string parentPath, string path)
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.Create(parentPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsPathWithin(pathId, parentPathId);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("/media/books", "/media/book.epub")] // sibling directory
|
||||
[InlineData("/media/books", "/Media/Books/book.epub")] // Unix paths are case-sensitive
|
||||
[InlineData("/media/books", "/media/other/book.epub")] // sibling directory
|
||||
[InlineData("/media/books", "/media/books/../other/book.epub")] // relative segment that escapes the parent
|
||||
[InlineData("/media/books", "/etc/passwd")] // unrelated location
|
||||
[InlineData("/media", "/media")] // the parent itself is not inside itself
|
||||
public void IsPathWithin_WithPathsOutsideTheParent_ShouldReturnFalse(string parentPath, string path)
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.Create(parentPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsPathWithin(pathId, parentPathId);
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
}
|
||||
}
|
||||
+42
-2
@@ -148,7 +148,7 @@ public class WindowsPathStrategyTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Exists_WhenPathExistsAndIsHiddenAndIncludeHiddenElementsIsTrue_ShouldReturnTrue()
|
||||
public void Exists_WhenPathExistsAndIsHiddenAndShouldIncludeHiddenElementsIsTrue_ShouldReturnTrue()
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = @"C:\Users\User\existing_file.txt";
|
||||
@@ -165,7 +165,7 @@ public class WindowsPathStrategyTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Exists_WhenPathExistsAndIsHiddenAndIncludeHiddenElementsIsFalse_ShouldReturnFalse()
|
||||
public void Exists_WhenPathExistsAndIsHiddenAndShouldIncludeHiddenElementsIsFalse_ShouldReturnFalse()
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = @"C:\Users\User\existing_file.txt";
|
||||
@@ -811,4 +811,44 @@ public class WindowsPathStrategyTests
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(@"C:\Media\Books", @"C:\Media\Books\book.epub")] // direct child
|
||||
[InlineData(@"C:\Media", @"C:\Media\Books\book.epub")] // nested descendant
|
||||
[InlineData(@"C:\Media\Books\", @"C:\Media\Books\book.epub")] // trailing separator on the parent
|
||||
[InlineData(@"C:\Media\Books", @"c:\media\books\book.epub")] // Windows paths are case-insensitive
|
||||
[InlineData(@"C:\Media\Books", @"C:\Media\Books\Sub\..\book.epub")] // relative segments that stay inside
|
||||
public void IsPathWithin_WithContainedPaths_ShouldReturnTrue(string parentPath, string path)
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.Create(parentPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsPathWithin(pathId, parentPathId);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(@"C:\Media\Books", @"C:\Media\book.epub")] // sibling directory
|
||||
[InlineData(@"C:\Media\Books", @"D:\Media\Books\book.epub")] // different drive
|
||||
[InlineData(@"C:\Media\Books", @"C:\Media\BookShelf\book.epub")] // a sibling whose name shares the prefix
|
||||
[InlineData(@"C:\Media\Books", @"C:\Media\Other\book.epub")] // sibling directory
|
||||
[InlineData(@"C:\Media\Books", @"C:\Media\Books\..\Other\book.epub")] // relative segment that escapes the parent
|
||||
[InlineData(@"C:\Media\Books", @"C:\Windows\System32\config\SAM")] // unrelated location
|
||||
[InlineData(@"C:\Media", @"C:\Media")] // the parent itself is not inside itself
|
||||
public void IsPathWithin_WithPathsOutsideTheParent_ShouldReturnFalse(string parentPath, string path)
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.Create(parentPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsPathWithin(pathId, parentPathId);
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -60,7 +60,7 @@ public class GetDirectoriesEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetDirectoriesRequest request = _getDirectoriesRequestFixture.Create();
|
||||
@@ -86,7 +86,7 @@ public class GetDirectoriesEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationError_ShouldReturnValidationProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationErrors_ShouldReturnValidationProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetDirectoriesRequest request = _getDirectoriesRequestFixture.Create();
|
||||
@@ -112,7 +112,7 @@ public class GetDirectoriesEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetDirectoriesQueryToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendGetDirectoriesQueryToSender()
|
||||
{
|
||||
// Arrange
|
||||
GetDirectoriesRequest request = _getDirectoriesRequestFixture.Create();
|
||||
@@ -125,7 +125,7 @@ public class GetDirectoriesEndpointTests
|
||||
|
||||
// Assert
|
||||
await _mockHandler.Received(1).HandleAsync(
|
||||
Arg.Is<GetDirectoriesQuery>(q => q.Path == request.Path && q.IncludeHiddenElements == request.IncludeHiddenElements),
|
||||
Arg.Is<GetDirectoriesQuery>(q => q.Path == request.Path && q.ShouldIncludeHiddenElements == request.ShouldIncludeHiddenElements),
|
||||
Arg.Is(cancellationToken));
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -60,7 +60,7 @@ public class GetFilesEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetFilesRequest request = _getFilesRequestFixture.Create();
|
||||
@@ -86,7 +86,7 @@ public class GetFilesEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationError_ShouldReturnValidationProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationErrors_ShouldReturnValidationProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetFilesRequest request = _getFilesRequestFixture.Create();
|
||||
@@ -126,7 +126,7 @@ public class GetFilesEndpointTests
|
||||
// Assert
|
||||
await _mockHandler.Received(1).HandleAsync(Arg.Is<GetFilesQuery>(q =>
|
||||
q.Path == request.Path &&
|
||||
q.IncludeHiddenElements == request.IncludeHiddenElements),
|
||||
q.ShouldIncludeHiddenElements == request.ShouldIncludeHiddenElements),
|
||||
Arg.Is(cancellationToken));
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -60,7 +60,7 @@ public class GetTreeFilesEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsError_ShouldReturnProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsNotFoundError_ShouldReturnProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetTreeFilesRequest request = _getTreeFilesRequestFixture.Create();
|
||||
@@ -86,7 +86,7 @@ public class GetTreeFilesEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationError_ShouldReturnValidationProblemResult()
|
||||
public async Task ExecuteAsync_WhenHandlerReturnsValidationErrors_ShouldReturnValidationProblemResult()
|
||||
{
|
||||
// Arrange
|
||||
GetTreeFilesRequest request = _getTreeFilesRequestFixture.Create();
|
||||
@@ -126,7 +126,7 @@ public class GetTreeFilesEndpointTests
|
||||
// Assert
|
||||
await _mockHandler.Received(1).HandleAsync(Arg.Is<GetTreeFilesQuery>(q =>
|
||||
q.Path == request.Path &&
|
||||
q.IncludeHiddenElements == request.IncludeHiddenElements),
|
||||
q.ShouldIncludeHiddenElements == request.ShouldIncludeHiddenElements),
|
||||
Arg.Is(cancellationToken));
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -43,7 +43,7 @@ public class CheckPathExistsEndpointTests
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldReturnOkResultWithPathExistsResponse()
|
||||
{
|
||||
// Arrange
|
||||
CheckPathExistsRequest request = _checkPathExistsRequestFixture.Create(path: @"C:\Users\TestUser\Documents", includeHiddenElements: true);
|
||||
CheckPathExistsRequest request = _checkPathExistsRequestFixture.Create(path: @"C:\Users\TestUser\Documents", shouldIncludeHiddenElements: true);
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
PathExistsResponse expectedResponse = _pathExistsResponseFixture.Create(exists: true);
|
||||
_mockHandler.HandleAsync(Arg.Any<CheckPathExistsQuery>(), Arg.Any<CancellationToken>())
|
||||
@@ -58,10 +58,10 @@ public class CheckPathExistsEndpointTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendCheckPathExistsQueryToHandler()
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendCheckPathExistsQueryToSender()
|
||||
{
|
||||
// Arrange
|
||||
CheckPathExistsRequest request = _checkPathExistsRequestFixture.Create(path: @"C:\Users\TestUser\Documents", includeHiddenElements: true);
|
||||
CheckPathExistsRequest request = _checkPathExistsRequestFixture.Create(path: @"C:\Users\TestUser\Documents", shouldIncludeHiddenElements: true);
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
_mockHandler.HandleAsync(Arg.Any<CheckPathExistsQuery>(), Arg.Any<CancellationToken>())
|
||||
.Returns(_pathExistsResponseFixture.Create(exists: true));
|
||||
@@ -71,7 +71,7 @@ public class CheckPathExistsEndpointTests
|
||||
|
||||
// Assert
|
||||
await _mockHandler.Received(1).HandleAsync(
|
||||
Arg.Is<CheckPathExistsQuery>(q => q.Path == request.Path && q.IncludeHiddenElements == request.IncludeHiddenElements),
|
||||
Arg.Is<CheckPathExistsQuery>(q => q.Path == request.Path && q.ShouldIncludeHiddenElements == request.ShouldIncludeHiddenElements),
|
||||
Arg.Is(cancellationToken));
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class CheckPathExistsEndpointTests
|
||||
public async Task ExecuteAsync_WhenCancellationRequested_ShouldCancelOperation()
|
||||
{
|
||||
// Arrange
|
||||
CheckPathExistsRequest request = _checkPathExistsRequestFixture.Create(path: @"C:\Users\TestUser\Documents", includeHiddenElements: true);
|
||||
CheckPathExistsRequest request = _checkPathExistsRequestFixture.Create(path: @"C:\Users\TestUser\Documents", shouldIncludeHiddenElements: true);
|
||||
CancellationTokenSource cts = new();
|
||||
TaskCompletionSource<bool> operationStarted = new();
|
||||
TaskCompletionSource<bool> cancellationRequested = new();
|
||||
|
||||
Reference in new issue
Block a user