mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 21:01:10 +00:00
74 lines
2.4 KiB
C#
74 lines
2.4 KiB
C#
#region ========================================================================= USING =====================================================================================
|
|
using Nemera.Application.Common.Mapping.Authentication;
|
|
using Nemera.Application.Core.UsersManagement.Authentication.Commands.RecoverPassword;
|
|
using Nemera.Contracts.Fixtures.Core.Requests.Authentication;
|
|
using Nemera.Contracts.Requests.Authentication;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
#endregion
|
|
|
|
namespace Nemera.Application.UnitTests.Common.Mapping.Authentication;
|
|
|
|
/// <summary>
|
|
/// Contains unit tests for the <see cref="RecoverPasswordRequestMapping"/> class.
|
|
/// </summary>
|
|
[ExcludeFromCodeCoverage]
|
|
public class RecoverPasswordRequestMappingTests
|
|
{
|
|
private readonly RecoverPasswordRequestFixture _recoverPasswordRequestFixture = new();
|
|
|
|
[Fact]
|
|
public void ToCommand_WhenMappingRequest_ShouldMapCorrectly()
|
|
{
|
|
// Arrange
|
|
RecoverPasswordRequest request = _recoverPasswordRequestFixture.Create();
|
|
|
|
// Act
|
|
RecoverPasswordCommand result = request.ToCommand();
|
|
|
|
// Assert
|
|
Assert.NotNull(result);
|
|
Assert.Equal(request.Username, result.Username);
|
|
Assert.Equal(request.TotpCode, result.TotpCode);
|
|
}
|
|
|
|
[Fact]
|
|
public void ToCommand_WhenMappingRequestWithNullValues_ShouldMapCorrectly()
|
|
{
|
|
// Arrange
|
|
RecoverPasswordRequest request = _recoverPasswordRequestFixture.Create(includeUsername: false, includeTotpCode: false);
|
|
|
|
// Act
|
|
RecoverPasswordCommand result = request.ToCommand();
|
|
|
|
// Assert
|
|
Assert.NotNull(result);
|
|
Assert.Null(result.Username);
|
|
Assert.Null(result.TotpCode);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("user1", "123456")]
|
|
[InlineData("", "")]
|
|
[InlineData("testUser", null)]
|
|
[InlineData(null, "654321")]
|
|
public void ToCommand_WhenMappingRequestWithSpecificValues_ShouldMapCorrectly(
|
|
string? username,
|
|
string? totpCode)
|
|
{
|
|
// Arrange
|
|
RecoverPasswordRequest request = _recoverPasswordRequestFixture.Create(
|
|
username,
|
|
totpCode,
|
|
includeUsername: username is not null,
|
|
includeTotpCode: totpCode is not null);
|
|
|
|
// Act
|
|
RecoverPasswordCommand result = request.ToCommand();
|
|
|
|
// Assert
|
|
Assert.NotNull(result);
|
|
Assert.Equal(username, result.Username);
|
|
Assert.Equal(totpCode, result.TotpCode);
|
|
}
|
|
}
|