mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 06:11:10 +00:00
Standardizes test conventions and documentation
This commit is contained in:
1 parent
7aeed04255
commit
f42dc709de
190 files changed
+2180
-2814
No files matched your search
+8
-8
@@ -7,7 +7,7 @@ using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Commands.CancelLibrariesScan;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Events;
|
||||
using Lumina.Application.Fixtures.Core.MediaLibrary.Management.Commands.CancelLibrariesScan;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
@@ -15,7 +15,6 @@ using NSubstitute;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
|
||||
@@ -35,6 +34,7 @@ public class CancelLibrariesScanCommandHandlerTests
|
||||
private readonly ICurrentUserService _mockCurrentUserService;
|
||||
private readonly IDomainEventsQueue _mockDomainEventsQueue;
|
||||
private readonly CancelLibrariesScanCommandHandler _sut;
|
||||
private readonly CancelLibrariesScanCommandFixture _cancelLibrariesScanCommandFixture = new();
|
||||
private readonly LibraryScanEntityFixture _libraryScanEntityFixture = new();
|
||||
private readonly Guid _userId;
|
||||
|
||||
@@ -72,7 +72,7 @@ public class CancelLibrariesScanCommandHandlerTests
|
||||
_mockLibraryScanRepository.GetRunningScansAsync(Arg.Any<CancellationToken>()).Returns(Result.From<IEnumerable<LibraryScanEntity>>(runningScans));
|
||||
|
||||
// Act
|
||||
Result<Success> result = await _sut.HandleAsync(new CancelLibrariesScanCommand(), CancellationToken.None);
|
||||
Result<Success> result = await _sut.HandleAsync(_cancelLibrariesScanCommandFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
@@ -96,7 +96,7 @@ public class CancelLibrariesScanCommandHandlerTests
|
||||
_mockAuthorizationService.IsInRoleAsync(_userId, "Admin", Arg.Any<CancellationToken>()).Returns(false);
|
||||
|
||||
// Act
|
||||
Result<Success> result = await _sut.HandleAsync(new CancelLibrariesScanCommand(), CancellationToken.None);
|
||||
Result<Success> result = await _sut.HandleAsync(_cancelLibrariesScanCommandFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
@@ -111,7 +111,7 @@ public class CancelLibrariesScanCommandHandlerTests
|
||||
_mockCurrentUserService.UserId.Returns((Guid?)null);
|
||||
|
||||
// Act
|
||||
Result<Success> result = await _sut.HandleAsync(new CancelLibrariesScanCommand(), CancellationToken.None);
|
||||
Result<Success> result = await _sut.HandleAsync(_cancelLibrariesScanCommandFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
@@ -128,7 +128,7 @@ public class CancelLibrariesScanCommandHandlerTests
|
||||
.Returns(Error.Failure(description: "Failed to get running scans"));
|
||||
|
||||
// Act
|
||||
Result<Success> result = await _sut.HandleAsync(new CancelLibrariesScanCommand(), CancellationToken.None);
|
||||
Result<Success> result = await _sut.HandleAsync(_cancelLibrariesScanCommandFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
@@ -146,7 +146,7 @@ public class CancelLibrariesScanCommandHandlerTests
|
||||
.Returns(Error.Failure(description: "Failed to update library scan"));
|
||||
|
||||
// Act
|
||||
Result<Success> result = await _sut.HandleAsync(new CancelLibrariesScanCommand(), CancellationToken.None);
|
||||
Result<Success> result = await _sut.HandleAsync(_cancelLibrariesScanCommandFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
@@ -161,7 +161,7 @@ public class CancelLibrariesScanCommandHandlerTests
|
||||
_mockLibraryScanRepository.GetRunningScansAsync(Arg.Any<CancellationToken>()).Returns(Result.From<IEnumerable<LibraryScanEntity>>(runningScans));
|
||||
|
||||
// Act
|
||||
Result<Success> result = await _sut.HandleAsync(new CancelLibrariesScanCommand(), CancellationToken.None);
|
||||
Result<Success> result = await _sut.HandleAsync(_cancelLibrariesScanCommandFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
|
||||
+10
-9
@@ -7,8 +7,8 @@ using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Commands.ScanLibraries;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Fixtures.Core.MediaLibrary.Management.Commands.ScanLibraries;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Events;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
using NSubstitute;
|
||||
@@ -37,6 +37,7 @@ public class ScanLibrariesCommandHandlerTests
|
||||
private readonly ICurrentUserService _mockCurrentUserService;
|
||||
private readonly IDomainEventsQueue _mockDomainEventsQueue;
|
||||
private readonly ScanLibrariesCommandHandler _sut;
|
||||
private readonly ScanLibrariesCommandFixture _scanLibrariesCommandFixture = new();
|
||||
private readonly LibraryEntityFixture _libraryEntityFixture = new();
|
||||
private readonly LibraryScanEntityFixture _libraryScanEntityFixture = new();
|
||||
private readonly Guid _userId;
|
||||
@@ -79,7 +80,7 @@ public class ScanLibrariesCommandHandlerTests
|
||||
_mockLibraryRepository.GetAllEnabledAndUnlockedAsync(Arg.Any<CancellationToken>()).Returns(Result.From<IEnumerable<LibraryEntity>>(libraries));
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<MediaLibraryScanResponse>> result = await _sut.HandleAsync(new ScanLibrariesCommand(), CancellationToken.None);
|
||||
Result<IEnumerable<MediaLibraryScanResponse>> result = await _sut.HandleAsync(_scanLibrariesCommandFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
@@ -105,7 +106,7 @@ public class ScanLibrariesCommandHandlerTests
|
||||
_mockAuthorizationService.IsInRoleAsync(_userId, "Admin", Arg.Any<CancellationToken>()).Returns(false);
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<MediaLibraryScanResponse>> result = await _sut.HandleAsync(new ScanLibrariesCommand(), CancellationToken.None);
|
||||
Result<IEnumerable<MediaLibraryScanResponse>> result = await _sut.HandleAsync(_scanLibrariesCommandFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
@@ -122,7 +123,7 @@ public class ScanLibrariesCommandHandlerTests
|
||||
_mockCurrentUserService.UserId.Returns((Guid?)null);
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<MediaLibraryScanResponse>> result = await _sut.HandleAsync(new ScanLibrariesCommand(), CancellationToken.None);
|
||||
Result<IEnumerable<MediaLibraryScanResponse>> result = await _sut.HandleAsync(_scanLibrariesCommandFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
@@ -139,7 +140,7 @@ public class ScanLibrariesCommandHandlerTests
|
||||
.Returns(Error.Failure(description: "Failed to get libraries"));
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<MediaLibraryScanResponse>> result = await _sut.HandleAsync(new ScanLibrariesCommand(), CancellationToken.None);
|
||||
Result<IEnumerable<MediaLibraryScanResponse>> result = await _sut.HandleAsync(_scanLibrariesCommandFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
@@ -161,7 +162,7 @@ public class ScanLibrariesCommandHandlerTests
|
||||
.Returns(Result.From<IEnumerable<LibraryScanEntity>>([runningScan]));
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<MediaLibraryScanResponse>> result = await _sut.HandleAsync(new ScanLibrariesCommand(), CancellationToken.None);
|
||||
Result<IEnumerable<MediaLibraryScanResponse>> result = await _sut.HandleAsync(_scanLibrariesCommandFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
@@ -181,7 +182,7 @@ public class ScanLibrariesCommandHandlerTests
|
||||
.Returns(Error.Failure(description: "Failed to insert library scan"));
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<MediaLibraryScanResponse>> result = await _sut.HandleAsync(new ScanLibrariesCommand(), CancellationToken.None);
|
||||
Result<IEnumerable<MediaLibraryScanResponse>> result = await _sut.HandleAsync(_scanLibrariesCommandFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
@@ -198,7 +199,7 @@ public class ScanLibrariesCommandHandlerTests
|
||||
.Returns(Error.Failure(description: "Failed to get past month scans"));
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<MediaLibraryScanResponse>> result = await _sut.HandleAsync(new ScanLibrariesCommand(), CancellationToken.None);
|
||||
Result<IEnumerable<MediaLibraryScanResponse>> result = await _sut.HandleAsync(_scanLibrariesCommandFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
@@ -214,7 +215,7 @@ public class ScanLibrariesCommandHandlerTests
|
||||
_mockLibraryRepository.GetAllEnabledAndUnlockedAsync(Arg.Any<CancellationToken>()).Returns(Result.From<IEnumerable<LibraryEntity>>(libraries));
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<MediaLibraryScanResponse>> result = await _sut.HandleAsync(new ScanLibrariesCommand(), CancellationToken.None);
|
||||
Result<IEnumerable<MediaLibraryScanResponse>> result = await _sut.HandleAsync(_scanLibrariesCommandFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
|
||||
+6
-5
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Infrastructure.Models.DTO.Configuration;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Events;
|
||||
using Lumina.Application.Fixtures.Common.Infrastructure.Models.DTO.Configuration;
|
||||
using Lumina.Domain.Common.Exceptions;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
@@ -30,6 +31,7 @@ public class LibraryDeletedDomainEventHandlerTests
|
||||
private readonly IPathService _mockPathService;
|
||||
private readonly LibraryDeletedDomainEventHandler _sut;
|
||||
private readonly LibraryFixture _libraryFixture = new();
|
||||
private readonly MediaSettingsDtoFixture _mediaSettingsDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibraryDeletedDomainEventHandlerTests"/> class.
|
||||
@@ -41,11 +43,10 @@ public class LibraryDeletedDomainEventHandlerTests
|
||||
_mockEnvironmentContext.DirectoryProviderService.Returns(_mockDirectoryProviderService);
|
||||
_mockPathService = Substitute.For<IPathService>();
|
||||
|
||||
MediaSettingsDto mediaSettings = new()
|
||||
{
|
||||
RootDirectory = "Media",
|
||||
LibrariesDirectory = "Libraries"
|
||||
};
|
||||
MediaSettingsDto mediaSettings = _mediaSettingsDtoFixture.Create(
|
||||
rootDirectory: "Media",
|
||||
librariesDirectory: "Libraries",
|
||||
booksDirectory: "Books");
|
||||
IOptions<MediaSettingsDto> mediaSettingsOptions = Substitute.For<IOptions<MediaSettingsDto>>();
|
||||
mediaSettingsOptions.Value.Returns(mediaSettings);
|
||||
|
||||
|
||||
+6
-5
@@ -5,6 +5,7 @@ using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.Infrastructure.Models.DTO.Configuration;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Events;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Fixtures.Common.Infrastructure.Models.DTO.Configuration;
|
||||
using Lumina.Domain.Common.Exceptions;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
@@ -44,6 +45,7 @@ public class LibrarySavedDomainEventHandlerTests
|
||||
private readonly LibraryFixture _libraryFixture = new();
|
||||
private readonly LibraryEntityFixture _libraryEntityFixture = new();
|
||||
private readonly FileSystemPathIdFixture _fileSystemPathIdFixture = new();
|
||||
private readonly MediaSettingsDtoFixture _mediaSettingsDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibrarySavedDomainEventHandlerTests"/> class.
|
||||
@@ -62,11 +64,10 @@ public class LibrarySavedDomainEventHandlerTests
|
||||
_mockEnvironmentContext.FileTypeService.Returns(_mockFileTypeService);
|
||||
_mockPathService = Substitute.For<IPathService>();
|
||||
|
||||
MediaSettingsDto mediaSettings = new()
|
||||
{
|
||||
RootDirectory = "Media",
|
||||
LibrariesDirectory = "Libraries"
|
||||
};
|
||||
MediaSettingsDto mediaSettings = _mediaSettingsDtoFixture.Create(
|
||||
rootDirectory: "Media",
|
||||
librariesDirectory: "Libraries",
|
||||
booksDirectory: "Books");
|
||||
IOptions<MediaSettingsDto> mediaSettingsOptions = Substitute.For<IOptions<MediaSettingsDto>>();
|
||||
mediaSettingsOptions.Value.Returns(mediaSettings);
|
||||
|
||||
|
||||
+6
-8
@@ -5,8 +5,8 @@ using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.DomainEvents;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Events;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Exceptions;
|
||||
using Lumina.Domain.Common.Events;
|
||||
using Lumina.Domain.Common.Exceptions;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
@@ -14,13 +14,12 @@ using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Library
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using DomainErrors = Lumina.Domain.Common.Errors.Errors;
|
||||
using NSubstitute;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using DomainErrors = Lumina.Domain.Common.Errors.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Core.MediaLibrary.Management.Events;
|
||||
@@ -52,7 +51,7 @@ public class LibraryScanQueuedDomainEventHandlerTests
|
||||
_mockDomainEventsQueue = Substitute.For<IDomainEventsQueue>();
|
||||
|
||||
// default stubs: the scanning service starts the scan successfully
|
||||
_mockMediaLibraryScanningService.StartScanAsync(Arg.Any<LibraryScan>(), Arg.Any<LibraryType>(), Arg.Any<bool>(), Arg.Any<CancellationToken>())
|
||||
_mockMediaLibraryScanningService.StartScanAsync(Arg.Any<LibraryScan>(), Arg.Any<LibraryType>(), Arg.Any<CancellationToken>())
|
||||
.Returns(Result.Success);
|
||||
|
||||
_sut = new LibraryScanQueuedDomainEventHandler(_mockMediaLibraryScanningService, _mockDomainEventsQueue, _mockUnitOfWork);
|
||||
@@ -74,7 +73,6 @@ public class LibraryScanQueuedDomainEventHandlerTests
|
||||
await _mockMediaLibraryScanningService.Received(1).StartScanAsync(
|
||||
Arg.Is<LibraryScan>(libraryScan => libraryScan.Id.Value == scan.Id),
|
||||
scan.Library.LibraryType,
|
||||
scan.Library.DownloadMetadataFromWeb,
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -93,7 +91,7 @@ public class LibraryScanQueuedDomainEventHandlerTests
|
||||
|
||||
// Assert
|
||||
Assert.Equal(error, exception.EventualConsistencyError);
|
||||
await _mockMediaLibraryScanningService.DidNotReceive().StartScanAsync(Arg.Any<LibraryScan>(), Arg.Any<LibraryType>(), Arg.Any<bool>(), Arg.Any<CancellationToken>());
|
||||
await _mockMediaLibraryScanningService.DidNotReceive().StartScanAsync(Arg.Any<LibraryScan>(), Arg.Any<LibraryType>(), Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -110,7 +108,7 @@ public class LibraryScanQueuedDomainEventHandlerTests
|
||||
|
||||
// Assert
|
||||
Assert.Equal(DomainErrors.LibraryScanning.LibraryScanNotFound, exception.EventualConsistencyError);
|
||||
await _mockMediaLibraryScanningService.DidNotReceive().StartScanAsync(Arg.Any<LibraryScan>(), Arg.Any<LibraryType>(), Arg.Any<bool>(), Arg.Any<CancellationToken>());
|
||||
await _mockMediaLibraryScanningService.DidNotReceive().StartScanAsync(Arg.Any<LibraryScan>(), Arg.Any<LibraryType>(), Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -122,7 +120,7 @@ public class LibraryScanQueuedDomainEventHandlerTests
|
||||
_mockLibraryScanRepository.GetByIdAsync(scan.Id, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<LibraryScanEntity?>(scan));
|
||||
Error error = Error.Failure(description: "Failed to start scan");
|
||||
_mockMediaLibraryScanningService.StartScanAsync(Arg.Any<LibraryScan>(), Arg.Any<LibraryType>(), Arg.Any<bool>(), Arg.Any<CancellationToken>())
|
||||
_mockMediaLibraryScanningService.StartScanAsync(Arg.Any<LibraryScan>(), Arg.Any<LibraryType>(), Arg.Any<CancellationToken>())
|
||||
.Returns(error);
|
||||
|
||||
// Act
|
||||
|
||||
+6
-5
@@ -7,13 +7,13 @@ using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Queries.GetEnabledLibraries;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Fixtures.Core.MediaLibrary.Management.Queries.GetEnabledLibraries;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using NSubstitute;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
@@ -31,6 +31,7 @@ public class GetEnabledLibrariesQueryHandlerTests
|
||||
private readonly IAuthorizationService _mockAuthorizationService;
|
||||
private readonly ICurrentUserService _mockCurrentUserService;
|
||||
private readonly GetEnabledLibrariesQueryHandler _sut;
|
||||
private readonly GetEnabledLibrariesQueryFixture _getEnabledLibrariesQueryFixture = new();
|
||||
private readonly LibraryEntityFixture _libraryEntityFixture = new();
|
||||
private readonly Guid _userId;
|
||||
|
||||
@@ -65,7 +66,7 @@ public class GetEnabledLibrariesQueryHandlerTests
|
||||
_mockLibraryRepository.GetAllEnabledAsync(Arg.Any<CancellationToken>()).Returns(Result.From<IEnumerable<LibraryEntity>>(libraries));
|
||||
|
||||
// Act
|
||||
Result<LibraryResponse[]> result = await _sut.HandleAsync(new GetEnabledLibrariesQuery(), CancellationToken.None);
|
||||
Result<LibraryResponse[]> result = await _sut.HandleAsync(_getEnabledLibrariesQueryFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
@@ -88,7 +89,7 @@ public class GetEnabledLibrariesQueryHandlerTests
|
||||
_mockAuthorizationService.IsInRoleAsync(_userId, "Admin", Arg.Any<CancellationToken>()).Returns(false);
|
||||
|
||||
// Act
|
||||
Result<LibraryResponse[]> result = await _sut.HandleAsync(new GetEnabledLibrariesQuery(), CancellationToken.None);
|
||||
Result<LibraryResponse[]> result = await _sut.HandleAsync(_getEnabledLibrariesQueryFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
@@ -103,7 +104,7 @@ public class GetEnabledLibrariesQueryHandlerTests
|
||||
_mockCurrentUserService.UserId.Returns((Guid?)null);
|
||||
|
||||
// Act
|
||||
Result<LibraryResponse[]> result = await _sut.HandleAsync(new GetEnabledLibrariesQuery(), CancellationToken.None);
|
||||
Result<LibraryResponse[]> result = await _sut.HandleAsync(_getEnabledLibrariesQueryFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
@@ -119,7 +120,7 @@ public class GetEnabledLibrariesQueryHandlerTests
|
||||
.Returns(Error.Failure(description: "Failed to get enabled libraries"));
|
||||
|
||||
// Act
|
||||
Result<LibraryResponse[]> result = await _sut.HandleAsync(new GetEnabledLibrariesQuery(), CancellationToken.None);
|
||||
Result<LibraryResponse[]> result = await _sut.HandleAsync(_getEnabledLibrariesQueryFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
|
||||
+6
-5
@@ -7,13 +7,13 @@ using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibraries;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Fixtures.Core.MediaLibrary.Management.Queries.GetLibraries;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using NSubstitute;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
@@ -31,6 +31,7 @@ public class GetLibrariesQueryHandlerTests
|
||||
private readonly IAuthorizationService _mockAuthorizationService;
|
||||
private readonly ICurrentUserService _mockCurrentUserService;
|
||||
private readonly GetLibrariesQueryHandler _sut;
|
||||
private readonly GetLibrariesQueryFixture _getLibrariesQueryFixture = new();
|
||||
private readonly LibraryEntityFixture _libraryEntityFixture = new();
|
||||
private readonly Guid _userId;
|
||||
|
||||
@@ -65,7 +66,7 @@ public class GetLibrariesQueryHandlerTests
|
||||
_mockLibraryRepository.GetAllAsync(Arg.Any<CancellationToken>()).Returns(Result.From<IEnumerable<LibraryEntity>>(libraries));
|
||||
|
||||
// Act
|
||||
Result<LibraryResponse[]> result = await _sut.HandleAsync(new GetLibrariesQuery(), CancellationToken.None);
|
||||
Result<LibraryResponse[]> result = await _sut.HandleAsync(_getLibrariesQueryFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
@@ -88,7 +89,7 @@ public class GetLibrariesQueryHandlerTests
|
||||
_mockAuthorizationService.IsInRoleAsync(_userId, "Admin", Arg.Any<CancellationToken>()).Returns(false);
|
||||
|
||||
// Act
|
||||
Result<LibraryResponse[]> result = await _sut.HandleAsync(new GetLibrariesQuery(), CancellationToken.None);
|
||||
Result<LibraryResponse[]> result = await _sut.HandleAsync(_getLibrariesQueryFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
@@ -103,7 +104,7 @@ public class GetLibrariesQueryHandlerTests
|
||||
_mockCurrentUserService.UserId.Returns((Guid?)null);
|
||||
|
||||
// Act
|
||||
Result<LibraryResponse[]> result = await _sut.HandleAsync(new GetLibrariesQuery(), CancellationToken.None);
|
||||
Result<LibraryResponse[]> result = await _sut.HandleAsync(_getLibrariesQueryFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
@@ -119,7 +120,7 @@ public class GetLibrariesQueryHandlerTests
|
||||
.Returns(Error.Failure(description: "Failed to get libraries"));
|
||||
|
||||
// Act
|
||||
Result<LibraryResponse[]> result = await _sut.HandleAsync(new GetLibrariesQuery(), CancellationToken.None);
|
||||
Result<LibraryResponse[]> result = await _sut.HandleAsync(_getLibrariesQueryFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
|
||||
+3
-12
@@ -7,6 +7,7 @@ using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization.Policies.LibraryOwnership;
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibrary;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Fixtures.Core.MediaLibrary.Management.Queries.GetLibrary;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
@@ -14,7 +15,6 @@ using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using NSubstitute;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -38,6 +38,7 @@ public class GetLibraryQueryHandlerTests
|
||||
private readonly GetLibraryQueryHandler _sut;
|
||||
private readonly Guid _userId;
|
||||
private readonly GetLibraryQueryFixture _getLibraryQueryFixture = new();
|
||||
private readonly LibraryEntityFixture _libraryEntityFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetLibraryQueryHandlerTests"/> class.
|
||||
@@ -57,17 +58,7 @@ public class GetLibraryQueryHandlerTests
|
||||
_mockAuthorizationService.EvaluatePolicyAsync<ILibraryOwnershipPolicy>(_userId, Arg.Any<LibraryOwnershipPolicyContext>(), Arg.Any<CancellationToken>())
|
||||
.Returns(true);
|
||||
_mockLibraryRepository.GetByIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From((LibraryEntity?)new LibraryEntity
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
UserId = _userId,
|
||||
Title = "Test Library",
|
||||
LibraryType = LibraryType.EBook,
|
||||
ContentLocations = [],
|
||||
CreatedBy = _userId,
|
||||
CreatedOnUtc = DateTime.UtcNow,
|
||||
UpdatedBy = null
|
||||
}));
|
||||
.Returns(Result.From((LibraryEntity?)_libraryEntityFixture.Create(userId: _userId, title: "Test Library", libraryType: LibraryType.EBook, contentLocations: [])));
|
||||
_mockValidator.Validate(Arg.Any<GetLibraryQuery>()).Returns([]);
|
||||
|
||||
_sut = new GetLibraryQueryHandler(_mockAuthorizationService, _mockCurrentUserService, _mockUnitOfWork, _mockValidator);
|
||||
|
||||
+7
-5
@@ -7,6 +7,7 @@ using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Queries.GetRunningLibraryScans;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Fixtures.Core.MediaLibrary.Management.Queries.GetRunningLibraryScans;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Progress;
|
||||
@@ -37,6 +38,7 @@ public class GetRunningLibraryScansQueryHandlerTests
|
||||
private readonly ICurrentUserService _mockCurrentUserService;
|
||||
private readonly IMediaLibrariesScanProgressTracker _mockMediaLibrariesScanProgressTracker;
|
||||
private readonly GetRunningLibraryScansQueryHandler _sut;
|
||||
private readonly GetRunningLibraryScansQueryFixture _getRunningLibraryScansQueryFixture = new();
|
||||
private readonly LibraryScanEntityFixture _libraryScanEntityFixture = new();
|
||||
private readonly MediaLibraryScanProgressFixture _mediaLibraryScanProgressFixture = new();
|
||||
private readonly UserIdFixture _userIdFixture = new();
|
||||
@@ -80,7 +82,7 @@ public class GetRunningLibraryScansQueryHandlerTests
|
||||
_mockLibraryScanRepository.GetRunningScansAsync(Arg.Any<CancellationToken>()).Returns(Result.From<IEnumerable<LibraryScanEntity>>(runningScans));
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<MediaLibraryScanProgressResponse>> result = await _sut.HandleAsync(new GetRunningLibraryScansQuery(), CancellationToken.None);
|
||||
Result<IEnumerable<MediaLibraryScanProgressResponse>> result = await _sut.HandleAsync(_getRunningLibraryScansQueryFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
@@ -100,7 +102,7 @@ public class GetRunningLibraryScansQueryHandlerTests
|
||||
_mockAuthorizationService.IsInRoleAsync(_userId, "Admin", Arg.Any<CancellationToken>()).Returns(false);
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<MediaLibraryScanProgressResponse>> result = await _sut.HandleAsync(new GetRunningLibraryScansQuery(), CancellationToken.None);
|
||||
Result<IEnumerable<MediaLibraryScanProgressResponse>> result = await _sut.HandleAsync(_getRunningLibraryScansQueryFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
@@ -114,7 +116,7 @@ public class GetRunningLibraryScansQueryHandlerTests
|
||||
_mockCurrentUserService.UserId.Returns((Guid?)null);
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<MediaLibraryScanProgressResponse>> result = await _sut.HandleAsync(new GetRunningLibraryScansQuery(), CancellationToken.None);
|
||||
Result<IEnumerable<MediaLibraryScanProgressResponse>> result = await _sut.HandleAsync(_getRunningLibraryScansQueryFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
@@ -130,7 +132,7 @@ public class GetRunningLibraryScansQueryHandlerTests
|
||||
.Returns(Error.Failure(description: "Failed to get running scans"));
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<MediaLibraryScanProgressResponse>> result = await _sut.HandleAsync(new GetRunningLibraryScansQuery(), CancellationToken.None);
|
||||
Result<IEnumerable<MediaLibraryScanProgressResponse>> result = await _sut.HandleAsync(_getRunningLibraryScansQueryFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
@@ -146,7 +148,7 @@ public class GetRunningLibraryScansQueryHandlerTests
|
||||
.Returns(Error.Failure(description: "Failed to get scan progress"));
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<MediaLibraryScanProgressResponse>> result = await _sut.HandleAsync(new GetRunningLibraryScansQuery(), CancellationToken.None);
|
||||
Result<IEnumerable<MediaLibraryScanProgressResponse>> result = await _sut.HandleAsync(_getRunningLibraryScansQueryFixture.Create(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
|
||||
+17
-16
@@ -8,8 +8,8 @@ using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||
using Lumina.Application.Fixtures.Common.Setup;
|
||||
using Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.Common;
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
@@ -34,6 +34,12 @@ public class AddBookCommandHandlerTests
|
||||
private readonly IBookRepository _mockBookRepository;
|
||||
private readonly AddBookCommandHandler _sut;
|
||||
private readonly AddBookCommandFixture _commandBookFixture = new();
|
||||
private readonly IsbnDtoFixture _isbnDtoFixture = new();
|
||||
private readonly BookRatingDtoFixture _bookRatingDtoFixture = new();
|
||||
private readonly GenreDtoFixture _genreDtoFixture = new();
|
||||
private readonly TagDtoFixture _tagDtoFixture = new();
|
||||
private readonly ReleaseInfoDtoFixture _releaseInfoDtoFixture = new();
|
||||
private readonly LanguageInfoDtoFixture _languageInfoDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AddBookCommandHandlerTests"/> class.
|
||||
@@ -98,7 +104,7 @@ public class AddBookCommandHandlerTests
|
||||
{
|
||||
// Arrange
|
||||
AddBookCommand bookCommand = _commandBookFixture.Create();
|
||||
bookCommand = bookCommand with { ISBNs = [new IsbnDto("invalid", IsbnFormat.Isbn13)] };
|
||||
bookCommand = bookCommand with { ISBNs = [_isbnDtoFixture.Create(value: "invalid", format: IsbnFormat.Isbn13)] };
|
||||
|
||||
// Act
|
||||
Result<BookResponse> result = await _sut.HandleAsync(bookCommand, CancellationToken.None);
|
||||
@@ -115,7 +121,7 @@ public class AddBookCommandHandlerTests
|
||||
{
|
||||
// Arrange
|
||||
AddBookCommand bookCommand = _commandBookFixture.Create();
|
||||
bookCommand = bookCommand with { Ratings = [new BookRatingDto(-1, 5, null, null)] };
|
||||
bookCommand = bookCommand with { Ratings = [_bookRatingDtoFixture.Create(value: -1, maxValue: 5, includeOptionalProperties: false)] };
|
||||
|
||||
// Act
|
||||
Result<BookResponse> result = await _sut.HandleAsync(bookCommand, CancellationToken.None);
|
||||
@@ -136,7 +142,7 @@ public class AddBookCommandHandlerTests
|
||||
{
|
||||
Metadata = bookCommand.Metadata! with
|
||||
{
|
||||
Genres = [new GenreDto("")]
|
||||
Genres = [_genreDtoFixture.Create(name: "")]
|
||||
}
|
||||
};
|
||||
|
||||
@@ -159,7 +165,7 @@ public class AddBookCommandHandlerTests
|
||||
{
|
||||
Metadata = bookCommand.Metadata! with
|
||||
{
|
||||
Tags = [new TagDto("")]
|
||||
Tags = [_tagDtoFixture.Create(name: "")]
|
||||
}
|
||||
};
|
||||
|
||||
@@ -182,14 +188,9 @@ public class AddBookCommandHandlerTests
|
||||
{
|
||||
Metadata = bookCommand.Metadata! with
|
||||
{
|
||||
ReleaseInfo = new ReleaseInfoDto(
|
||||
OriginalReleaseDate: new DateOnly(2025, 1, 1),
|
||||
ReReleaseDate: new DateOnly(2024, 1, 1),
|
||||
OriginalReleaseYear: null,
|
||||
ReReleaseYear: null,
|
||||
ReleaseCountry: null,
|
||||
ReleaseVersion: null
|
||||
)
|
||||
ReleaseInfo = _releaseInfoDtoFixture.Create(
|
||||
originalReleaseDate: new DateOnly(2025, 1, 1),
|
||||
reReleaseDate: new DateOnly(2024, 1, 1))
|
||||
}
|
||||
};
|
||||
|
||||
@@ -212,7 +213,7 @@ public class AddBookCommandHandlerTests
|
||||
{
|
||||
Metadata = bookCommand.Metadata! with
|
||||
{
|
||||
Language = new LanguageInfoDto("", "English", null)
|
||||
Language = _languageInfoDtoFixture.Create(languageCode: "", languageName: "English")
|
||||
}
|
||||
};
|
||||
|
||||
@@ -235,7 +236,7 @@ public class AddBookCommandHandlerTests
|
||||
{
|
||||
Metadata = bookCommand.Metadata! with
|
||||
{
|
||||
OriginalLanguage = new LanguageInfoDto("", "English", null)
|
||||
OriginalLanguage = _languageInfoDtoFixture.Create(languageCode: "", languageName: "English")
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+14
@@ -1881,4 +1881,18 @@ public class AddBookCommandValidatorTests
|
||||
// Assert
|
||||
result.ShouldNotHaveValidationError(Errors.Metadata.RatingVoteCountMustBePositive);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Validate_WhenLibraryIdIsEmpty_ShouldHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
AddBookCommand bookCommand = _commandBookFixture.Create();
|
||||
bookCommand = bookCommand with { LibraryId = Guid.Empty };
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(bookCommand);
|
||||
|
||||
// Assert
|
||||
result.ShouldHaveValidationError(Errors.WrittenContent.BookLibraryCannotBeNull);
|
||||
}
|
||||
}
|
||||
+9
-41
@@ -2,12 +2,15 @@
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Books;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization.Policies.LibraryOwnership;
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooks;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooks;
|
||||
using Lumina.Contracts.Responses.Common;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
@@ -18,12 +21,9 @@ using NSubstitute;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooks;
|
||||
@@ -43,6 +43,7 @@ public class GetBooksQueryHandlerTests
|
||||
private readonly Guid _userId;
|
||||
private readonly BookEntityFixture _bookEntityFixture = new();
|
||||
private readonly GetBooksQueryFixture _getBooksQueryFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<BookEntity> _paginatedResultDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetBooksQueryHandlerTests"/> class.
|
||||
@@ -73,14 +74,7 @@ public class GetBooksQueryHandlerTests
|
||||
GetBooksQuery query = _getBooksQueryFixture.Create();
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
List<BookEntity> bookEntities = _bookEntityFixture.CreateMany(2);
|
||||
PaginatedResultDto<BookEntity> paginatedBooks = new()
|
||||
{
|
||||
Data = bookEntities,
|
||||
CurrentPage = 1,
|
||||
PerPage = 10,
|
||||
Count = 2,
|
||||
NumberOfPages = 1
|
||||
};
|
||||
PaginatedResultDto<BookEntity> paginatedBooks = _paginatedResultDtoFixture.Create(data: bookEntities, currentPage: 1, perPage: 10, count: 2, numberOfPages: 1);
|
||||
_mockBookRepository.GetPaginatedAsync(
|
||||
Arg.Any<PaginationDataDto?>(),
|
||||
Arg.Any<string?>(),
|
||||
@@ -106,14 +100,7 @@ public class GetBooksQueryHandlerTests
|
||||
{
|
||||
// Arrange
|
||||
GetBooksQuery query = _getBooksQueryFixture.Create();
|
||||
PaginatedResultDto<BookEntity> paginatedBooks = new()
|
||||
{
|
||||
Data = [],
|
||||
CurrentPage = 1,
|
||||
PerPage = 10,
|
||||
Count = 0,
|
||||
NumberOfPages = 0
|
||||
};
|
||||
PaginatedResultDto<BookEntity> paginatedBooks = _paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 10, count: 0, numberOfPages: 0);
|
||||
_mockBookRepository.GetPaginatedAsync(
|
||||
Arg.Any<PaginationDataDto?>(),
|
||||
Arg.Any<string?>(),
|
||||
@@ -157,14 +144,7 @@ public class GetBooksQueryHandlerTests
|
||||
// Arrange
|
||||
GetBooksQuery query = _getBooksQueryFixture.Create();
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
PaginatedResultDto<BookEntity> paginatedBooks = new()
|
||||
{
|
||||
Data = [],
|
||||
CurrentPage = 1,
|
||||
PerPage = 10,
|
||||
Count = 0,
|
||||
NumberOfPages = 0
|
||||
};
|
||||
PaginatedResultDto<BookEntity> paginatedBooks = _paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 10, count: 0, numberOfPages: 0);
|
||||
_mockBookRepository.GetPaginatedAsync(
|
||||
Arg.Any<PaginationDataDto?>(),
|
||||
Arg.Any<string?>(),
|
||||
@@ -190,20 +170,8 @@ public class GetBooksQueryHandlerTests
|
||||
public async Task HandleAsync_WhenQueryHasNoPaginationData_ShouldQueryRepositoryWithoutPagination()
|
||||
{
|
||||
// Arrange
|
||||
GetBooksQuery query = new(
|
||||
PaginationData: null,
|
||||
Filter: new LibraryFilterDto { LibraryId = Guid.NewGuid() },
|
||||
SortBy: null,
|
||||
SortOrder: SortOrder.Ascending
|
||||
);
|
||||
PaginatedResultDto<BookEntity> paginatedBooks = new()
|
||||
{
|
||||
Data = [],
|
||||
CurrentPage = 1,
|
||||
PerPage = 10,
|
||||
Count = 0,
|
||||
NumberOfPages = 0
|
||||
};
|
||||
GetBooksQuery query = _getBooksQueryFixture.Create(includePaginationData: false, libraryId: Guid.NewGuid(), sortOrder: SortOrder.Ascending);
|
||||
PaginatedResultDto<BookEntity> paginatedBooks = _paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 10, count: 0, numberOfPages: 0);
|
||||
_mockBookRepository.GetPaginatedAsync(
|
||||
Arg.Any<PaginationDataDto?>(),
|
||||
Arg.Any<string?>(),
|
||||
|
||||
+9
-41
@@ -2,12 +2,15 @@
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Books;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization.Policies.LibraryOwnership;
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooksLite;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooksLite;
|
||||
using Lumina.Contracts.Responses.Common;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
@@ -18,12 +21,9 @@ using NSubstitute;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooksLite;
|
||||
@@ -43,6 +43,7 @@ public class GetBooksLiteQueryHandlerTests
|
||||
private readonly Guid _userId;
|
||||
private readonly BookEntityFixture _bookEntityFixture = new();
|
||||
private readonly GetBooksLiteQueryFixture _getBooksLiteQueryFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<BookEntity> _paginatedResultDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetBooksLiteQueryHandlerTests"/> class.
|
||||
@@ -73,14 +74,7 @@ public class GetBooksLiteQueryHandlerTests
|
||||
GetBooksLiteQuery query = _getBooksLiteQueryFixture.Create();
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
List<BookEntity> bookEntities = _bookEntityFixture.CreateMany(2);
|
||||
PaginatedResultDto<BookEntity> paginatedBooks = new()
|
||||
{
|
||||
Data = bookEntities,
|
||||
CurrentPage = 1,
|
||||
PerPage = 10,
|
||||
Count = 2,
|
||||
NumberOfPages = 1
|
||||
};
|
||||
PaginatedResultDto<BookEntity> paginatedBooks = _paginatedResultDtoFixture.Create(data: bookEntities, currentPage: 1, perPage: 10, count: 2, numberOfPages: 1);
|
||||
_mockBookRepository.GetPaginatedAsync(
|
||||
Arg.Any<PaginationDataDto?>(),
|
||||
Arg.Any<string?>(),
|
||||
@@ -106,14 +100,7 @@ public class GetBooksLiteQueryHandlerTests
|
||||
{
|
||||
// Arrange
|
||||
GetBooksLiteQuery query = _getBooksLiteQueryFixture.Create();
|
||||
PaginatedResultDto<BookEntity> paginatedBooks = new()
|
||||
{
|
||||
Data = [],
|
||||
CurrentPage = 1,
|
||||
PerPage = 10,
|
||||
Count = 0,
|
||||
NumberOfPages = 0
|
||||
};
|
||||
PaginatedResultDto<BookEntity> paginatedBooks = _paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 10, count: 0, numberOfPages: 0);
|
||||
_mockBookRepository.GetPaginatedAsync(
|
||||
Arg.Any<PaginationDataDto?>(),
|
||||
Arg.Any<string?>(),
|
||||
@@ -157,14 +144,7 @@ public class GetBooksLiteQueryHandlerTests
|
||||
// Arrange
|
||||
GetBooksLiteQuery query = _getBooksLiteQueryFixture.Create();
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
PaginatedResultDto<BookEntity> paginatedBooks = new()
|
||||
{
|
||||
Data = [],
|
||||
CurrentPage = 1,
|
||||
PerPage = 10,
|
||||
Count = 0,
|
||||
NumberOfPages = 0
|
||||
};
|
||||
PaginatedResultDto<BookEntity> paginatedBooks = _paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 10, count: 0, numberOfPages: 0);
|
||||
_mockBookRepository.GetPaginatedAsync(
|
||||
Arg.Any<PaginationDataDto?>(),
|
||||
Arg.Any<string?>(),
|
||||
@@ -190,20 +170,8 @@ public class GetBooksLiteQueryHandlerTests
|
||||
public async Task HandleAsync_WhenQueryHasNoPaginationData_ShouldQueryRepositoryWithoutPagination()
|
||||
{
|
||||
// Arrange
|
||||
GetBooksLiteQuery query = new(
|
||||
PaginationData: null,
|
||||
Filter: new LibraryFilterDto { LibraryId = Guid.NewGuid() },
|
||||
SortBy: null,
|
||||
SortOrder: SortOrder.Ascending
|
||||
);
|
||||
PaginatedResultDto<BookEntity> paginatedBooks = new()
|
||||
{
|
||||
Data = [],
|
||||
CurrentPage = 1,
|
||||
PerPage = 10,
|
||||
Count = 0,
|
||||
NumberOfPages = 0
|
||||
};
|
||||
GetBooksLiteQuery query = _getBooksLiteQueryFixture.Create(includePaginationData: false, libraryId: Guid.NewGuid(), sortOrder: SortOrder.Ascending);
|
||||
PaginatedResultDto<BookEntity> paginatedBooks = _paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 10, count: 0, numberOfPages: 0);
|
||||
_mockBookRepository.GetPaginatedAsync(
|
||||
Arg.Any<PaginationDataDto?>(),
|
||||
Arg.Any<string?>(),
|
||||
|
||||
Reference in new issue
Block a user