diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Controllers/FileManagement/DirectoriesControllerTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Controllers/FileManagement/DirectoriesControllerTests.cs index 02be4ed8..77df7b0b 100644 --- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Controllers/FileManagement/DirectoriesControllerTests.cs +++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Controllers/FileManagement/DirectoriesControllerTests.cs @@ -362,52 +362,6 @@ public class DirectoriesControllerTests : IClassFixture } } - [Fact] - public async Task GetDirectoryTree_WhenCancellationIsRequested_ShouldStopYieldingResults() - { - // Arrange - FileSystemStructureFixture fileSystemFixture = new(); - string testPath = fileSystemFixture.CreateFileSystemStructure(); - - bool includeFiles = true; - bool includeHiddenElements = false; - CancellationTokenSource cts = new(); - - try - { - // Act - Task getDirectoryTreeTask = _client.GetAsync( - $"/api/v1/directories/get-directory-tree?path={Uri.EscapeDataString(testPath)}&includeFiles={includeFiles}&includeHiddenElements={includeHiddenElements}", - cts.Token - ); - - // simulate cancellation before the request completes - cts.Cancel(); - - HttpResponseMessage? response = null; - try - { - response = await getDirectoryTreeTask; - } - catch (TaskCanceledException) - { - // expected when the task is cancelled, suppress the exception to continue the test - } - // Assert - response?.StatusCode.Should().Be(HttpStatusCode.OK, "The cancellation should occur gracefully on the server side"); - - // assert that no elements were returned after cancellation - if (response != null) - using (Stream stream = await response.Content.ReadAsStreamAsync()) - using (JsonDocument jsonDoc = await JsonDocument.ParseAsync(stream)) - jsonDoc.RootElement.GetArrayLength().Should().Be(0, "no elements should be yielded after cancellation"); - } - finally - { - fileSystemFixture.CleanupFileSystemStructure(); - } - } - [Fact] public async Task GetTreeDirectories_WhenCalledWithValidPathAndNotIncludeHiddenElements_ShouldReturnTreeDirectoriesWithoutHiddenElements() { @@ -550,51 +504,6 @@ public class DirectoriesControllerTests : IClassFixture } } - [Fact] - public async Task GetTreeDirectories_WhenCancellationIsRequested_ShouldStopYieldingResults() - { - // Arrange - FileSystemStructureFixture fileSystemFixture = new(); - string testPath = fileSystemFixture.CreateFileSystemStructure(); - - bool includeHiddenElements = false; - CancellationTokenSource cts = new(); - - try - { - // Act - Task getTreeDirectoriesTask = _client.GetAsync( - $"/api/v1/directories/get-tree-directories?path={Uri.EscapeDataString(testPath)}&includeHiddenElements={includeHiddenElements}", - cts.Token - ); - - // simulate cancellation before the request completes - cts.Cancel(); - - HttpResponseMessage? response = null; - try - { - response = await getTreeDirectoriesTask; - } - catch (TaskCanceledException) - { - // expected when the task is cancelled, suppress the exception to continue the test - } - // Assert - response?.StatusCode.Should().Be(HttpStatusCode.OK, "The cancellation should occur gracefully on the server side"); - - // assert that no elements were returned after cancellation - if (response != null) - using (Stream stream = await response.Content.ReadAsStreamAsync()) - using (JsonDocument jsonDoc = await JsonDocument.ParseAsync(stream)) - jsonDoc.RootElement.GetArrayLength().Should().Be(0, "no elements should be yielded after cancellation"); - } - finally - { - fileSystemFixture.CleanupFileSystemStructure(); - } - } - [Fact] public async Task GetDirectories_WhenCalledWithValidPathAndNotIncludeHiddenElements_ShouldReturnDirectoriesWithoutHiddenElements() { @@ -732,47 +641,5 @@ public class DirectoriesControllerTests : IClassFixture fileSystemFixture.CleanupFileSystemStructure(); } } - - [Fact] - public async Task GetDirectories_WhenCancellationIsRequested_ShouldStopYieldingResults() - { - // Arrange - FileSystemStructureFixture fileSystemFixture = new(); - string testPath = fileSystemFixture.CreateFileSystemStructure(); - - bool includeHiddenElements = false; - CancellationTokenSource cts = new(); - - try - { - // Act - Task getDirectoriesTask = _client.GetAsync($"/api/v1/directories/get-directories?path={Uri.EscapeDataString(testPath)}&includeHiddenElements={includeHiddenElements}", cts.Token); - - // simulate cancellation before the request completes - cts.Cancel(); - - HttpResponseMessage? response = null; - try - { - response = await getDirectoriesTask; - } - catch (TaskCanceledException) - { - // expected when the task is cancelled, suppress the exception to continue the test - } - // Assert - response?.StatusCode.Should().Be(HttpStatusCode.OK, "The cancellation should occur gracefully on the server side"); - - // assert that no elements were returned after cancellation - if (response != null) - using (Stream stream = await response.Content.ReadAsStreamAsync()) - using (JsonDocument jsonDoc = await JsonDocument.ParseAsync(stream)) - jsonDoc.RootElement.GetArrayLength().Should().Be(0, "no elements should be yielded after cancellation"); - } - finally - { - fileSystemFixture.CleanupFileSystemStructure(); - } - } #endregion } diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Controllers/FileManagement/DrivesControllerTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Controllers/FileManagement/DrivesControllerTests.cs index 41a25903..9ea1891d 100644 --- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Controllers/FileManagement/DrivesControllerTests.cs +++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Controllers/FileManagement/DrivesControllerTests.cs @@ -81,39 +81,5 @@ public class DrivesControllerTests : IClassFixture firstDrive.ItemType.Should().Be(FileSystemItemType.Root); drives.Count.Should().BeGreaterThanOrEqualTo(1); } - - [Fact] - public async Task GetDrives_WhenCancellationIsRequested_ShouldStopYieldingResults() - { - // Arrange - CancellationTokenSource cts = new(); - - // Act - Task getDrivesTask = _client.GetAsync( - $"/api/v1/drives/get-drives", - cts.Token - ); - - // simulate cancellation before the request completes - cts.Cancel(); - - HttpResponseMessage? response = null; - try - { - response = await getDrivesTask; - } - catch (TaskCanceledException) - { - // expected when the task is cancelled, suppress the exception to continue the test - } - // Assert - response?.StatusCode.Should().Be(HttpStatusCode.OK, "The cancellation should occur gracefully on the server side"); - - // assert that no elements were returned after cancellation - if (response != null) - using (Stream stream = await response.Content.ReadAsStreamAsync()) - using (JsonDocument jsonDoc = await JsonDocument.ParseAsync(stream)) - jsonDoc.RootElement.GetArrayLength().Should().Be(0, "no elements should be yielded after cancellation"); - } #endregion } diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Controllers/FileManagement/FilesControllerTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Controllers/FileManagement/FilesControllerTests.cs index 1da564ba..0011b252 100644 --- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Controllers/FileManagement/FilesControllerTests.cs +++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Controllers/FileManagement/FilesControllerTests.cs @@ -331,50 +331,5 @@ public class FilesControllerTests : IClassFixture fileSystemFixture.CleanupFileSystemStructure(); } } - - [Fact] - public async Task GetFiles_WhenCancellationIsRequested_ShouldStopYieldingResults() - { - // Arrange - FileSystemStructureFixture fileSystemFixture = new(); - string testPath = fileSystemFixture.CreateFileSystemStructure(); - - bool includeHiddenElements = false; - CancellationTokenSource cts = new(); - - try - { - // Act - Task getTreeFilesTask = _client.GetAsync( - $"/api/v1/files/get-files?path={Uri.EscapeDataString(testPath)}&includeHiddenElements={includeHiddenElements}", - cts.Token - ); - - // simulate cancellation before the request completes - cts.Cancel(); - - HttpResponseMessage? response = null; - try - { - response = await getTreeFilesTask; - } - catch (TaskCanceledException) - { - // expected when the task is cancelled, suppress the exception to continue the test - } - // Assert - response?.StatusCode.Should().Be(HttpStatusCode.OK, "The cancellation should occur gracefully on the server side"); - - // assert that no elements were returned after cancellation - if (response != null) - using (Stream stream = await response.Content.ReadAsStreamAsync()) - using (JsonDocument jsonDoc = await JsonDocument.ParseAsync(stream)) - jsonDoc.RootElement.GetArrayLength().Should().Be(0, "no elements should be yielded after cancellation"); - } - finally - { - fileSystemFixture.CleanupFileSystemStructure(); - } - } #endregion }