mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 18:57:24 +00:00
Adds per-library consumption settings to the domain, storage, and API
This commit is contained in:
1 parent
eaca69bf2a
commit
b2d274f609
47 files changed
+4371
-11
No files matched your search
@@ -65,6 +65,8 @@ POST api/v1/libraries
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": []
|
||||
}
|
||||
```
|
||||
@@ -90,6 +92,8 @@ POST api/v1/libraries
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": [],
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null
|
||||
@@ -126,6 +130,8 @@ GET api/v1/libraries
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": [],
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null
|
||||
@@ -163,6 +169,8 @@ GET api/v1/libraries/enabled
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": [],
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null
|
||||
@@ -199,6 +207,8 @@ GET api/v1/libraries/{id}
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": [],
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null
|
||||
@@ -228,6 +238,8 @@ PUT api/v1/libraries/{id}
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": []
|
||||
}
|
||||
```
|
||||
@@ -253,6 +265,8 @@ PUT api/v1/libraries/{id}
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": [],
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null
|
||||
|
||||
@@ -14,6 +14,8 @@ Content-Type: application/json
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": [
|
||||
{ "kind": "Artist", "representation": "{0}", "isOptional": false },
|
||||
{ "kind": "Separator", "representation": "", "isOptional": false }
|
||||
|
||||
@@ -16,6 +16,8 @@ Content-Type: application/json
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": [
|
||||
{ "kind": "Artist", "representation": "{0}", "isOptional": false },
|
||||
{ "kind": "Separator", "representation": "", "isOptional": false }
|
||||
|
||||
+10
@@ -80,6 +80,16 @@ public class LibraryEntity : IStorageEntity, IAuditableEntity
|
||||
/// </summary>
|
||||
public bool ShouldSkipUnchangedDirectoriesDuringScan { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the consumption progress of the media library items is tracked.
|
||||
/// </summary>
|
||||
public bool ShouldTrackConsumptionProgress { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the percentage of a media library item that must be consumed for its session to be considered completed, when progress tracking is enabled.
|
||||
/// </summary>
|
||||
public int? CompletionThresholdPercentage { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the fingerprint of the metadata provider configuration of the media library, used to detect
|
||||
/// whether the configuration changed since the last scan, and thus whether the books need re-enrichment.
|
||||
|
||||
+2
@@ -29,6 +29,8 @@ public static class AddMediaLibraryRequestMapping
|
||||
request.CanDownloadMetadataFromWeb,
|
||||
request.ShouldSaveMetadataInMediaDirectories,
|
||||
request.ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
request.ShouldTrackConsumptionProgress,
|
||||
request.CompletionThresholdPercentage,
|
||||
request.PathTemplateParts?.Select(part => new LibraryPathTemplatePartDto(part.Kind, part.Representation, part.IsOptional)).ToArray()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ public static class LibraryEntityMapping
|
||||
repositoryEntity.CanDownloadMetadataFromWeb,
|
||||
repositoryEntity.ShouldSaveMetadataInMediaDirectories,
|
||||
repositoryEntity.ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
repositoryEntity.ShouldTrackConsumptionProgress,
|
||||
repositoryEntity.CompletionThresholdPercentage,
|
||||
[.. repositoryEntity.PathTemplateParts
|
||||
.OrderBy(part => part.Position)
|
||||
.Select(part => new LibraryPathTemplatePartResponse(part.Kind.ToString(), part.Representation, part.IsOptional))],
|
||||
@@ -57,6 +59,10 @@ public static class LibraryEntityMapping
|
||||
if (pathTemplateResult.IsFailure)
|
||||
return pathTemplateResult.Errors;
|
||||
|
||||
LibraryConsumptionSettings consumptionSettings = LibraryConsumptionSettings.Create(
|
||||
repositoryEntity.ShouldTrackConsumptionProgress,
|
||||
Optional<int>.FromNullable(repositoryEntity.CompletionThresholdPercentage));
|
||||
|
||||
return Library.Create(
|
||||
LibraryId.Create(repositoryEntity.Id),
|
||||
UserId.Create(repositoryEntity.UserId),
|
||||
@@ -69,6 +75,7 @@ public static class LibraryEntityMapping
|
||||
repositoryEntity.CanDownloadMetadataFromWeb,
|
||||
repositoryEntity.ShouldSaveMetadataInMediaDirectories,
|
||||
repositoryEntity.ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
consumptionSettings,
|
||||
pathTemplateResult.Value,
|
||||
[.. repositoryEntity.LibraryScans.Select(libraryScan => ScanId.Create(libraryScan.Id))]
|
||||
);
|
||||
|
||||
@@ -39,6 +39,10 @@ public static class LibraryMapping
|
||||
CanDownloadMetadataFromWeb = domainEntity.CanDownloadMetadataFromWeb,
|
||||
ShouldSaveMetadataInMediaDirectories = domainEntity.ShouldSaveMetadataInMediaDirectories,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan = domainEntity.ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
ShouldTrackConsumptionProgress = domainEntity.ConsumptionSettings.ShouldTrackConsumptionProgress,
|
||||
CompletionThresholdPercentage = domainEntity.ConsumptionSettings.CompletionThresholdPercentage.HasValue
|
||||
? domainEntity.ConsumptionSettings.CompletionThresholdPercentage.Value
|
||||
: null,
|
||||
LibraryScans = [.. domainEntity.ScanIds.Select(scanId => new LibraryScanEntity()
|
||||
{
|
||||
Id = scanId.Value,
|
||||
|
||||
+2
@@ -31,6 +31,8 @@ public static class UpdateLibraryRequestMapping
|
||||
request.CanDownloadMetadataFromWeb,
|
||||
request.ShouldSaveMetadataInMediaDirectories,
|
||||
request.ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
request.ShouldTrackConsumptionProgress,
|
||||
request.CompletionThresholdPercentage,
|
||||
request.PathTemplateParts?.Select(part => new LibraryPathTemplatePartDto(part.Kind, part.Representation, part.IsOptional)).ToArray()
|
||||
);
|
||||
}
|
||||
|
||||
+4
@@ -18,6 +18,8 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary;
|
||||
/// <param name="CanDownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="ShouldSaveMetadataInMediaDirectories">Whether this media library should copy the downloaded metadata into the media library content locations, or not.</param>
|
||||
/// <param name="ShouldSkipUnchangedDirectoriesDuringScan">Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.</param>
|
||||
/// <param name="ShouldTrackConsumptionProgress">Whether the consumption progress of the media library items should be tracked, or not. When absent, the default of the library type is used.</param>
|
||||
/// <param name="CompletionThresholdPercentage">The percentage of a media library item that must be consumed for its session to be considered completed. When absent, the default of the library type is used on creation.</param>
|
||||
/// <param name="PathTemplateParts">The ordered parts of the template describing the structure of the media library on disk.</param>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
public record AddLibraryCommand(
|
||||
@@ -30,5 +32,7 @@ public record AddLibraryCommand(
|
||||
bool CanDownloadMetadataFromWeb,
|
||||
bool ShouldSaveMetadataInMediaDirectories,
|
||||
bool ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
bool? ShouldTrackConsumptionProgress,
|
||||
int? CompletionThresholdPercentage,
|
||||
LibraryPathTemplatePartDto[]? PathTemplateParts
|
||||
) : ICommand;
|
||||
+12
@@ -116,6 +116,17 @@ public class AddLibraryCommandHandler : ICommandHandler<AddLibraryCommand, Resul
|
||||
|
||||
LibraryType libraryType = Enum.Parse<LibraryType>(command.LibraryType!);
|
||||
|
||||
// A library created without explicit consumption settings uses the defaults of its type. When progress tracking is on and no threshold is
|
||||
// supplied, the default threshold of the type is used; a type without one keeps no threshold, which means completion is recorded explicitly.
|
||||
LibraryConsumptionSettings defaultConsumptionSettings = LibraryConsumptionSettings.CreateDefault(libraryType);
|
||||
bool shouldTrackConsumptionProgress = command.ShouldTrackConsumptionProgress ?? defaultConsumptionSettings.ShouldTrackConsumptionProgress;
|
||||
Optional<int> completionThresholdPercentage = Optional<int>.FromNullable(command.CompletionThresholdPercentage);
|
||||
if (completionThresholdPercentage.HasValue && !shouldTrackConsumptionProgress)
|
||||
return DomainErrors.Library.CompletionThresholdPercentageMustBeNullWhenProgressTrackingIsOff;
|
||||
if (!completionThresholdPercentage.HasValue && shouldTrackConsumptionProgress)
|
||||
completionThresholdPercentage = defaultConsumptionSettings.CompletionThresholdPercentage;
|
||||
LibraryConsumptionSettings consumptionSettings = LibraryConsumptionSettings.Create(shouldTrackConsumptionProgress, completionThresholdPercentage);
|
||||
|
||||
// A library always carries a path template: the one provided by the user, or the ideal structure of the library type as its default.
|
||||
Result<IReadOnlyList<LibraryPathPart>> pathTemplatePartsResult = command.PathTemplateParts.ToDomainParts();
|
||||
if (pathTemplatePartsResult.IsFailure)
|
||||
@@ -136,6 +147,7 @@ public class AddLibraryCommandHandler : ICommandHandler<AddLibraryCommand, Resul
|
||||
command.CanDownloadMetadataFromWeb,
|
||||
command.ShouldSaveMetadataInMediaDirectories,
|
||||
command.ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
consumptionSettings,
|
||||
pathTemplateResult.Value,
|
||||
[]
|
||||
);
|
||||
|
||||
+8
@@ -42,6 +42,14 @@ public class AddLibraryCommandValidator : AbstractValidator<AddLibraryCommand>
|
||||
.MaximumLength(255)
|
||||
.WithError(Errors.Library.TitleMustBeMaximum255CharactersLong);
|
||||
|
||||
RuleFor(command => command.CompletionThresholdPercentage)
|
||||
.Must((command, completionThresholdPercentage) => command.ShouldTrackConsumptionProgress != false || completionThresholdPercentage is null)
|
||||
.WithError(Errors.Library.CompletionThresholdPercentageMustBeNullWhenProgressTrackingIsOff);
|
||||
|
||||
RuleFor(command => command.CompletionThresholdPercentage)
|
||||
.InclusiveBetween(0, 100)
|
||||
.WithError(Errors.Library.CompletionThresholdPercentageMustBeBetweenZeroAndOneHundred);
|
||||
|
||||
RuleForEach(command => command.PathTemplateParts)
|
||||
.ChildRules(part =>
|
||||
{
|
||||
|
||||
+4
@@ -21,6 +21,8 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Commands.UpdateLibrary
|
||||
/// <param name="CanDownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="ShouldSaveMetadataInMediaDirectories">Whether this media library should copy the downloaded metadata into the media library content locations, or not.</param>
|
||||
/// <param name="ShouldSkipUnchangedDirectoriesDuringScan">Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.</param>
|
||||
/// <param name="ShouldTrackConsumptionProgress">Whether the consumption progress of the media library items should be tracked, or not. When absent, the stored value is kept.</param>
|
||||
/// <param name="CompletionThresholdPercentage">The percentage of a media library item that must be consumed for its session to be considered completed. When absent, the stored value is kept.</param>
|
||||
/// <param name="PathTemplateParts">The ordered parts of the template describing the structure of the media library on disk.</param>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
public record UpdateLibraryCommand(
|
||||
@@ -35,5 +37,7 @@ public record UpdateLibraryCommand(
|
||||
bool CanDownloadMetadataFromWeb,
|
||||
bool ShouldSaveMetadataInMediaDirectories,
|
||||
bool ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
bool? ShouldTrackConsumptionProgress,
|
||||
int? CompletionThresholdPercentage,
|
||||
LibraryPathTemplatePartDto[]? PathTemplateParts
|
||||
) : ICommand;
|
||||
+20
@@ -130,6 +130,25 @@ public class UpdateLibraryCommandHandler : ICommandHandler<UpdateLibraryCommand,
|
||||
// Create a domain library object.
|
||||
LibraryType newLibraryType = Enum.Parse<LibraryType>(command.LibraryType!);
|
||||
|
||||
// Keep the stored consumption settings unless the request explicitly changes them. When progress tracking is enabled and
|
||||
// no threshold is supplied, the stored threshold is kept; the value object never retains a threshold while tracking is disabled.
|
||||
LibraryConsumptionSettings existingConsumptionSettings = LibraryConsumptionSettings.Create(
|
||||
getLibraryResult.Value.ShouldTrackConsumptionProgress,
|
||||
Optional<int>.FromNullable(getLibraryResult.Value.CompletionThresholdPercentage));
|
||||
bool shouldTrackConsumptionProgress = command.ShouldTrackConsumptionProgress ?? existingConsumptionSettings.ShouldTrackConsumptionProgress;
|
||||
bool isEnablingConsumptionProgressTracking = shouldTrackConsumptionProgress && !existingConsumptionSettings.ShouldTrackConsumptionProgress;
|
||||
Optional<int> completionThresholdPercentage = Optional<int>.FromNullable(command.CompletionThresholdPercentage);
|
||||
if (completionThresholdPercentage.HasValue && !shouldTrackConsumptionProgress)
|
||||
return DomainErrors.Library.CompletionThresholdPercentageMustBeNullWhenProgressTrackingIsOff;
|
||||
if (!completionThresholdPercentage.HasValue && shouldTrackConsumptionProgress)
|
||||
{
|
||||
completionThresholdPercentage = existingConsumptionSettings.CompletionThresholdPercentage;
|
||||
// Enabling progress tracking on a library that did not track it yet must use the same type default that creating the library would have used.
|
||||
if (!completionThresholdPercentage.HasValue && isEnablingConsumptionProgressTracking)
|
||||
completionThresholdPercentage = LibraryConsumptionSettings.CreateDefault(newLibraryType).CompletionThresholdPercentage;
|
||||
}
|
||||
LibraryConsumptionSettings consumptionSettings = LibraryConsumptionSettings.Create(shouldTrackConsumptionProgress, completionThresholdPercentage);
|
||||
|
||||
// A library always carries a path template: the one provided by the user, or the ideal structure of the library type as its default.
|
||||
Result<IReadOnlyList<LibraryPathPart>> pathTemplatePartsResult = command.PathTemplateParts.ToDomainParts();
|
||||
if (pathTemplatePartsResult.IsFailure)
|
||||
@@ -150,6 +169,7 @@ public class UpdateLibraryCommandHandler : ICommandHandler<UpdateLibraryCommand,
|
||||
command.CanDownloadMetadataFromWeb,
|
||||
command.ShouldSaveMetadataInMediaDirectories,
|
||||
command.ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
consumptionSettings,
|
||||
pathTemplateResult.Value,
|
||||
[.. getLibraryResult.Value.LibraryScans.Select(libraryScan => ScanId.Create(libraryScan.Id))]
|
||||
);
|
||||
|
||||
+8
@@ -54,6 +54,14 @@ public class UpdateLibraryCommandValidator : AbstractValidator<UpdateLibraryComm
|
||||
.MaximumLength(255)
|
||||
.WithError(Errors.Library.TitleMustBeMaximum255CharactersLong);
|
||||
|
||||
RuleFor(command => command.CompletionThresholdPercentage)
|
||||
.Must((command, completionThresholdPercentage) => command.ShouldTrackConsumptionProgress != false || completionThresholdPercentage is null)
|
||||
.WithError(Errors.Library.CompletionThresholdPercentageMustBeNullWhenProgressTrackingIsOff);
|
||||
|
||||
RuleFor(command => command.CompletionThresholdPercentage)
|
||||
.InclusiveBetween(0, 100)
|
||||
.WithError(Errors.Library.CompletionThresholdPercentageMustBeBetweenZeroAndOneHundred);
|
||||
|
||||
RuleForEach(command => command.PathTemplateParts)
|
||||
.ChildRules(part =>
|
||||
{
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
/// <param name="CanDownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not. Optional.</param>
|
||||
/// <param name="ShouldSaveMetadataInMediaDirectories">Whether this media library should copy the downloaded metadata into the media library content locations, or not. Optional.</param>
|
||||
/// <param name="ShouldSkipUnchangedDirectoriesDuringScan">Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not. Optional.</param>
|
||||
/// <param name="ShouldTrackConsumptionProgress">Whether the consumption progress of the media library items should be tracked, or not. Optional, the default of the library type is used when absent.</param>
|
||||
/// <param name="CompletionThresholdPercentage">The percentage of a media library item that must be consumed for its session to be considered completed. Optional, the default of the library type is used when absent.</param>
|
||||
/// <param name="PathTemplateParts">The ordered parts of the template describing the structure of the media library on disk. Optional, the ideal structure of the library type is used when absent.</param>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
public record AddLibraryRequest(
|
||||
@@ -28,5 +30,7 @@ public record AddLibraryRequest(
|
||||
bool CanDownloadMetadataFromWeb,
|
||||
bool ShouldSaveMetadataInMediaDirectories,
|
||||
bool ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
bool? ShouldTrackConsumptionProgress,
|
||||
int? CompletionThresholdPercentage,
|
||||
LibraryPathTemplatePartRequest[]? PathTemplateParts
|
||||
);
|
||||
@@ -19,6 +19,8 @@ namespace Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
/// <param name="CanDownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not. Optional.</param>
|
||||
/// <param name="ShouldSaveMetadataInMediaDirectories">Whether this media library should copy the downloaded metadata into the media library content locations, or not.
|
||||
/// <param name="ShouldSkipUnchangedDirectoriesDuringScan">Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not. Optional.</param>
|
||||
/// <param name="ShouldTrackConsumptionProgress">Whether the consumption progress of the media library items should be tracked, or not. Optional, the stored value is kept when absent.</param>
|
||||
/// <param name="CompletionThresholdPercentage">The percentage of a media library item that must be consumed for its session to be considered completed. Optional, the stored value is kept when absent.</param>
|
||||
/// <param name="PathTemplateParts">The ordered parts of the template describing the structure of the media library on disk. Optional, the ideal structure of the library type is used when absent.</param>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
public record class UpdateLibraryRequest(
|
||||
@@ -33,5 +35,7 @@ public record class UpdateLibraryRequest(
|
||||
bool CanDownloadMetadataFromWeb,
|
||||
bool ShouldSaveMetadataInMediaDirectories,
|
||||
bool ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
bool? ShouldTrackConsumptionProgress,
|
||||
int? CompletionThresholdPercentage,
|
||||
LibraryPathTemplatePartRequest[]? PathTemplateParts
|
||||
);
|
||||
@@ -21,6 +21,8 @@ namespace Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
/// <param name="CanDownloadMetadataFromWeb">Whether the media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="ShouldSaveMetadataInMediaDirectories">Whether the media library should copy the downloaded metadata into the media library content locations, or not.</param>
|
||||
/// <param name="ShouldSkipUnchangedDirectoriesDuringScan">Whether the media library should skip the directories whose contents have not changed since the last scan, during the scan.</param>
|
||||
/// <param name="ShouldTrackConsumptionProgress">Whether the consumption progress of the media library items is tracked.</param>
|
||||
/// <param name="CompletionThresholdPercentage">The percentage of a media library item that must be consumed for its session to be considered completed, when progress tracking is enabled.</param>
|
||||
/// <param name="PathTemplateParts">The ordered parts of the template describing the structure of the media library on disk.</param>
|
||||
/// <param name="CreatedOnUtc">The date and time when the library was created.</param>
|
||||
/// <param name="UpdatedOnUtc">The optional date and time when the library was updated.</param>
|
||||
@@ -37,6 +39,8 @@ public record LibraryResponse(
|
||||
bool CanDownloadMetadataFromWeb,
|
||||
bool ShouldSaveMetadataInMediaDirectories,
|
||||
bool ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
bool ShouldTrackConsumptionProgress,
|
||||
int? CompletionThresholdPercentage,
|
||||
List<LibraryPathTemplatePartResponse> PathTemplateParts,
|
||||
DateTime CreatedOnUtc,
|
||||
DateTime? UpdatedOnUtc
|
||||
|
||||
@@ -71,6 +71,14 @@ public class LibraryConfiguration : IEntityTypeConfiguration<LibraryEntity>
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(11);
|
||||
|
||||
builder.Property(library => library.ShouldTrackConsumptionProgress)
|
||||
.HasDefaultValue(false)
|
||||
.HasColumnOrder(12);
|
||||
|
||||
builder.Property(library => library.CompletionThresholdPercentage)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(13);
|
||||
|
||||
// one user with many libraries
|
||||
builder.HasOne(library => library.User)
|
||||
.WithMany(user => user.Libraries)
|
||||
@@ -130,18 +138,18 @@ public class LibraryConfiguration : IEntityTypeConfiguration<LibraryEntity>
|
||||
// audit
|
||||
builder.Property(library => library.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(12);
|
||||
.HasColumnOrder(14);
|
||||
|
||||
builder.Property(library => library.CreatedBy)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(13);
|
||||
.HasColumnOrder(15);
|
||||
|
||||
builder.Property(library => library.UpdatedOnUtc)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(14);
|
||||
.HasColumnOrder(16);
|
||||
|
||||
builder.Property(library => library.UpdatedBy)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(15);
|
||||
.HasColumnOrder(17);
|
||||
}
|
||||
}
|
||||
Generated
+3776
File diff suppressed because it is too large.
Load diff
+41
@@ -0,0 +1,41 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Lumina.DataAccess.Common.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddsLibraryConsumptionSettings : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "CompletionThresholdPercentage",
|
||||
table: "Libraries",
|
||||
type: "INTEGER",
|
||||
nullable: true)
|
||||
.Annotation("Relational:ColumnOrder", 17);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "ShouldTrackConsumptionProgress",
|
||||
table: "Libraries",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: false)
|
||||
.Annotation("Relational:ColumnOrder", 16);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CompletionThresholdPercentage",
|
||||
table: "Libraries");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ShouldTrackConsumptionProgress",
|
||||
table: "Libraries");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1402,6 +1402,10 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
.HasDefaultValue(true)
|
||||
.HasColumnOrder(6);
|
||||
|
||||
b.Property<int?>("CompletionThresholdPercentage")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnOrder(17);
|
||||
|
||||
b.Property<string>("CoverImage")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("TEXT")
|
||||
@@ -1448,6 +1452,12 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnOrder(8);
|
||||
|
||||
b.Property<bool>("ShouldTrackConsumptionProgress")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasDefaultValue(false)
|
||||
.HasColumnOrder(16);
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasMaxLength(255)
|
||||
|
||||
@@ -29,5 +29,7 @@ public static partial class Errors
|
||||
public static Error PathTemplateValuePartMustContainSinglePlaceholder => Error.Validation(description: nameof(PathTemplateValuePartMustContainSinglePlaceholder));
|
||||
public static Error PathTemplatePartKindNotSupportedForLibraryType => Error.Validation(description: nameof(PathTemplatePartKindNotSupportedForLibraryType));
|
||||
public static Error PathTemplateIsNotSupportedForLibraryType => Error.Validation(description: nameof(PathTemplateIsNotSupportedForLibraryType));
|
||||
public static Error CompletionThresholdPercentageMustBeNullWhenProgressTrackingIsOff => Error.Validation(description: nameof(CompletionThresholdPercentageMustBeNullWhenProgressTrackingIsOff));
|
||||
public static Error CompletionThresholdPercentageMustBeBetweenZeroAndOneHundred => Error.Validation(description: nameof(CompletionThresholdPercentageMustBeBetweenZeroAndOneHundred));
|
||||
}
|
||||
}
|
||||
+14
@@ -76,6 +76,11 @@ public class Library : AggregateRoot<LibraryId>
|
||||
/// </summary>
|
||||
public bool ShouldSkipUnchangedDirectoriesDuringScan { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the consumption settings of the media library.
|
||||
/// </summary>
|
||||
public LibraryConsumptionSettings ConsumptionSettings { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the template describing the structure of the media library on disk, always populated with the effective template: the one specified by the
|
||||
/// user, or the ideal structure of the library type when none was provided.
|
||||
@@ -106,6 +111,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether this media library should copy the downloaded metadata into the media library content locations, or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.</param>
|
||||
/// <param name="consumptionSettings">The consumption settings of the media library.</param>
|
||||
/// <param name="pathTemplate">The template describing the structure of the media library on disk.</param>
|
||||
/// <param name="scanIds">The list of objects representing the unique identifier of scans of the media library.</param>
|
||||
private Library(
|
||||
@@ -120,6 +126,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
bool canDownloadMetadataFromWeb,
|
||||
bool shouldSaveMetadataInMediaDirectories,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan,
|
||||
LibraryConsumptionSettings consumptionSettings,
|
||||
LibraryPathTemplate pathTemplate,
|
||||
List<ScanId> scanIds) : base(id)
|
||||
{
|
||||
@@ -133,6 +140,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
CanDownloadMetadataFromWeb = canDownloadMetadataFromWeb;
|
||||
ShouldSaveMetadataInMediaDirectories = shouldSaveMetadataInMediaDirectories;
|
||||
ShouldSkipUnchangedDirectoriesDuringScan = shouldSkipUnchangedDirectoriesDuringScan;
|
||||
ConsumptionSettings = consumptionSettings;
|
||||
PathTemplate = pathTemplate;
|
||||
_scanIds = scanIds;
|
||||
}
|
||||
@@ -150,6 +158,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether this media library should copy the downloaded metadata into the media library content locations, or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.</param>
|
||||
/// <param name="consumptionSettings">The consumption settings of the media library.</param>
|
||||
/// <param name="pathTemplate">The template describing the structure of the media library on disk.</param>
|
||||
/// <param name="scanIds">The list of objects representing the unique identifier of scans of the media library.</param>
|
||||
/// <returns>
|
||||
@@ -166,6 +175,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
bool canDownloadMetadataFromWeb,
|
||||
bool shouldSaveMetadataInMediaDirectories,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan,
|
||||
LibraryConsumptionSettings consumptionSettings,
|
||||
LibraryPathTemplate pathTemplate,
|
||||
List<ScanId> scanIds)
|
||||
{
|
||||
@@ -190,6 +200,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
canDownloadMetadataFromWeb,
|
||||
shouldSaveMetadataInMediaDirectories,
|
||||
shouldSkipUnchangedDirectoriesDuringScan,
|
||||
consumptionSettings,
|
||||
pathTemplate,
|
||||
scanIds
|
||||
);
|
||||
@@ -209,6 +220,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether this media library should copy the downloaded metadata into the media library content locations, or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.</param>
|
||||
/// <param name="consumptionSettings">The consumption settings of the media library.</param>
|
||||
/// <param name="pathTemplate">The template describing the structure of the media library on disk.</param>
|
||||
/// <param name="scanIds">The list of objects representing the unique identifier of scans of the media library.</param>
|
||||
/// <returns>
|
||||
@@ -226,6 +238,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
bool canDownloadMetadataFromWeb,
|
||||
bool shouldSaveMetadataInMediaDirectories,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan,
|
||||
LibraryConsumptionSettings consumptionSettings,
|
||||
LibraryPathTemplate pathTemplate,
|
||||
List<ScanId> scanIds)
|
||||
{
|
||||
@@ -250,6 +263,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
canDownloadMetadataFromWeb,
|
||||
shouldSaveMetadataInMediaDirectories,
|
||||
shouldSkipUnchangedDirectoriesDuringScan,
|
||||
consumptionSettings,
|
||||
pathTemplate,
|
||||
scanIds
|
||||
);
|
||||
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the consumption settings of a media library.
|
||||
/// </summary>
|
||||
public sealed class LibraryConsumptionSettings : ValueObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the consumption progress of the media library items is tracked.
|
||||
/// </summary>
|
||||
public bool ShouldTrackConsumptionProgress { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the percentage of a media library item that must be consumed for its session to be considered completed. The value is absent when
|
||||
/// progress tracking is disabled, and for library types whose completion is only recorded explicitly.
|
||||
/// </summary>
|
||||
public Optional<int> CompletionThresholdPercentage { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibraryConsumptionSettings"/> class.
|
||||
/// </summary>
|
||||
/// <param name="shouldTrackConsumptionProgress">Whether the consumption progress of the media library items is tracked.</param>
|
||||
/// <param name="completionThresholdPercentage">The percentage of a media library item that must be consumed for its session to be considered completed.</param>
|
||||
private LibraryConsumptionSettings(bool shouldTrackConsumptionProgress, Optional<int> completionThresholdPercentage)
|
||||
{
|
||||
ShouldTrackConsumptionProgress = shouldTrackConsumptionProgress;
|
||||
// A completion threshold has no meaning when progress is not tracked, so it is never stored in that case.
|
||||
CompletionThresholdPercentage = shouldTrackConsumptionProgress ? completionThresholdPercentage : Optional<int>.None();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="LibraryConsumptionSettings"/> class.
|
||||
/// </summary>
|
||||
/// <param name="shouldTrackConsumptionProgress">Whether the consumption progress of the media library items is tracked.</param>
|
||||
/// <param name="completionThresholdPercentage">The percentage of a media library item that must be consumed for its session to be considered completed.</param>
|
||||
/// <returns>The created consumption settings.</returns>
|
||||
public static LibraryConsumptionSettings Create(bool shouldTrackConsumptionProgress, Optional<int> completionThresholdPercentage)
|
||||
{
|
||||
return new LibraryConsumptionSettings(shouldTrackConsumptionProgress, completionThresholdPercentage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the default consumption settings for <paramref name="libraryType"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A library type without a default completion threshold is created with progress tracking off. If progress tracking is enabled explicitly for
|
||||
/// such a type without a threshold, completion is only recorded when it is reported explicitly.
|
||||
/// </remarks>
|
||||
/// <param name="libraryType">The type of the media library for which to create the default consumption settings.</param>
|
||||
/// <returns>The default consumption settings of the media library type.</returns>
|
||||
public static LibraryConsumptionSettings CreateDefault(LibraryType libraryType)
|
||||
{
|
||||
return libraryType switch
|
||||
{
|
||||
// Written content.
|
||||
LibraryType.Book or LibraryType.EBook or LibraryType.ComicBook or LibraryType.Magazine or LibraryType.Newspaper or LibraryType.Manga or
|
||||
LibraryType.GraphicNovel or LibraryType.AcademicPaper or LibraryType.SheetMusic
|
||||
=> Create(shouldTrackConsumptionProgress: true, Optional<int>.Some(100)),
|
||||
// Video.
|
||||
LibraryType.TvShow or LibraryType.Movie or LibraryType.Documentary or LibraryType.Anime or LibraryType.ConcertVideo or LibraryType.TutorialVideo or
|
||||
LibraryType.HomeVideo or LibraryType.YouTubeVideo or LibraryType.MusicVideo or LibraryType.LiveRecordingVideo or LibraryType.InterviewVideo or
|
||||
LibraryType.CoverSongVideo
|
||||
=> Create(shouldTrackConsumptionProgress: true, Optional<int>.Some(90)),
|
||||
// Audiobooks and podcasts.
|
||||
LibraryType.Audiobook or LibraryType.PodcastAudio or LibraryType.PodcastVideo
|
||||
=> Create(shouldTrackConsumptionProgress: true, Optional<int>.Some(95)),
|
||||
// Music audio and photos.
|
||||
LibraryType.Music or LibraryType.Remix or LibraryType.SoundEffect or LibraryType.LiveRecordingAudio or LibraryType.InterviewAudio or
|
||||
LibraryType.CoverSongAudio or LibraryType.Photo
|
||||
=> Create(shouldTrackConsumptionProgress: false, Optional<int>.None()),
|
||||
// Library types that are not media libraries, and any type added later, stay off until they are classified here.
|
||||
LibraryType.Playlist or LibraryType.Collection or LibraryType.Subtitles or LibraryType.Lyrics or LibraryType.Other
|
||||
=> Create(shouldTrackConsumptionProgress: false, Optional<int>.None()),
|
||||
_ => Create(shouldTrackConsumptionProgress: false, Optional<int>.None())
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the default consumption settings for <paramref name="mediaKind"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A media kind without a default completion threshold is created with progress tracking off. If progress tracking is enabled explicitly for
|
||||
/// such a kind without a threshold, completion is only recorded when it is reported explicitly.
|
||||
/// </remarks>
|
||||
/// <param name="mediaKind">The kind of media for which to create the default consumption settings.</param>
|
||||
/// <returns>The default consumption settings of the media kind.</returns>
|
||||
public static LibraryConsumptionSettings CreateDefault(MediaKind mediaKind)
|
||||
{
|
||||
return mediaKind switch
|
||||
{
|
||||
MediaKind.Book => Create(shouldTrackConsumptionProgress: true, Optional<int>.Some(100)),
|
||||
MediaKind.Movie or MediaKind.TvEpisode or MediaKind.Video => Create(shouldTrackConsumptionProgress: true, Optional<int>.Some(90)),
|
||||
MediaKind.PodcastEpisode or MediaKind.Audiobook => Create(shouldTrackConsumptionProgress: true, Optional<int>.Some(95)),
|
||||
// Kinds that do not track progress, and any kind added later, stay off until they are classified here.
|
||||
MediaKind.None or MediaKind.MusicTrack or MediaKind.Photo => Create(shouldTrackConsumptionProgress: false, Optional<int>.None()),
|
||||
_ => Create(shouldTrackConsumptionProgress: false, Optional<int>.None())
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of items that define equality of the object.
|
||||
/// </summary>
|
||||
/// <returns>A list of items defining the equality.</returns>
|
||||
public override IEnumerable<object?> GetEqualityComponents()
|
||||
{
|
||||
yield return ShouldTrackConsumptionProgress;
|
||||
yield return CompletionThresholdPercentage;
|
||||
}
|
||||
}
|
||||
+10
@@ -37,6 +37,8 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: false,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
ShouldTrackConsumptionProgress: true,
|
||||
CompletionThresholdPercentage: 90,
|
||||
PathTemplateParts: null
|
||||
);
|
||||
|
||||
@@ -49,6 +51,8 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
|
||||
RequestParam(r => r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not. Optional.");
|
||||
RequestParam(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not. Optional.");
|
||||
RequestParam(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not. Optional.");
|
||||
RequestParam(r => r.ShouldTrackConsumptionProgress, "Whether the consumption progress of the media library items should be tracked, or not. Optional, the default of the library type is used when absent.");
|
||||
RequestParam(r => r.CompletionThresholdPercentage, "The percentage of a media library item that must be consumed for its session to be considered completed. Optional, the default of the library type is used when absent.");
|
||||
RequestParam(r => r.PathTemplateParts, "The ordered parts of the template describing the structure of the media library on disk. Optional, the ideal structure of the library type is used when absent.");
|
||||
|
||||
ResponseParam<LibraryResponse>(r => r.Id, "The unique identifier of the entity.");
|
||||
@@ -62,6 +66,8 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
|
||||
ResponseParam<LibraryResponse>(r => r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldTrackConsumptionProgress, "Whether the consumption progress of the media library items is tracked.");
|
||||
ResponseParam<LibraryResponse>(r => r.CompletionThresholdPercentage, "The percentage of a media library item that must be consumed for its session to be considered completed, when progress tracking is enabled.");
|
||||
ResponseParam<LibraryResponse>(r => r.PathTemplateParts, "The ordered parts of the template describing the structure of the media library on disk.");
|
||||
ResponseParam<LibraryResponse>(r => r.CreatedOnUtc, "The date and time when the entity was created.");
|
||||
ResponseParam<LibraryResponse>(r => r.UpdatedOnUtc, "The date and time when the entity was last updated.");
|
||||
@@ -79,6 +85,8 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: false,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
ShouldTrackConsumptionProgress: true,
|
||||
CompletionThresholdPercentage: 90,
|
||||
PathTemplateParts: [],
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: default
|
||||
@@ -158,6 +166,8 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
|
||||
"PathMustBeMaximum260CharactersLong",
|
||||
"TitleCannotBeEmpty",
|
||||
"TitleMustBeMaximum255CharactersLong",
|
||||
"CompletionThresholdPercentageMustBeNullWhenProgressTrackingIsOff",
|
||||
"CompletionThresholdPercentageMustBeBetweenZeroAndOneHundred",
|
||||
"CoverFileMustBeAnImage"
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -33,6 +33,8 @@ public class GetEnabledLibrariesEndpointSummary : Summary<GetEnabledLibrariesEnd
|
||||
ResponseParam<LibraryResponse>(r => r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldTrackConsumptionProgress, "Whether the consumption progress of the media library items is tracked.");
|
||||
ResponseParam<LibraryResponse>(r => r.CompletionThresholdPercentage, "The percentage of a media library item that must be consumed for its session to be considered completed, when progress tracking is enabled.");
|
||||
ResponseParam<LibraryResponse>(r => r.PathTemplateParts, "The ordered parts of the template describing the structure of the media library on disk.");
|
||||
ResponseParam<LibraryResponse>(r => r.CreatedOnUtc, "The date and time when the entity was created.");
|
||||
ResponseParam<LibraryResponse>(r => r.UpdatedOnUtc, "The date and time when the entity was last updated.");
|
||||
@@ -51,6 +53,8 @@ public class GetEnabledLibrariesEndpointSummary : Summary<GetEnabledLibrariesEnd
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: false,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
ShouldTrackConsumptionProgress: true,
|
||||
CompletionThresholdPercentage: 90,
|
||||
PathTemplateParts: [],
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: default
|
||||
@@ -67,6 +71,8 @@ public class GetEnabledLibrariesEndpointSummary : Summary<GetEnabledLibrariesEnd
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: true,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
ShouldTrackConsumptionProgress: true,
|
||||
CompletionThresholdPercentage: 90,
|
||||
PathTemplateParts: [],
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: default
|
||||
|
||||
+6
@@ -33,6 +33,8 @@ public class GetLibrariesEndpointSummary : Summary<GetLibrariesEndpoint, EmptyRe
|
||||
ResponseParam<LibraryResponse>(r => r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldTrackConsumptionProgress, "Whether the consumption progress of the media library items is tracked.");
|
||||
ResponseParam<LibraryResponse>(r => r.CompletionThresholdPercentage, "The percentage of a media library item that must be consumed for its session to be considered completed, when progress tracking is enabled.");
|
||||
ResponseParam<LibraryResponse>(r => r.PathTemplateParts, "The ordered parts of the template describing the structure of the media library on disk.");
|
||||
ResponseParam<LibraryResponse>(r => r.CreatedOnUtc, "The date and time when the entity was created.");
|
||||
ResponseParam<LibraryResponse>(r => r.UpdatedOnUtc, "The date and time when the entity was last updated.");
|
||||
@@ -51,6 +53,8 @@ public class GetLibrariesEndpointSummary : Summary<GetLibrariesEndpoint, EmptyRe
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: false,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
ShouldTrackConsumptionProgress: true,
|
||||
CompletionThresholdPercentage: 90,
|
||||
PathTemplateParts: [],
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: default
|
||||
@@ -67,6 +71,8 @@ public class GetLibrariesEndpointSummary : Summary<GetLibrariesEndpoint, EmptyRe
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: true,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
ShouldTrackConsumptionProgress: true,
|
||||
CompletionThresholdPercentage: 90,
|
||||
PathTemplateParts: [],
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: default
|
||||
|
||||
+4
@@ -41,6 +41,8 @@ public class GetLibraryEndpointSummary : Summary<GetLibraryEndpoint, GetLibraryR
|
||||
ResponseParam<LibraryResponse>(r => r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldTrackConsumptionProgress, "Whether the consumption progress of the media library items is tracked.");
|
||||
ResponseParam<LibraryResponse>(r => r.CompletionThresholdPercentage, "The percentage of a media library item that must be consumed for its session to be considered completed, when progress tracking is enabled.");
|
||||
ResponseParam<LibraryResponse>(r => r.PathTemplateParts, "The ordered parts of the template describing the structure of the media library on disk.");
|
||||
ResponseParam<LibraryResponse>(r => r.CreatedOnUtc, "The date and time when the entity was created.");
|
||||
ResponseParam<LibraryResponse>(r => r.UpdatedOnUtc, "The date and time when the entity was last updated.");
|
||||
@@ -57,6 +59,8 @@ public class GetLibraryEndpointSummary : Summary<GetLibraryEndpoint, GetLibraryR
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: false,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
ShouldTrackConsumptionProgress: true,
|
||||
CompletionThresholdPercentage: 90,
|
||||
PathTemplateParts: [],
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: default
|
||||
|
||||
+11
-1
@@ -39,6 +39,8 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: false,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
ShouldTrackConsumptionProgress: true,
|
||||
CompletionThresholdPercentage: 90,
|
||||
PathTemplateParts: null
|
||||
);
|
||||
|
||||
@@ -53,6 +55,8 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
RequestParam(r => r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not. Optional.");
|
||||
RequestParam(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not. Optional.");
|
||||
RequestParam(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not. Optional.");
|
||||
RequestParam(r => r.ShouldTrackConsumptionProgress, "Whether the consumption progress of the media library items should be tracked, or not. Optional, the stored value is kept when absent.");
|
||||
RequestParam(r => r.CompletionThresholdPercentage, "The percentage of a media library item that must be consumed for its session to be considered completed. Optional, the stored value is kept when absent.");
|
||||
RequestParam(r => r.PathTemplateParts, "The ordered parts of the template describing the structure of the media library on disk. Optional, the ideal structure of the library type is used when absent.");
|
||||
|
||||
ResponseParam<LibraryResponse>(r => r.Id, "The unique identifier of the entity.");
|
||||
@@ -66,6 +70,8 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
ResponseParam<LibraryResponse>(r => r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldTrackConsumptionProgress, "Whether the consumption progress of the media library items is tracked.");
|
||||
ResponseParam<LibraryResponse>(r => r.CompletionThresholdPercentage, "The percentage of a media library item that must be consumed for its session to be considered completed, when progress tracking is enabled.");
|
||||
ResponseParam<LibraryResponse>(r => r.PathTemplateParts, "The ordered parts of the template describing the structure of the media library on disk.");
|
||||
ResponseParam<LibraryResponse>(r => r.CreatedOnUtc, "The date and time when the entity was created.");
|
||||
ResponseParam<LibraryResponse>(r => r.UpdatedOnUtc, "The date and time when the entity was last updated.");
|
||||
@@ -83,6 +89,8 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: false,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
ShouldTrackConsumptionProgress: true,
|
||||
CompletionThresholdPercentage: 90,
|
||||
PathTemplateParts: [],
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: default
|
||||
@@ -175,7 +183,9 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
"PathCannotBeEmpty",
|
||||
"PathMustBeMaximum260CharactersLong",
|
||||
"TitleCannotBeEmpty",
|
||||
"TitleMustBeMaximum255CharactersLong"
|
||||
"TitleMustBeMaximum255CharactersLong",
|
||||
"CompletionThresholdPercentageMustBeNullWhenProgressTrackingIsOff",
|
||||
"CompletionThresholdPercentageMustBeBetweenZeroAndOneHundred"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
+6
@@ -33,6 +33,8 @@ public class LibraryEntityFixture
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether the media library should download metadata from the web or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether the metadata should be saved in the media directories or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether unchanged directories should be skipped during a scan or not.</param>
|
||||
/// <param name="shouldTrackConsumptionProgress">Whether the consumption progress of the media library items is tracked.</param>
|
||||
/// <param name="completionThresholdPercentage">The percentage of a media library item that must be consumed for its session to be considered completed.</param>
|
||||
/// <param name="metadataProvidersConfigurationFingerprint">Optional. The fingerprint of the metadata provider configuration of the media library.</param>
|
||||
/// <param name="artworkProvidersConfigurationFingerprint">Optional. The fingerprint of the artwork provider configuration of the media library.</param>
|
||||
/// <param name="pathTemplateParts">Optional. The ordered parts of the path template of the media library.</param>
|
||||
@@ -50,6 +52,8 @@ public class LibraryEntityFixture
|
||||
bool canDownloadMetadataFromWeb = true,
|
||||
bool shouldSaveMetadataInMediaDirectories = true,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan = false,
|
||||
bool shouldTrackConsumptionProgress = false,
|
||||
int? completionThresholdPercentage = null,
|
||||
string? metadataProvidersConfigurationFingerprint = null,
|
||||
string? artworkProvidersConfigurationFingerprint = null,
|
||||
IEnumerable<LibraryPathTemplatePartEntity>? pathTemplateParts = null,
|
||||
@@ -71,6 +75,8 @@ public class LibraryEntityFixture
|
||||
CanDownloadMetadataFromWeb = canDownloadMetadataFromWeb,
|
||||
ShouldSaveMetadataInMediaDirectories = shouldSaveMetadataInMediaDirectories,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan = shouldSkipUnchangedDirectoriesDuringScan,
|
||||
ShouldTrackConsumptionProgress = shouldTrackConsumptionProgress,
|
||||
CompletionThresholdPercentage = completionThresholdPercentage,
|
||||
MetadataProvidersConfigurationFingerprint = metadataProvidersConfigurationFingerprint,
|
||||
ArtworkProvidersConfigurationFingerprint = artworkProvidersConfigurationFingerprint,
|
||||
PathTemplateFingerprint = pathTemplateFingerprint,
|
||||
|
||||
+6
@@ -28,6 +28,8 @@ public class AddLibraryCommandFixture
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether the media library should download metadata from the web or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether the metadata should be saved in the media directories or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether unchanged directories should be skipped during a scan or not.</param>
|
||||
/// <param name="shouldTrackConsumptionProgress">Optional. Whether the consumption progress of the media library items should be tracked, or not.</param>
|
||||
/// <param name="completionThresholdPercentage">Optional. The percentage of a media library item that must be consumed for its session to be considered completed.</param>
|
||||
/// <param name="pathTemplateParts">Optional. The ordered parts of the path template of the media library.</param>
|
||||
/// <returns>The created command.</returns>
|
||||
public AddLibraryCommand Create(
|
||||
@@ -40,6 +42,8 @@ public class AddLibraryCommandFixture
|
||||
bool canDownloadMetadataFromWeb = true,
|
||||
bool shouldSaveMetadataInMediaDirectories = true,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan = false,
|
||||
bool? shouldTrackConsumptionProgress = null,
|
||||
int? completionThresholdPercentage = null,
|
||||
LibraryPathTemplatePartDto[]? pathTemplateParts = null)
|
||||
{
|
||||
return new Faker<AddLibraryCommand>()
|
||||
@@ -53,6 +57,8 @@ public class AddLibraryCommandFixture
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
shouldTrackConsumptionProgress,
|
||||
completionThresholdPercentage,
|
||||
null
|
||||
))
|
||||
.RuleFor(x => x.Title, f => title ?? f.Lorem.Word())
|
||||
|
||||
+6
@@ -31,6 +31,8 @@ public class UpdateLibraryCommandFixture
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether the media library should download metadata from the web or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether the metadata should be saved in the media directories or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether unchanged directories should be skipped during a scan or not.</param>
|
||||
/// <param name="shouldTrackConsumptionProgress">Optional. Whether the consumption progress of the media library items should be tracked, or not.</param>
|
||||
/// <param name="completionThresholdPercentage">Optional. The percentage of a media library item that must be consumed for its session to be considered completed.</param>
|
||||
/// <param name="pathTemplateParts">Optional. The ordered parts of the path template of the media library.</param>
|
||||
/// <returns>The created command.</returns>
|
||||
public UpdateLibraryCommand Create(
|
||||
@@ -45,6 +47,8 @@ public class UpdateLibraryCommandFixture
|
||||
bool canDownloadMetadataFromWeb = true,
|
||||
bool shouldSaveMetadataInMediaDirectories = true,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan = false,
|
||||
bool? shouldTrackConsumptionProgress = null,
|
||||
int? completionThresholdPercentage = null,
|
||||
LibraryPathTemplatePartDto[]? pathTemplateParts = null)
|
||||
{
|
||||
return new Faker<UpdateLibraryCommand>()
|
||||
@@ -60,6 +64,8 @@ public class UpdateLibraryCommandFixture
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
shouldTrackConsumptionProgress,
|
||||
completionThresholdPercentage,
|
||||
null
|
||||
))
|
||||
.RuleFor(x => x.Id, id ?? Guid.NewGuid())
|
||||
|
||||
+6
@@ -28,6 +28,8 @@ public class AddLibraryRequestFixture
|
||||
/// <param name="canDownloadMetadataFromWeb">Optional. Whether metadata should be downloaded from the web.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Optional. Whether metadata should be saved in the media directories.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Optional. Whether unchanged directories should be skipped during scan.</param>
|
||||
/// <param name="shouldTrackConsumptionProgress">Optional. Whether the consumption progress of the media library items should be tracked, or not.</param>
|
||||
/// <param name="completionThresholdPercentage">Optional. The percentage of a media library item that must be consumed for its session to be considered completed.</param>
|
||||
/// <param name="pathTemplateParts">Optional. The ordered parts of the path template of the media library.</param>
|
||||
/// <returns>The created <see cref="AddLibraryRequest"/>.</returns>
|
||||
public AddLibraryRequest Create(
|
||||
@@ -40,6 +42,8 @@ public class AddLibraryRequestFixture
|
||||
bool? canDownloadMetadataFromWeb = null,
|
||||
bool? shouldSaveMetadataInMediaDirectories = null,
|
||||
bool? shouldSkipUnchangedDirectoriesDuringScan = null,
|
||||
bool? shouldTrackConsumptionProgress = null,
|
||||
int? completionThresholdPercentage = null,
|
||||
LibraryPathTemplatePartRequest[]? pathTemplateParts = null)
|
||||
{
|
||||
return new AddLibraryRequest(
|
||||
@@ -52,6 +56,8 @@ public class AddLibraryRequestFixture
|
||||
canDownloadMetadataFromWeb ?? _faker.Random.Bool(),
|
||||
shouldSaveMetadataInMediaDirectories ?? _faker.Random.Bool(),
|
||||
shouldSkipUnchangedDirectoriesDuringScan ?? _faker.Random.Bool(),
|
||||
shouldTrackConsumptionProgress,
|
||||
completionThresholdPercentage,
|
||||
pathTemplateParts
|
||||
);
|
||||
}
|
||||
|
||||
+6
@@ -31,6 +31,8 @@ public class UpdateLibraryRequestFixture
|
||||
/// <param name="canDownloadMetadataFromWeb">Optional. Whether metadata should be downloaded from the web.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Optional. Whether metadata should be saved in the media directories.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Optional. Whether unchanged directories should be skipped during scan.</param>
|
||||
/// <param name="shouldTrackConsumptionProgress">Optional. Whether the consumption progress of the media library items should be tracked, or not.</param>
|
||||
/// <param name="completionThresholdPercentage">Optional. The percentage of a media library item that must be consumed for its session to be considered completed.</param>
|
||||
/// <param name="pathTemplateParts">Optional. The ordered parts of the path template of the media library.</param>
|
||||
/// <returns>The created <see cref="UpdateLibraryRequest"/>.</returns>
|
||||
public UpdateLibraryRequest Create(
|
||||
@@ -45,6 +47,8 @@ public class UpdateLibraryRequestFixture
|
||||
bool? canDownloadMetadataFromWeb = null,
|
||||
bool? shouldSaveMetadataInMediaDirectories = null,
|
||||
bool? shouldSkipUnchangedDirectoriesDuringScan = null,
|
||||
bool? shouldTrackConsumptionProgress = null,
|
||||
int? completionThresholdPercentage = null,
|
||||
LibraryPathTemplatePartRequest[]? pathTemplateParts = null)
|
||||
{
|
||||
return new UpdateLibraryRequest(
|
||||
@@ -59,6 +63,8 @@ public class UpdateLibraryRequestFixture
|
||||
canDownloadMetadataFromWeb ?? _faker.Random.Bool(),
|
||||
shouldSaveMetadataInMediaDirectories ?? _faker.Random.Bool(),
|
||||
shouldSkipUnchangedDirectoriesDuringScan ?? _faker.Random.Bool(),
|
||||
shouldTrackConsumptionProgress,
|
||||
completionThresholdPercentage,
|
||||
pathTemplateParts
|
||||
);
|
||||
}
|
||||
|
||||
+8
@@ -32,6 +32,8 @@ public class LibraryResponseFixture
|
||||
/// <param name="canDownloadMetadataFromWeb">Optional. Whether metadata should be downloaded from the web.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Optional. Whether metadata should be saved in the media directories.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Optional. Whether unchanged directories should be skipped during scan.</param>
|
||||
/// <param name="shouldTrackConsumptionProgress">Optional. Whether the consumption progress of the media library items is tracked.</param>
|
||||
/// <param name="completionThresholdPercentage">Optional. The percentage of a media library item that must be consumed for its session to be considered completed.</param>
|
||||
/// <param name="pathTemplateParts">Optional. The ordered parts of the path template of the media library.</param>
|
||||
/// <param name="createdOnUtc">Optional. The date and time when the library was created.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The date and time when the library was updated.</param>
|
||||
@@ -48,10 +50,14 @@ public class LibraryResponseFixture
|
||||
bool? canDownloadMetadataFromWeb = null,
|
||||
bool? shouldSaveMetadataInMediaDirectories = null,
|
||||
bool? shouldSkipUnchangedDirectoriesDuringScan = null,
|
||||
bool? shouldTrackConsumptionProgress = null,
|
||||
int? completionThresholdPercentage = null,
|
||||
List<LibraryPathTemplatePartResponse>? pathTemplateParts = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
DateTime? updatedOnUtc = null)
|
||||
{
|
||||
bool resolvedShouldTrackConsumptionProgress = shouldTrackConsumptionProgress ?? _faker.Random.Bool();
|
||||
int? resolvedCompletionThresholdPercentage = completionThresholdPercentage ?? (resolvedShouldTrackConsumptionProgress ? _faker.Random.Int(0, 100) : null);
|
||||
return new LibraryResponse(
|
||||
id ?? Guid.NewGuid(),
|
||||
userId ?? Guid.NewGuid(),
|
||||
@@ -64,6 +70,8 @@ public class LibraryResponseFixture
|
||||
canDownloadMetadataFromWeb ?? _faker.Random.Bool(),
|
||||
shouldSaveMetadataInMediaDirectories ?? _faker.Random.Bool(),
|
||||
shouldSkipUnchangedDirectoriesDuringScan ?? _faker.Random.Bool(),
|
||||
resolvedShouldTrackConsumptionProgress,
|
||||
resolvedCompletionThresholdPercentage,
|
||||
pathTemplateParts ?? [],
|
||||
createdOnUtc ?? _faker.Date.Past().ToUniversalTime(),
|
||||
updatedOnUtc
|
||||
|
||||
+9
-2
@@ -27,6 +27,7 @@ public class LibraryFixture
|
||||
private readonly LibraryIdFixture _libraryIdFixture = new();
|
||||
private readonly UserIdFixture _userIdFixture = new();
|
||||
private readonly ScanIdFixture _scanIdFixture = new();
|
||||
private readonly LibraryConsumptionSettingsFixture _libraryConsumptionSettingsFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="Library"/> domain aggregate.
|
||||
@@ -42,6 +43,7 @@ public class LibraryFixture
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether metadata download from the web is enabled.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether metadata should be saved in the media directories.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether unchanged directories should be skipped during scan.</param>
|
||||
/// <param name="consumptionSettings">Optional. The consumption settings of the library.</param>
|
||||
/// <param name="scanIds">Optional. The scan Ids associated with the library.</param>
|
||||
/// <param name="pathTemplate">Optional. The path template of the library.</param>
|
||||
/// <param name="includeCoverImage">Whether the cover image should be included, or left unset, meaning the library has no cover.</param>
|
||||
@@ -58,6 +60,7 @@ public class LibraryFixture
|
||||
bool canDownloadMetadataFromWeb = true,
|
||||
bool shouldSaveMetadataInMediaDirectories = false,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan = false,
|
||||
LibraryConsumptionSettings? consumptionSettings = null,
|
||||
IEnumerable<Guid>? scanIds = null,
|
||||
LibraryPathTemplate? pathTemplate = null,
|
||||
bool includeCoverImage = true)
|
||||
@@ -71,6 +74,8 @@ public class LibraryFixture
|
||||
];
|
||||
|
||||
UserId resolvedUserId = userId is null ? _userIdFixture.Create() : _userIdFixture.Create(userId.Value);
|
||||
LibraryType resolvedLibraryType = libraryType ?? _faker.PickRandom<LibraryType>();
|
||||
LibraryConsumptionSettings resolvedConsumptionSettings = consumptionSettings ?? _libraryConsumptionSettingsFixture.Create(resolvedLibraryType);
|
||||
List<ScanId> resolvedScanIds = scanIds is null ? [.. _scanIdFixture.CreateMany(2)] : [.. scanIds.Select(scanId => _scanIdFixture.Create(scanId))];
|
||||
string? resolvedCoverImage = includeCoverImage ? (coverImage ?? _faker.System.FilePath()) : null;
|
||||
|
||||
@@ -78,7 +83,7 @@ public class LibraryFixture
|
||||
Library.Create(
|
||||
resolvedUserId,
|
||||
title ?? _faker.Random.String2(_faker.Random.Number(1, 50)),
|
||||
libraryType ?? _faker.PickRandom<LibraryType>(),
|
||||
resolvedLibraryType,
|
||||
contentLocations ?? validPaths.Take(Random.Shared.Next(1, validPaths.Count)),
|
||||
Optional<string>.FromNullable(resolvedCoverImage),
|
||||
isEnabled,
|
||||
@@ -86,6 +91,7 @@ public class LibraryFixture
|
||||
canDownloadMetadataFromWeb,
|
||||
shouldSaveMetadataInMediaDirectories,
|
||||
shouldSkipUnchangedDirectoriesDuringScan,
|
||||
resolvedConsumptionSettings,
|
||||
pathTemplate ?? LibraryPathTemplate.Empty(),
|
||||
resolvedScanIds
|
||||
) :
|
||||
@@ -93,7 +99,7 @@ public class LibraryFixture
|
||||
_libraryIdFixture.Create(id.Value),
|
||||
resolvedUserId,
|
||||
title ?? _faker.Random.String2(_faker.Random.Number(1, 50)),
|
||||
libraryType ?? _faker.PickRandom<LibraryType>(),
|
||||
resolvedLibraryType,
|
||||
contentLocations ?? validPaths.Take(Random.Shared.Next(1, validPaths.Count)),
|
||||
Optional<string>.FromNullable(resolvedCoverImage),
|
||||
isEnabled,
|
||||
@@ -101,6 +107,7 @@ public class LibraryFixture
|
||||
canDownloadMetadataFromWeb,
|
||||
shouldSaveMetadataInMediaDirectories,
|
||||
shouldSkipUnchangedDirectoriesDuringScan,
|
||||
resolvedConsumptionSettings,
|
||||
pathTemplate ?? LibraryPathTemplate.Empty(),
|
||||
resolvedScanIds
|
||||
);
|
||||
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryConsumptionSettings"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryConsumptionSettingsFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a valid <see cref="LibraryConsumptionSettings"/>.
|
||||
/// </summary>
|
||||
/// <param name="shouldTrackConsumptionProgress">Optional. Whether the consumption progress is tracked. A random value is used when absent.</param>
|
||||
/// <param name="completionThresholdPercentage">Optional. The completion threshold percentage. A random value is used when absent and the threshold is included.</param>
|
||||
/// <param name="includeCompletionThreshold">Whether the completion threshold should be included. When <see langword="false"/>, no threshold is set.</param>
|
||||
/// <returns>The created consumption settings.</returns>
|
||||
public LibraryConsumptionSettings Create(
|
||||
bool? shouldTrackConsumptionProgress = null,
|
||||
int? completionThresholdPercentage = null,
|
||||
bool includeCompletionThreshold = true)
|
||||
{
|
||||
bool resolvedShouldTrackConsumptionProgress = shouldTrackConsumptionProgress ?? _faker.Random.Bool();
|
||||
Optional<int> resolvedCompletionThresholdPercentage = includeCompletionThreshold
|
||||
? Optional<int>.FromNullable(completionThresholdPercentage ?? _faker.Random.Int(0, 100))
|
||||
: Optional<int>.None();
|
||||
return LibraryConsumptionSettings.Create(resolvedShouldTrackConsumptionProgress, resolvedCompletionThresholdPercentage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the default <see cref="LibraryConsumptionSettings"/> for <paramref name="libraryType"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryType">The type of the media library for which to create the default consumption settings.</param>
|
||||
/// <returns>The default consumption settings of the media library type.</returns>
|
||||
public LibraryConsumptionSettings Create(LibraryType libraryType)
|
||||
{
|
||||
return LibraryConsumptionSettings.CreateDefault(libraryType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="LibraryConsumptionSettings"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryConsumptionSettings"/> instances.</returns>
|
||||
public List<LibraryConsumptionSettings> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -31,7 +31,9 @@ public class AddMediaLibraryRequestMappingTests
|
||||
isLocked: false,
|
||||
canDownloadMetadataFromWeb: true,
|
||||
shouldSaveMetadataInMediaDirectories: false,
|
||||
shouldSkipUnchangedDirectoriesDuringScan: false
|
||||
shouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
shouldTrackConsumptionProgress: true,
|
||||
completionThresholdPercentage: 90
|
||||
);
|
||||
|
||||
// Act
|
||||
@@ -47,6 +49,8 @@ public class AddMediaLibraryRequestMappingTests
|
||||
Assert.Equal(request.IsLocked, result.IsLocked);
|
||||
Assert.Equal(request.CanDownloadMetadataFromWeb, result.CanDownloadMetadataFromWeb);
|
||||
Assert.Equal(request.ShouldSaveMetadataInMediaDirectories, result.ShouldSaveMetadataInMediaDirectories);
|
||||
Assert.Equal(request.ShouldTrackConsumptionProgress, result.ShouldTrackConsumptionProgress);
|
||||
Assert.Equal(request.CompletionThresholdPercentage, result.CompletionThresholdPercentage);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
||||
+4
@@ -45,6 +45,8 @@ 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.ShouldTrackConsumptionProgress, result.ShouldTrackConsumptionProgress);
|
||||
Assert.Equal(entity.CompletionThresholdPercentage, result.CompletionThresholdPercentage);
|
||||
Assert.Equal(entity.CreatedOnUtc, result.CreatedOnUtc);
|
||||
Assert.Equal(entity.UpdatedOnUtc, result.UpdatedOnUtc);
|
||||
}
|
||||
@@ -198,6 +200,8 @@ 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.ShouldTrackConsumptionProgress, result.Value.ConsumptionSettings.ShouldTrackConsumptionProgress);
|
||||
Assert.Equal(entity.CompletionThresholdPercentage, result.Value.ConsumptionSettings.CompletionThresholdPercentage.HasValue ? result.Value.ConsumptionSettings.CompletionThresholdPercentage.Value : null);
|
||||
Assert.Equal(2, result.Value.PathTemplate.Parts.Count);
|
||||
Assert.Equal(LibraryPathPartKind.Literal, result.Value.PathTemplate.Parts[0].Kind);
|
||||
Assert.Equal("Various Artists", result.Value.PathTemplate.Parts[0].Representation);
|
||||
|
||||
+2
@@ -59,6 +59,8 @@ public class LibraryMappingTests
|
||||
Assert.False(result.IsLocked);
|
||||
Assert.True(result.CanDownloadMetadataFromWeb);
|
||||
Assert.False(result.ShouldSaveMetadataInMediaDirectories);
|
||||
Assert.Equal(library.ConsumptionSettings.ShouldTrackConsumptionProgress, result.ShouldTrackConsumptionProgress);
|
||||
Assert.Equal(library.ConsumptionSettings.CompletionThresholdPercentage.HasValue ? library.ConsumptionSettings.CompletionThresholdPercentage.Value : null, result.CompletionThresholdPercentage);
|
||||
Assert.Equal(library.ScanIds.Select(scanId => scanId.Value), result.LibraryScans.Select(libraryScan => libraryScan.Id));
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -31,7 +31,9 @@ public class UpdateLibraryRequestMappingTests
|
||||
isLocked: false,
|
||||
canDownloadMetadataFromWeb: true,
|
||||
shouldSaveMetadataInMediaDirectories: false,
|
||||
shouldSkipUnchangedDirectoriesDuringScan: false);
|
||||
shouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
shouldTrackConsumptionProgress: true,
|
||||
completionThresholdPercentage: 90);
|
||||
|
||||
// Act
|
||||
UpdateLibraryCommand result = request.ToCommand();
|
||||
@@ -47,6 +49,8 @@ public class UpdateLibraryRequestMappingTests
|
||||
Assert.Equal(request.CanDownloadMetadataFromWeb, result.CanDownloadMetadataFromWeb);
|
||||
Assert.Equal(request.ShouldSaveMetadataInMediaDirectories, result.ShouldSaveMetadataInMediaDirectories);
|
||||
Assert.Equal(request.ShouldSkipUnchangedDirectoriesDuringScan, result.ShouldSkipUnchangedDirectoriesDuringScan);
|
||||
Assert.Equal(request.ShouldTrackConsumptionProgress, result.ShouldTrackConsumptionProgress);
|
||||
Assert.Equal(request.CompletionThresholdPercentage, result.CompletionThresholdPercentage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
+43
@@ -113,6 +113,49 @@ public class AddLibraryCommandHandlerTests
|
||||
_mockDomainEventsQueue.Received(1).Enqueue(Arg.Any<LibrarySavedDomainEvent>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task HandleAsync_WhenThresholdIsSuppliedWhileEffectiveTrackingIsOff_ShouldReturnThresholdMustBeNullError()
|
||||
{
|
||||
// Arrange
|
||||
AddLibraryCommand command = _addLibraryCommandFixture.Create(
|
||||
libraryType: nameof(LibraryType.Music),
|
||||
shouldTrackConsumptionProgress: null,
|
||||
completionThresholdPercentage: 50);
|
||||
|
||||
// Act
|
||||
Result<LibraryResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(DomainErrors.Library.CompletionThresholdPercentageMustBeNullWhenProgressTrackingIsOff, result.FirstError);
|
||||
await _mockLibraryRepository.DidNotReceive().InsertAsync(Arg.Any<LibraryEntity>(), Arg.Any<CancellationToken>());
|
||||
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task HandleAsync_WhenProgressTrackingIsEnabledWithoutThreshold_ShouldUseLibraryTypeDefaultThreshold()
|
||||
{
|
||||
// Arrange
|
||||
AddLibraryCommand command = _addLibraryCommandFixture.Create(
|
||||
libraryType: nameof(LibraryType.Book),
|
||||
shouldTrackConsumptionProgress: true,
|
||||
completionThresholdPercentage: 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.ShouldTrackConsumptionProgress &&
|
||||
library.CompletionThresholdPercentage == 100),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task HandleAsync_WhenProviderConfigurationSeedingFails_ShouldReturnErrorWithoutSaving()
|
||||
{
|
||||
|
||||
+52
@@ -118,6 +118,58 @@ public class UpdateLibraryCommandHandlerTests
|
||||
_mockDomainEventsQueue.Received(1).Enqueue(Arg.Any<LibrarySavedDomainEvent>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task HandleAsync_WhenThresholdIsSuppliedWhileStoredTrackingIsOff_ShouldReturnThresholdMustBeNullError()
|
||||
{
|
||||
// Arrange
|
||||
UpdateLibraryCommand command = _updateLibraryCommandFixture.Create(
|
||||
shouldTrackConsumptionProgress: null,
|
||||
completionThresholdPercentage: 50);
|
||||
LibraryEntity existingLibrary = _libraryEntityFixture.Create(
|
||||
id: command.Id,
|
||||
userId: command.OwnerId,
|
||||
shouldTrackConsumptionProgress: false);
|
||||
_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.True(result.IsFailure);
|
||||
Assert.Equal(DomainErrors.Library.CompletionThresholdPercentageMustBeNullWhenProgressTrackingIsOff, result.FirstError);
|
||||
await _mockLibraryRepository.DidNotReceive().UpdateAsync(Arg.Any<LibraryEntity>(), Arg.Any<CancellationToken>());
|
||||
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task HandleAsync_WhenProgressTrackingIsEnabledWithoutThreshold_ShouldUseLibraryTypeDefaultThreshold()
|
||||
{
|
||||
// Arrange
|
||||
UpdateLibraryCommand command = _updateLibraryCommandFixture.Create(
|
||||
libraryType: nameof(LibraryType.Book),
|
||||
shouldTrackConsumptionProgress: true,
|
||||
completionThresholdPercentage: null);
|
||||
LibraryEntity existingLibrary = _libraryEntityFixture.Create(
|
||||
id: command.Id,
|
||||
userId: command.OwnerId,
|
||||
libraryType: LibraryType.Music,
|
||||
shouldTrackConsumptionProgress: false);
|
||||
_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.ShouldTrackConsumptionProgress &&
|
||||
library.CompletionThresholdPercentage == 100),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task HandleAsync_WhenLibraryTypeIsUnchanged_ShouldNotReconcileProviderConfigurations()
|
||||
{
|
||||
|
||||
+19
@@ -60,6 +60,8 @@ public class LibraryConfigurationTests
|
||||
IProperty libraryTypeProperty = entityType.GetProperty(nameof(LibraryEntity.LibraryType));
|
||||
IProperty isEnabledProperty = entityType.GetProperty(nameof(LibraryEntity.IsEnabled));
|
||||
IProperty downloadMetadataProperty = entityType.GetProperty(nameof(LibraryEntity.CanDownloadMetadataFromWeb));
|
||||
IProperty shouldTrackConsumptionProgressProperty = entityType.GetProperty(nameof(LibraryEntity.ShouldTrackConsumptionProgress));
|
||||
IProperty completionThresholdPercentageProperty = entityType.GetProperty(nameof(LibraryEntity.CompletionThresholdPercentage));
|
||||
|
||||
// Assert
|
||||
Assert.False(titleProperty.IsNullable);
|
||||
@@ -68,6 +70,8 @@ public class LibraryConfigurationTests
|
||||
Assert.Equal("TEXT", libraryTypeProperty.GetColumnType());
|
||||
Assert.Equal(true, isEnabledProperty.GetDefaultValue());
|
||||
Assert.Equal(true, downloadMetadataProperty.GetDefaultValue());
|
||||
Assert.Equal(false, shouldTrackConsumptionProgressProperty.GetDefaultValue());
|
||||
Assert.True(completionThresholdPercentageProperty.IsNullable);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -86,6 +90,21 @@ public class LibraryConfigurationTests
|
||||
Assert.Equal(11, fingerprintProperty.GetColumnOrder());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Configure_WhenApplied_ShouldConfigureConsumptionSettingsColumnOrders()
|
||||
{
|
||||
// Arrange
|
||||
IEntityType entityType = DesignTimeModel.FindEntityType(typeof(LibraryEntity))!;
|
||||
|
||||
// Act
|
||||
IProperty shouldTrackProperty = entityType.GetProperty(nameof(LibraryEntity.ShouldTrackConsumptionProgress));
|
||||
IProperty completionThresholdProperty = entityType.GetProperty(nameof(LibraryEntity.CompletionThresholdPercentage));
|
||||
|
||||
// Assert
|
||||
Assert.Equal(16, shouldTrackProperty.GetColumnOrder());
|
||||
Assert.Equal(17, completionThresholdProperty.GetColumnOrder());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Configure_WhenApplied_ShouldConfigureOwnedContentLocations()
|
||||
{
|
||||
|
||||
+10
@@ -28,6 +28,7 @@ public class LibraryTests
|
||||
private readonly UserIdFixture _userIdFixture = new();
|
||||
private readonly ScanIdFixture _scanIdFixture = new();
|
||||
private readonly LibraryIdFixture _libraryIdFixture = new();
|
||||
private readonly LibraryConsumptionSettingsFixture _libraryConsumptionSettingsFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalledWithValidData_ShouldCreateLibraryWithAllPropertiesSet()
|
||||
@@ -39,6 +40,9 @@ public class LibraryTests
|
||||
List<string> contentLocations = ["C:/Media/Books", "D:/Books"];
|
||||
string coverImageSourcePath = "C:/Cover/cover.jpg";
|
||||
List<ScanId> scanIds = [_scanIdFixture.Create(), _scanIdFixture.Create()];
|
||||
LibraryConsumptionSettings consumptionSettings = _libraryConsumptionSettingsFixture.Create(
|
||||
shouldTrackConsumptionProgress: true,
|
||||
completionThresholdPercentage: 75);
|
||||
|
||||
// Act
|
||||
Result<Library> result = Library.Create(
|
||||
@@ -52,6 +56,7 @@ public class LibraryTests
|
||||
canDownloadMetadataFromWeb: false,
|
||||
shouldSaveMetadataInMediaDirectories: true,
|
||||
shouldSkipUnchangedDirectoriesDuringScan: true,
|
||||
consumptionSettings,
|
||||
LibraryPathTemplate.Empty(),
|
||||
scanIds);
|
||||
|
||||
@@ -68,6 +73,7 @@ public class LibraryTests
|
||||
Assert.False(result.Value.CanDownloadMetadataFromWeb);
|
||||
Assert.True(result.Value.ShouldSaveMetadataInMediaDirectories);
|
||||
Assert.True(result.Value.ShouldSkipUnchangedDirectoriesDuringScan);
|
||||
Assert.Equal(consumptionSettings, result.Value.ConsumptionSettings);
|
||||
Assert.Equal(scanIds, result.Value.ScanIds);
|
||||
}
|
||||
|
||||
@@ -91,6 +97,7 @@ public class LibraryTests
|
||||
canDownloadMetadataFromWeb: true,
|
||||
shouldSaveMetadataInMediaDirectories: false,
|
||||
shouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
_libraryConsumptionSettingsFixture.Create(),
|
||||
LibraryPathTemplate.Empty(),
|
||||
scanIds);
|
||||
|
||||
@@ -118,6 +125,7 @@ public class LibraryTests
|
||||
canDownloadMetadataFromWeb: true,
|
||||
shouldSaveMetadataInMediaDirectories: false,
|
||||
shouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
_libraryConsumptionSettingsFixture.Create(),
|
||||
LibraryPathTemplate.Empty(),
|
||||
[]);
|
||||
|
||||
@@ -154,6 +162,7 @@ public class LibraryTests
|
||||
canDownloadMetadataFromWeb: true,
|
||||
shouldSaveMetadataInMediaDirectories: false,
|
||||
shouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
_libraryConsumptionSettingsFixture.Create(),
|
||||
LibraryPathTemplate.Empty(),
|
||||
[]);
|
||||
|
||||
@@ -182,6 +191,7 @@ public class LibraryTests
|
||||
canDownloadMetadataFromWeb: true,
|
||||
shouldSaveMetadataInMediaDirectories: false,
|
||||
shouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
_libraryConsumptionSettingsFixture.Create(),
|
||||
LibraryPathTemplate.Empty(),
|
||||
[]);
|
||||
|
||||
|
||||
+3
-1
@@ -105,7 +105,9 @@ public class AddLibraryEndpointTests
|
||||
command.IsLocked == request.IsLocked &&
|
||||
command.CanDownloadMetadataFromWeb == request.CanDownloadMetadataFromWeb &&
|
||||
command.ShouldSaveMetadataInMediaDirectories == request.ShouldSaveMetadataInMediaDirectories &&
|
||||
command.ShouldSkipUnchangedDirectoriesDuringScan == request.ShouldSkipUnchangedDirectoriesDuringScan),
|
||||
command.ShouldSkipUnchangedDirectoriesDuringScan == request.ShouldSkipUnchangedDirectoriesDuringScan &&
|
||||
command.ShouldTrackConsumptionProgress == request.ShouldTrackConsumptionProgress &&
|
||||
command.CompletionThresholdPercentage == request.CompletionThresholdPercentage),
|
||||
Arg.Is(cancellationToken));
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -107,7 +107,9 @@ public class UpdateLibraryEndpointTests
|
||||
command.IsLocked == request.IsLocked &&
|
||||
command.CanDownloadMetadataFromWeb == request.CanDownloadMetadataFromWeb &&
|
||||
command.ShouldSaveMetadataInMediaDirectories == request.ShouldSaveMetadataInMediaDirectories &&
|
||||
command.ShouldSkipUnchangedDirectoriesDuringScan == request.ShouldSkipUnchangedDirectoriesDuringScan),
|
||||
command.ShouldSkipUnchangedDirectoriesDuringScan == request.ShouldSkipUnchangedDirectoriesDuringScan &&
|
||||
command.ShouldTrackConsumptionProgress == request.ShouldTrackConsumptionProgress &&
|
||||
command.CompletionThresholdPercentage == request.CompletionThresholdPercentage),
|
||||
Arg.Is(cancellationToken));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user