#region ========================================================================= USING ===================================================================================== using Lumina.Contracts.Requests.MediaLibrary.Management; using System; using System.Diagnostics.CodeAnalysis; using System.Text.Json; #endregion namespace Lumina.Contracts.UnitTests.Requests.MediaLibrary.Management; /// /// Contains unit tests for the record. /// [ExcludeFromCodeCoverage] public class UpdateLibraryRequestTests { private readonly JsonSerializerOptions _jsonOptions = new() { PropertyNameCaseInsensitive = true }; [Fact] public void RoundTrip_WhenSerializingUpdateLibraryRequest_ShouldPreserveValues() { // Arrange Guid id = Guid.NewGuid(); Guid userId = Guid.NewGuid(); UpdateLibraryRequest expected = new( id, userId, "Books", "Book", [@"C:\Media\Books"], null, true, false, true, false, true ); // Act string json = JsonSerializer.Serialize(expected, _jsonOptions); UpdateLibraryRequest? actual = JsonSerializer.Deserialize(json, _jsonOptions); // Assert Assert.NotNull(actual); Assert.Equivalent(expected, actual); } [Fact] public void Deconstruct_WhenCalled_ShouldReturnAllProperties() { // Arrange Guid id = Guid.NewGuid(); Guid userId = Guid.NewGuid(); UpdateLibraryRequest sut = new( id, userId, "Books", "Book", [@"C:\Media\Books"], null, true, false, true, false, true ); // Act (Guid sutId, Guid sutUserId, string? title, string? libraryType, string[]? contentLocations, string? coverImage, bool isEnabled, bool isLocked, bool downloadMetadataFromWeb, bool shouldSaveMetadataInMediaDirectories, bool shouldSkipUnchangedDirectoriesDuringScan) = sut; // Assert Assert.Equal(sut.Id, sutId); Assert.Equal(sut.UserId, sutUserId); Assert.Equal(sut.Title, title); Assert.Equal(sut.LibraryType, libraryType); Assert.Equal(sut.ContentLocations, contentLocations); Assert.Equal(sut.CoverImage, coverImage); Assert.Equal(sut.IsEnabled, isEnabled); Assert.Equal(sut.IsLocked, isLocked); Assert.Equal(sut.DownloadMetadataFromWeb, downloadMetadataFromWeb); Assert.Equal(sut.ShouldSaveMetadataInMediaDirectories, shouldSaveMetadataInMediaDirectories); Assert.Equal(sut.ShouldSkipUnchangedDirectoriesDuringScan, shouldSkipUnchangedDirectoriesDuringScan); } }