diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/DeleteLibrary/DeleteLibraryEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/DeleteLibrary/DeleteLibraryEndpointTests.cs index 0bf11ce0..270858c0 100644 --- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/DeleteLibrary/DeleteLibraryEndpointTests.cs +++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/DeleteLibrary/DeleteLibraryEndpointTests.cs @@ -2,6 +2,7 @@ using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management; using Lumina.Application.Common.DataAccess.Entities.UsersManagement; using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management; +using Lumina.Application.Fixtures.Common.DataAccess.Entities.Plugins; using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement; using Lumina.DataAccess.Core.UoW; using Lumina.Domain.SharedKernel.Common.Enums.Authorization; @@ -39,6 +40,14 @@ public class DeleteLibraryEndpointTests : IClassFixture /// Initializes a new instance of the class. @@ -79,6 +88,33 @@ public class DeleteLibraryEndpointTests : IClassFixture(); + Assert.Null(await dbContext.Libraries.FirstOrDefaultAsync(library => library.Id == libraryId)); + Assert.False(await dbContext.LibraryScans.AnyAsync(scan => scan.LibraryId == libraryId)); + Assert.False(await dbContext.LibraryScanResults.AnyAsync(result => result.LibraryScanId == scanId)); + Assert.False(await dbContext.LibraryScanStagingResults.AnyAsync(result => result.LibraryScanId == scanId)); + Assert.False(await dbContext.LibraryScanSnapshots.AnyAsync(snapshot => snapshot.LibraryId == libraryId)); + Assert.False(await dbContext.DirectoryScanFingerprints.AnyAsync(fingerprint => fingerprint.LibraryId == libraryId)); + Assert.False(await dbContext.LibraryMetadataProviderConfigurations.AnyAsync(configuration => configuration.LibraryId == libraryId)); + Assert.False(await dbContext.LibraryArtworkProviderConfigurations.AnyAsync(configuration => configuration.LibraryId == libraryId)); + Assert.False(await dbContext.LibraryBookReaderConfigurations.AnyAsync(configuration => configuration.LibraryId == libraryId)); + } + [Fact] public async Task DeleteLibrary_WhenLibraryDoesNotExist_ShouldReturnNotFound() { @@ -129,6 +165,30 @@ public class DeleteLibraryEndpointTests : IClassFixture + /// Seeds a together with the data that belongs to it. + /// + /// The Id of the library to seed. + /// The Id of the user that owns the library. + /// The Id of the library scan to seed. + /// A task representing the asynchronous operation. + private async Task SeedLibraryWithRelatedDataAsync(Guid libraryId, Guid userId, Guid scanId) + { + using IServiceScope scope = _apiFactory.Services.CreateScope(); + LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService(); + LibraryEntity library = _libraryEntityFixture.Create(id: libraryId, userId: userId, title: "Test Library", libraryType: LibraryType.EBook, contentLocations: []); + dbContext.Libraries.Add(library); + dbContext.LibraryScans.Add(_libraryScanEntityFixture.Create(id: scanId, libraryId: libraryId, userId: userId, libraryEntity: library)); + dbContext.LibraryScanResults.Add(_libraryScanResultEntityFixture.Create(libraryScanId: scanId)); + dbContext.LibraryScanStagingResults.Add(_libraryScanStagingResultsEntityFixture.Create(libraryScanId: scanId)); + dbContext.LibraryScanSnapshots.Add(_libraryScanSnapshotEntityFixture.Create(libraryId: libraryId)); + dbContext.DirectoryScanFingerprints.Add(_directoryScanFingerprintEntityFixture.Create(libraryId: libraryId)); + dbContext.LibraryMetadataProviderConfigurations.Add(_libraryMetadataProviderConfigurationEntityFixture.Create(libraryId, Guid.NewGuid(), 0)); + dbContext.LibraryArtworkProviderConfigurations.Add(_libraryArtworkProviderConfigurationEntityFixture.Create(libraryId, Guid.NewGuid(), 0)); + dbContext.LibraryBookReaderConfigurations.Add(_libraryBookReaderConfigurationEntityFixture.Create(libraryId: libraryId)); + await dbContext.SaveChangesAsync(); + } + /// /// Seeds a and returns its Id. ///