mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 21:01:10 +00:00
79 lines
2.5 KiB
C#
79 lines
2.5 KiB
C#
#region ========================================================================= USING =====================================================================================
|
|
using Nemera.Application.Common.Mapping.Playlists;
|
|
using Nemera.Application.Core.Playlists.Commands.UpdatePlaylist;
|
|
using Nemera.Contracts.Fixtures.Core.Requests.Playlists;
|
|
using Nemera.Contracts.Requests.Playlists;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
#endregion
|
|
|
|
namespace Nemera.Application.UnitTests.Common.Mapping.Playlists;
|
|
|
|
/// <summary>
|
|
/// Contains unit tests for the <see cref="UpdatePlaylistRequestMapping"/> class.
|
|
/// </summary>
|
|
[ExcludeFromCodeCoverage]
|
|
public class UpdatePlaylistRequestMappingTests
|
|
{
|
|
private readonly UpdatePlaylistRequestFixture _updatePlaylistRequestFixture = new();
|
|
|
|
[Fact]
|
|
public void ToCommand_WhenEveryMemberIsSupplied_ShouldPreserveThem()
|
|
{
|
|
// Arrange
|
|
UpdatePlaylistRequest request = _updatePlaylistRequestFixture.Create(
|
|
name: "Deep Focus",
|
|
description: "Long sessions");
|
|
|
|
// Act
|
|
UpdatePlaylistCommand command = request.ToCommand("playlist-id");
|
|
|
|
// Assert
|
|
Assert.Equal("playlist-id", command.PlaylistId);
|
|
Assert.Equal("Deep Focus", command.Name);
|
|
Assert.Equal("Long sessions", command.Description);
|
|
}
|
|
|
|
[Fact]
|
|
public void ToCommand_WhenTheOptionalMembersAreOmitted_ShouldPreserveThemAsNull()
|
|
{
|
|
// Arrange
|
|
UpdatePlaylistRequest request = _updatePlaylistRequestFixture.Create(
|
|
name: "Deep Focus",
|
|
includeDescription: false);
|
|
|
|
// Act
|
|
UpdatePlaylistCommand command = request.ToCommand("playlist-id");
|
|
|
|
// Assert
|
|
Assert.Equal("Deep Focus", command.Name);
|
|
Assert.Null(command.Description);
|
|
}
|
|
|
|
[Fact]
|
|
public void ToCommand_WhenThePlaylistIdIsNull_ShouldPreserveNull()
|
|
{
|
|
// Arrange
|
|
UpdatePlaylistRequest request = _updatePlaylistRequestFixture.Create();
|
|
|
|
// Act
|
|
UpdatePlaylistCommand command = request.ToCommand(null);
|
|
|
|
// Assert
|
|
Assert.Null(command.PlaylistId);
|
|
Assert.NotNull(command.Name);
|
|
}
|
|
|
|
[Fact]
|
|
public void ToCommand_WhenThePlaylistIdIsEmpty_ShouldPreserveEmpty()
|
|
{
|
|
// Arrange
|
|
UpdatePlaylistRequest request = _updatePlaylistRequestFixture.Create();
|
|
|
|
// Act
|
|
UpdatePlaylistCommand command = request.ToCommand(string.Empty);
|
|
|
|
// Assert
|
|
Assert.Equal(string.Empty, command.PlaylistId);
|
|
}
|
|
}
|