Files
Nemera/tests/UnitTests/Lumina.Contracts.UnitTests/Requests/MediaLibrary/Management/AddLibraryRequestTests.cs
T

75 lines
2.5 KiB
C#

#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Requests.MediaLibrary.Management;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
#endregion
namespace Lumina.Contracts.UnitTests.Requests.MediaLibrary.Management;
/// <summary>
/// Contains unit tests for the <see cref="AddLibraryRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class AddLibraryRequestTests
{
private readonly JsonSerializerOptions _jsonOptions = new()
{
PropertyNameCaseInsensitive = true
};
[Fact]
public void RoundTrip_WhenSerializingAddLibraryRequest_ShouldPreserveValues()
{
// Arrange
AddLibraryRequest expected = new(
"Books",
"Book",
[@"C:\Media\Books"],
null,
true,
false,
true,
false,
true
);
// Act
string json = JsonSerializer.Serialize(expected, _jsonOptions);
AddLibraryRequest? actual = JsonSerializer.Deserialize<AddLibraryRequest>(json, _jsonOptions);
// Assert
Assert.NotNull(actual);
Assert.Equivalent(expected, actual);
}
[Fact]
public void Deconstruct_WhenCalled_ShouldReturnAllProperties()
{
// Arrange
AddLibraryRequest sut = new(
"Books",
"Book",
[@"C:\Media\Books"],
null,
true,
false,
true,
false,
true
);
// Act
(string? title, string? libraryType, string[]? contentLocations, string? coverImage, bool isEnabled, bool isLocked, bool downloadMetadataFromWeb, bool shouldSaveMetadataInMediaDirectories, bool shouldSkipUnchangedDirectoriesDuringScan) = sut;
// Assert
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);
}
}