mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-02 19:11:10 +00:00
Adds a per-library option to skip hidden files and directories during scans
This commit is contained in:
1 parent
0bb795dca5
commit
0e8d61b215
67 files changed
+4624
-19
No files matched your search
+2
@@ -36,6 +36,7 @@ public class AddMediaLibraryRequestMappingTests
|
||||
canDownloadMetadataFromWeb: true,
|
||||
shouldSaveMetadataInMediaDirectories: false,
|
||||
shouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
shouldSkipHiddenFilesAndDirectoriesDuringScan: true,
|
||||
isContentOnSsd: true,
|
||||
shouldTrackConsumptionProgress: true,
|
||||
completionThresholdPercentage: 90
|
||||
@@ -54,6 +55,7 @@ public class AddMediaLibraryRequestMappingTests
|
||||
Assert.Equal(request.IsLocked, result.IsLocked);
|
||||
Assert.Equal(request.CanDownloadMetadataFromWeb, result.CanDownloadMetadataFromWeb);
|
||||
Assert.Equal(request.ShouldSaveMetadataInMediaDirectories, result.ShouldSaveMetadataInMediaDirectories);
|
||||
Assert.Equal(request.ShouldSkipHiddenFilesAndDirectoriesDuringScan, result.ShouldSkipHiddenFilesAndDirectoriesDuringScan);
|
||||
Assert.Equal(request.IsContentOnSsd, result.IsContentOnSsd);
|
||||
Assert.Equal(request.ShouldTrackConsumptionProgress, result.ShouldTrackConsumptionProgress);
|
||||
Assert.Equal(request.CompletionThresholdPercentage, result.CompletionThresholdPercentage);
|
||||
|
||||
+4
@@ -33,6 +33,7 @@ public class LibraryEntityMappingTests
|
||||
libraryType: LibraryType.Book,
|
||||
contentLocations: ["C:/Books", "D:/Media/Books"],
|
||||
coverImage: "D:/myPoster.jpg",
|
||||
shouldSkipHiddenFilesAndDirectoriesDuringScan: true,
|
||||
isContentOnSsd: true);
|
||||
|
||||
// Act
|
||||
@@ -46,6 +47,7 @@ public class LibraryEntityMappingTests
|
||||
Assert.Equal(entity.LibraryType, result.LibraryType);
|
||||
Assert.Equal(entity.ContentLocations.Select(l => l.Path), result.ContentLocations);
|
||||
Assert.Equal(entity.CoverImage, result.CoverImage);
|
||||
Assert.Equal(entity.ShouldSkipHiddenFilesAndDirectoriesDuringScan, result.ShouldSkipHiddenFilesAndDirectoriesDuringScan);
|
||||
Assert.Equal(entity.IsContentOnSsd, result.IsContentOnSsd);
|
||||
Assert.Equal(entity.ShouldTrackConsumptionProgress, result.ShouldTrackConsumptionProgress);
|
||||
Assert.Equal(entity.CompletionThresholdPercentage, result.CompletionThresholdPercentage);
|
||||
@@ -190,6 +192,7 @@ public class LibraryEntityMappingTests
|
||||
libraryType: LibraryType.Book,
|
||||
contentLocations: ["C:/Books"],
|
||||
coverImage: "D:/cover.jpg",
|
||||
shouldSkipHiddenFilesAndDirectoriesDuringScan: true,
|
||||
isContentOnSsd: true,
|
||||
pathTemplateParts: [firstPart, secondPart]);
|
||||
|
||||
@@ -203,6 +206,7 @@ public class LibraryEntityMappingTests
|
||||
Assert.Equal(entity.Title, result.Value.Title);
|
||||
Assert.Equal(entity.LibraryType, result.Value.LibraryType);
|
||||
Assert.Equal("D:/cover.jpg", result.Value.CoverImage.Value);
|
||||
Assert.Equal(entity.ShouldSkipHiddenFilesAndDirectoriesDuringScan, result.Value.ShouldSkipHiddenFilesAndDirectoriesDuringScan);
|
||||
Assert.Equal(entity.IsContentOnSsd, result.Value.IsContentOnSsd);
|
||||
Assert.Equal(entity.ShouldTrackConsumptionProgress, result.Value.ConsumptionSettings.ShouldTrackConsumptionProgress);
|
||||
Assert.Equal(entity.CompletionThresholdPercentage, result.Value.ConsumptionSettings.CompletionThresholdPercentage.HasValue ? result.Value.ConsumptionSettings.CompletionThresholdPercentage.Value : null);
|
||||
|
||||
+2
@@ -41,6 +41,7 @@ public class LibraryMappingTests
|
||||
canDownloadMetadataFromWeb: true,
|
||||
shouldSaveMetadataInMediaDirectories: false,
|
||||
shouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
shouldSkipHiddenFilesAndDirectoriesDuringScan: true,
|
||||
scanIds: [Guid.NewGuid()]);
|
||||
|
||||
// Act
|
||||
@@ -60,6 +61,7 @@ public class LibraryMappingTests
|
||||
Assert.False(result.IsLocked);
|
||||
Assert.True(result.CanDownloadMetadataFromWeb);
|
||||
Assert.False(result.ShouldSaveMetadataInMediaDirectories);
|
||||
Assert.True(result.ShouldSkipHiddenFilesAndDirectoriesDuringScan);
|
||||
Assert.Equal(library.IsContentOnSsd, result.IsContentOnSsd);
|
||||
Assert.Equal(library.ConsumptionSettings.ShouldTrackConsumptionProgress, result.ShouldTrackConsumptionProgress);
|
||||
Assert.Equal(library.ConsumptionSettings.CompletionThresholdPercentage.HasValue ? library.ConsumptionSettings.CompletionThresholdPercentage.Value : null, result.CompletionThresholdPercentage);
|
||||
|
||||
+2
@@ -36,6 +36,7 @@ public class UpdateLibraryRequestMappingTests
|
||||
canDownloadMetadataFromWeb: true,
|
||||
shouldSaveMetadataInMediaDirectories: false,
|
||||
shouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
shouldSkipHiddenFilesAndDirectoriesDuringScan: true,
|
||||
isContentOnSsd: true,
|
||||
shouldTrackConsumptionProgress: true,
|
||||
completionThresholdPercentage: 90);
|
||||
@@ -54,6 +55,7 @@ public class UpdateLibraryRequestMappingTests
|
||||
Assert.Equal(request.CanDownloadMetadataFromWeb, result.CanDownloadMetadataFromWeb);
|
||||
Assert.Equal(request.ShouldSaveMetadataInMediaDirectories, result.ShouldSaveMetadataInMediaDirectories);
|
||||
Assert.Equal(request.ShouldSkipUnchangedDirectoriesDuringScan, result.ShouldSkipUnchangedDirectoriesDuringScan);
|
||||
Assert.Equal(request.ShouldSkipHiddenFilesAndDirectoriesDuringScan, result.ShouldSkipHiddenFilesAndDirectoriesDuringScan);
|
||||
Assert.Equal(request.IsContentOnSsd, result.IsContentOnSsd);
|
||||
Assert.Equal(request.ShouldTrackConsumptionProgress, result.ShouldTrackConsumptionProgress);
|
||||
Assert.Equal(request.CompletionThresholdPercentage, result.CompletionThresholdPercentage);
|
||||
|
||||
+19
@@ -114,6 +114,25 @@ public class AddLibraryCommandHandlerTests
|
||||
_mockDomainEventsQueue.Received(1).Enqueue(Arg.Any<LibrarySavedDomainEvent>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task HandleAsync_WhenHiddenFilesSettingIsAbsent_ShouldDefaultToNotSkippingHiddenFiles()
|
||||
{
|
||||
// Arrange
|
||||
AddLibraryCommand command = _addLibraryCommandFixture.Create(shouldSkipHiddenFilesAndDirectoriesDuringScan: null);
|
||||
LibraryEntity persistedLibrary = _libraryEntityFixture.Create(userId: _userId);
|
||||
_mockLibraryRepository.GetByIdAsync(Arg.Any<Guid>(), cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<LibraryEntity?>(persistedLibrary));
|
||||
|
||||
// Act
|
||||
Result<LibraryResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
await _mockLibraryRepository.Received(1).InsertAsync(
|
||||
Arg.Is<LibraryEntity>(library => !library.ShouldSkipHiddenFilesAndDirectoriesDuringScan),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task HandleAsync_WhenThresholdIsSuppliedWhileEffectiveTrackingIsOff_ShouldReturnThresholdMustBeNullError()
|
||||
{
|
||||
|
||||
+100
@@ -45,6 +45,7 @@ public class UpdateLibraryCommandHandlerTests
|
||||
{
|
||||
private readonly IUnitOfWork _mockUnitOfWork;
|
||||
private readonly ILibraryRepository _mockLibraryRepository;
|
||||
private readonly IDirectoryScanFingerprintRepository _mockDirectoryScanFingerprintRepository;
|
||||
private readonly IAuthorizationService _mockAuthorizationService;
|
||||
private readonly ICurrentUserService _mockCurrentUserService;
|
||||
private readonly IDomainEventsQueue _mockDomainEventsQueue;
|
||||
@@ -70,6 +71,10 @@ public class UpdateLibraryCommandHandlerTests
|
||||
_mockUnitOfWork.SaveChangesAsync(Arg.Any<CancellationToken>()).Returns(Result.Success);
|
||||
_mockLibraryRepository = Substitute.For<ILibraryRepository>();
|
||||
_mockUnitOfWork.LibraryRepository.Returns(_mockLibraryRepository);
|
||||
_mockDirectoryScanFingerprintRepository = Substitute.For<IDirectoryScanFingerprintRepository>();
|
||||
_mockDirectoryScanFingerprintRepository.DeleteByLibraryIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
|
||||
.Returns(Result.Deleted);
|
||||
_mockUnitOfWork.DirectoryScanFingerprintRepository.Returns(_mockDirectoryScanFingerprintRepository);
|
||||
_mockAuthorizationService = Substitute.For<IAuthorizationService>();
|
||||
_mockCurrentUserService = Substitute.For<ICurrentUserService>();
|
||||
_mockDomainEventsQueue = Substitute.For<IDomainEventsQueue>();
|
||||
@@ -121,6 +126,101 @@ public class UpdateLibraryCommandHandlerTests
|
||||
_mockDomainEventsQueue.Received(1).Enqueue(Arg.Any<LibrarySavedDomainEvent>());
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(true, false, false, false)] // Only the skip unchanged directories setting changes.
|
||||
[InlineData(false, true, false, false)] // Only the skip hidden files and directories setting changes.
|
||||
public async Task HandleAsync_WhenAScanScopeSettingChanges_ShouldDeleteTheDirectoryScanFingerprints(
|
||||
bool commandShouldSkipUnchangedDirectories,
|
||||
bool commandShouldSkipHiddenFilesAndDirectories,
|
||||
bool existingShouldSkipUnchangedDirectories,
|
||||
bool existingShouldSkipHiddenFilesAndDirectories)
|
||||
{
|
||||
// Arrange
|
||||
UpdateLibraryCommand command = _updateLibraryCommandFixture.Create(
|
||||
shouldSkipUnchangedDirectoriesDuringScan: commandShouldSkipUnchangedDirectories,
|
||||
shouldSkipHiddenFilesAndDirectoriesDuringScan: commandShouldSkipHiddenFilesAndDirectories);
|
||||
LibraryEntity existingLibrary = _libraryEntityFixture.Create(
|
||||
id: command.Id,
|
||||
userId: _userId,
|
||||
shouldSkipUnchangedDirectoriesDuringScan: existingShouldSkipUnchangedDirectories,
|
||||
shouldSkipHiddenFilesAndDirectoriesDuringScan: existingShouldSkipHiddenFilesAndDirectories);
|
||||
existingLibrary.LibraryType = Enum.Parse<LibraryType>(command.LibraryType!);
|
||||
_mockLibraryRepository.GetByIdAsync(command.Id, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<LibraryEntity?>(existingLibrary));
|
||||
|
||||
// Act
|
||||
Result<LibraryResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
await _mockDirectoryScanFingerprintRepository.Received(1).DeleteByLibraryIdAsync(command.Id, Arg.Any<CancellationToken>());
|
||||
await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task HandleAsync_WhenHiddenFilesSettingIsAbsent_ShouldKeepTheStoredValue()
|
||||
{
|
||||
// Arrange
|
||||
UpdateLibraryCommand command = _updateLibraryCommandFixture.Create(shouldSkipHiddenFilesAndDirectoriesDuringScan: null);
|
||||
LibraryEntity existingLibrary = _libraryEntityFixture.Create(
|
||||
id: command.Id,
|
||||
userId: _userId,
|
||||
shouldSkipHiddenFilesAndDirectoriesDuringScan: true);
|
||||
existingLibrary.LibraryType = Enum.Parse<LibraryType>(command.LibraryType!);
|
||||
_mockLibraryRepository.GetByIdAsync(command.Id, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<LibraryEntity?>(existingLibrary));
|
||||
|
||||
// Act
|
||||
Result<LibraryResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
await _mockLibraryRepository.Received(1).UpdateAsync(
|
||||
Arg.Is<LibraryEntity>(library => library.ShouldSkipHiddenFilesAndDirectoriesDuringScan),
|
||||
Arg.Any<CancellationToken>());
|
||||
await _mockDirectoryScanFingerprintRepository.DidNotReceive().DeleteByLibraryIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task HandleAsync_WhenScanScopeSettingsAreUnchanged_ShouldNotDeleteTheDirectoryScanFingerprints()
|
||||
{
|
||||
// Arrange
|
||||
UpdateLibraryCommand command = _updateLibraryCommandFixture.Create();
|
||||
LibraryEntity existingLibrary = _libraryEntityFixture.Create(id: command.Id, userId: _userId);
|
||||
existingLibrary.LibraryType = Enum.Parse<LibraryType>(command.LibraryType!);
|
||||
_mockLibraryRepository.GetByIdAsync(command.Id, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<LibraryEntity?>(existingLibrary));
|
||||
|
||||
// Act
|
||||
Result<LibraryResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
await _mockDirectoryScanFingerprintRepository.DidNotReceive().DeleteByLibraryIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task HandleAsync_WhenDeletingTheDirectoryScanFingerprintsFails_ShouldReturnTheErrorAndNotSave()
|
||||
{
|
||||
// Arrange
|
||||
UpdateLibraryCommand command = _updateLibraryCommandFixture.Create(shouldSkipHiddenFilesAndDirectoriesDuringScan: true);
|
||||
LibraryEntity existingLibrary = _libraryEntityFixture.Create(id: command.Id, userId: _userId);
|
||||
existingLibrary.LibraryType = Enum.Parse<LibraryType>(command.LibraryType!);
|
||||
_mockLibraryRepository.GetByIdAsync(command.Id, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<LibraryEntity?>(existingLibrary));
|
||||
Error deleteError = Error.Failure("Database.Error", "Failed to delete the directory scan fingerprints");
|
||||
_mockDirectoryScanFingerprintRepository.DeleteByLibraryIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
|
||||
.Returns(deleteError);
|
||||
|
||||
// Act
|
||||
Result<LibraryResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(deleteError, result.FirstError);
|
||||
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task HandleAsync_WhenThresholdIsSuppliedWhileStoredTrackingIsOff_ShouldReturnThresholdMustBeNullError()
|
||||
{
|
||||
|
||||
+6
@@ -56,6 +56,7 @@ public class LibraryTests
|
||||
canDownloadMetadataFromWeb: false,
|
||||
shouldSaveMetadataInMediaDirectories: true,
|
||||
shouldSkipUnchangedDirectoriesDuringScan: true,
|
||||
shouldSkipHiddenFilesAndDirectoriesDuringScan: true,
|
||||
isContentOnSsd: true,
|
||||
consumptionSettings,
|
||||
LibraryPathTemplate.Empty(),
|
||||
@@ -74,6 +75,7 @@ public class LibraryTests
|
||||
Assert.False(result.Value.CanDownloadMetadataFromWeb);
|
||||
Assert.True(result.Value.ShouldSaveMetadataInMediaDirectories);
|
||||
Assert.True(result.Value.ShouldSkipUnchangedDirectoriesDuringScan);
|
||||
Assert.True(result.Value.ShouldSkipHiddenFilesAndDirectoriesDuringScan);
|
||||
Assert.True(result.Value.IsContentOnSsd);
|
||||
Assert.Equal(consumptionSettings, result.Value.ConsumptionSettings);
|
||||
Assert.Equal(scanIds, result.Value.ScanIds);
|
||||
@@ -99,6 +101,7 @@ public class LibraryTests
|
||||
canDownloadMetadataFromWeb: true,
|
||||
shouldSaveMetadataInMediaDirectories: false,
|
||||
shouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
shouldSkipHiddenFilesAndDirectoriesDuringScan: false,
|
||||
isContentOnSsd: false,
|
||||
_libraryConsumptionSettingsFixture.Create(),
|
||||
LibraryPathTemplate.Empty(),
|
||||
@@ -128,6 +131,7 @@ public class LibraryTests
|
||||
canDownloadMetadataFromWeb: true,
|
||||
shouldSaveMetadataInMediaDirectories: false,
|
||||
shouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
shouldSkipHiddenFilesAndDirectoriesDuringScan: false,
|
||||
isContentOnSsd: false,
|
||||
_libraryConsumptionSettingsFixture.Create(),
|
||||
LibraryPathTemplate.Empty(),
|
||||
@@ -166,6 +170,7 @@ public class LibraryTests
|
||||
canDownloadMetadataFromWeb: true,
|
||||
shouldSaveMetadataInMediaDirectories: false,
|
||||
shouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
shouldSkipHiddenFilesAndDirectoriesDuringScan: false,
|
||||
isContentOnSsd: false,
|
||||
_libraryConsumptionSettingsFixture.Create(),
|
||||
LibraryPathTemplate.Empty(),
|
||||
@@ -196,6 +201,7 @@ public class LibraryTests
|
||||
canDownloadMetadataFromWeb: true,
|
||||
shouldSaveMetadataInMediaDirectories: false,
|
||||
shouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
shouldSkipHiddenFilesAndDirectoriesDuringScan: false,
|
||||
isContentOnSsd: false,
|
||||
_libraryConsumptionSettingsFixture.Create(),
|
||||
LibraryPathTemplate.Empty(),
|
||||
|
||||
+28
-4
@@ -179,6 +179,8 @@ public class MusicFileSystemDiscoveryJobTests
|
||||
|
||||
// Assert
|
||||
Assert.Equal(LibraryScanJobStatus.Completed, _sut.Status);
|
||||
_mockFileProviderService.Received(1).GetFilePaths(Arg.Any<FileSystemPathId>(), true);
|
||||
_mockDirectoryProviderService.Received(1).GetSubdirectoryPaths(Arg.Any<FileSystemPathId>(), true);
|
||||
await _mockStagingResultsRepository.Received(1).InsertRangeAsync(
|
||||
Arg.Is<IReadOnlyCollection<LibraryScanStagingResultsEntity>>(entities => entities.Count == 1
|
||||
&& entities.First().Path == AUDIO_FILE_PATH
|
||||
@@ -227,6 +229,25 @@ public class MusicFileSystemDiscoveryJobTests
|
||||
Arg.Any<Func<object, Exception?, string>>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenHiddenFilesAndDirectoriesAreSkipped_ShouldAskTheProvidersToExcludeThem()
|
||||
{
|
||||
// Arrange
|
||||
SetupLibrary(shouldSkipHiddenFilesAndDirectoriesDuringScan: true);
|
||||
SetupDirectory(ROOT_PATH, files: [AUDIO_FILE_PATH], subdirectories: [], shouldIncludeHiddenElements: false);
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(Guid.NewGuid(), new { }, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(LibraryScanJobStatus.Completed, _sut.Status);
|
||||
_mockFileProviderService.Received(1).GetFilePaths(Arg.Any<FileSystemPathId>(), false);
|
||||
_mockDirectoryProviderService.Received(1).GetSubdirectoryPaths(Arg.Any<FileSystemPathId>(), false);
|
||||
await _mockStagingResultsRepository.Received(1).InsertRangeAsync(
|
||||
Arg.Is<IReadOnlyCollection<LibraryScanStagingResultsEntity>>(entities => entities.Count == 1 && entities.First().Path == AUDIO_FILE_PATH),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenTheSubdirectoryHasAudioFiles_ShouldTraverseIntoIt()
|
||||
{
|
||||
@@ -403,14 +424,16 @@ public class MusicFileSystemDiscoveryJobTests
|
||||
/// Stubs the media library reader with a library whose single content location is the test root path.
|
||||
/// </summary>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether the library skips the directories that have not changed since the last scan.</param>
|
||||
/// <param name="shouldSkipHiddenFilesAndDirectoriesDuringScan">Whether the library skips hidden files and directories.</param>
|
||||
/// <param name="isContentOnSsd">Whether the content of the library is stored on a solid state drive.</param>
|
||||
private void SetupLibrary(bool shouldSkipUnchangedDirectoriesDuringScan = false, bool isContentOnSsd = false)
|
||||
private void SetupLibrary(bool shouldSkipUnchangedDirectoriesDuringScan = false, bool shouldSkipHiddenFilesAndDirectoriesDuringScan = false, bool isContentOnSsd = false)
|
||||
{
|
||||
LibraryEntity library = _libraryEntityFixture.Create(
|
||||
id: _libraryId.Value,
|
||||
libraryType: LibraryType.Music,
|
||||
contentLocations: [ROOT_PATH],
|
||||
shouldSkipUnchangedDirectoriesDuringScan: shouldSkipUnchangedDirectoriesDuringScan,
|
||||
shouldSkipHiddenFilesAndDirectoriesDuringScan: shouldSkipHiddenFilesAndDirectoriesDuringScan,
|
||||
isContentOnSsd: isContentOnSsd);
|
||||
_mockLibraryRepository.GetByIdAsync(Arg.Any<Guid>(), cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<LibraryEntity?>(library));
|
||||
@@ -422,11 +445,12 @@ public class MusicFileSystemDiscoveryJobTests
|
||||
/// <param name="directory">The file system path of the directory.</param>
|
||||
/// <param name="files">The file system paths of the files of the directory.</param>
|
||||
/// <param name="subdirectories">The file system paths of the subdirectories of the directory.</param>
|
||||
private void SetupDirectory(string directory, string[] files, string[] subdirectories)
|
||||
/// <param name="shouldIncludeHiddenElements">Whether the providers are expected to include hidden elements.</param>
|
||||
private void SetupDirectory(string directory, string[] files, string[] subdirectories, bool shouldIncludeHiddenElements = true)
|
||||
{
|
||||
_mockFileProviderService.GetFilePaths(Arg.Is<FileSystemPathId>(path => path.Path == directory), true)
|
||||
_mockFileProviderService.GetFilePaths(Arg.Is<FileSystemPathId>(path => path.Path == directory), shouldIncludeHiddenElements)
|
||||
.Returns(Result.From<IEnumerable<FileSystemPathId>>([.. files.Select(file => PathId(file))]));
|
||||
_mockDirectoryProviderService.GetSubdirectoryPaths(Arg.Is<FileSystemPathId>(path => path.Path == directory), true)
|
||||
_mockDirectoryProviderService.GetSubdirectoryPaths(Arg.Is<FileSystemPathId>(path => path.Path == directory), shouldIncludeHiddenElements)
|
||||
.Returns(Result.From<IEnumerable<FileSystemPathId>>([.. subdirectories.Select(subdirectoryPath => PathId(subdirectoryPath))]));
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -87,6 +87,7 @@ public class AddLibraryEndpointTests
|
||||
{
|
||||
// Arrange
|
||||
AddLibraryRequest request = _addLibraryRequestFixture.Create(
|
||||
shouldSkipHiddenFilesAndDirectoriesDuringScan: true,
|
||||
isContentOnSsd: true,
|
||||
shouldTrackConsumptionProgress: true,
|
||||
completionThresholdPercentage: 65);
|
||||
@@ -109,6 +110,7 @@ public class AddLibraryEndpointTests
|
||||
command.CanDownloadMetadataFromWeb == request.CanDownloadMetadataFromWeb &&
|
||||
command.ShouldSaveMetadataInMediaDirectories == request.ShouldSaveMetadataInMediaDirectories &&
|
||||
command.ShouldSkipUnchangedDirectoriesDuringScan == request.ShouldSkipUnchangedDirectoriesDuringScan &&
|
||||
command.ShouldSkipHiddenFilesAndDirectoriesDuringScan == request.ShouldSkipHiddenFilesAndDirectoriesDuringScan &&
|
||||
command.IsContentOnSsd == request.IsContentOnSsd &&
|
||||
command.ShouldTrackConsumptionProgress == request.ShouldTrackConsumptionProgress &&
|
||||
command.CompletionThresholdPercentage == request.CompletionThresholdPercentage),
|
||||
|
||||
+2
@@ -87,6 +87,7 @@ public class UpdateLibraryEndpointTests
|
||||
{
|
||||
// Arrange
|
||||
UpdateLibraryRequest request = _updateLibraryRequestFixture.Create(
|
||||
shouldSkipHiddenFilesAndDirectoriesDuringScan: true,
|
||||
isContentOnSsd: true,
|
||||
shouldTrackConsumptionProgress: true,
|
||||
completionThresholdPercentage: 65);
|
||||
@@ -110,6 +111,7 @@ public class UpdateLibraryEndpointTests
|
||||
command.CanDownloadMetadataFromWeb == request.CanDownloadMetadataFromWeb &&
|
||||
command.ShouldSaveMetadataInMediaDirectories == request.ShouldSaveMetadataInMediaDirectories &&
|
||||
command.ShouldSkipUnchangedDirectoriesDuringScan == request.ShouldSkipUnchangedDirectoriesDuringScan &&
|
||||
command.ShouldSkipHiddenFilesAndDirectoriesDuringScan == request.ShouldSkipHiddenFilesAndDirectoriesDuringScan &&
|
||||
command.IsContentOnSsd == request.IsContentOnSsd &&
|
||||
command.ShouldTrackConsumptionProgress == request.ShouldTrackConsumptionProgress &&
|
||||
command.CompletionThresholdPercentage == request.CompletionThresholdPercentage),
|
||||
|
||||
Reference in new issue
Block a user