You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OptifitWebService/TestAPI/MapperTests/FormationMapperTests.cs

62 lines
2.1 KiB

using Infrastructure.Entities;
using Server.Dto.Request;
using Server.Mappers;
namespace TestAPI.MapperTests
{
public class FormationMapperTests
{
[Fact]
public void ToDto_ConvertsFormationEntityToResponseFormationDto()
{
// Arrange
var formationEntity = new FormationEntity
{
Id = "1",
AlumniId = "1",
Name = "Test Formation",
StartDate = DateTime.UtcNow,
EndDate = DateTime.UtcNow.AddYears(1),
SchoolName = "Test School",
IsCurrent = false
};
// Act
var result = formationEntity.ToDto();
// Assert
Assert.Equal(formationEntity.Id, result.Id);
Assert.Equal(formationEntity.AlumniId, result.AlumniId);
Assert.Equal(formationEntity.Name, result.Name);
Assert.Equal(formationEntity.StartDate, result.StartingDate);
Assert.Equal(formationEntity.EndDate, result.EndingDate);
Assert.Equal(formationEntity.SchoolName, result.SchoolName);
Assert.Equal(formationEntity.IsCurrent, result.CurrentFormation);
}
[Fact]
public void ToEntity_ConvertsRequestFormationDtoToFormationEntity()
{
// Arrange
var requestFormationDto = new RequestFormationDto
{
Name = "Test Formation",
StartingDate = DateTime.UtcNow,
EndingDate = DateTime.UtcNow.AddYears(1),
SchoolName = "Test School",
CurrentFormation = false
};
// Act
var result = requestFormationDto.ToEntity();
// Assert
Assert.Equal(requestFormationDto.Name, result.Name);
Assert.Equal(requestFormationDto.StartingDate, result.StartDate);
Assert.Equal(requestFormationDto.EndingDate, result.EndDate);
Assert.Equal(requestFormationDto.SchoolName, result.SchoolName);
Assert.Equal(requestFormationDto.CurrentFormation, result.IsCurrent);
}
}
}