|
|
|
@ -0,0 +1,115 @@ |
|
|
|
|
using EPAServeur.Context; |
|
|
|
|
using EPAServeur.IServices; |
|
|
|
|
using EPAServeur.Models.EP; |
|
|
|
|
using EPAServeur.Services; |
|
|
|
|
using IO.Swagger.ApiCollaborateur; |
|
|
|
|
using IO.Swagger.DTO; |
|
|
|
|
using IO.Swagger.Enum; |
|
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
|
using NUnit.Framework; |
|
|
|
|
using System; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using System.Text; |
|
|
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
|
|
|
namespace EPAServeur.Tests.Services |
|
|
|
|
{ |
|
|
|
|
public class EpDetailsServiceTests |
|
|
|
|
{ |
|
|
|
|
#region variables |
|
|
|
|
private EpContext context; |
|
|
|
|
private ICollaborateurService collaborateurService; |
|
|
|
|
private ITransformDTO transformDTO; |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region Setup |
|
|
|
|
[SetUp] |
|
|
|
|
public void Setup() |
|
|
|
|
{ |
|
|
|
|
// Utilisation d'une base de données en mémoire |
|
|
|
|
var optionBuider = new DbContextOptionsBuilder<EpContext>() |
|
|
|
|
.UseInMemoryDatabase("server_ep_test") |
|
|
|
|
.Options; |
|
|
|
|
|
|
|
|
|
context = new EpContext(optionBuider); |
|
|
|
|
|
|
|
|
|
context.Database.EnsureDeleted(); |
|
|
|
|
context.Database.EnsureCreated(); |
|
|
|
|
context.SaveChanges(); |
|
|
|
|
|
|
|
|
|
DataSeeder.AddEp(context); |
|
|
|
|
|
|
|
|
|
foreach (var entity in context.ChangeTracker.Entries()) |
|
|
|
|
{ |
|
|
|
|
entity.State = EntityState.Detached; |
|
|
|
|
} |
|
|
|
|
transformDTO = new TransformDTO(); |
|
|
|
|
collaborateurService = new CollaborateurService(new CollaborateurApi(), context, transformDTO); |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region Récupérer EP simple |
|
|
|
|
[TestCase(1, "301ba7f3-095e-4912-8998-a7c942dc5f23", StatutEp.Disponible)] |
|
|
|
|
[TestCase(2, "e7820f92-eab1-42f5-ae96-5c16e71ff1e6", StatutEp.DatesProposees)] |
|
|
|
|
[TestCase(5, "17b87130-0e9d-4b78-b0e3-a11e5f70318d", StatutEp.AttenteEntretien)] |
|
|
|
|
[TestCase(14, "a0f40e2a-cc03-4032-a627-5389e1281c64", StatutEp.Signe)] |
|
|
|
|
public async Task GetEpById(long idEP, Guid? idCollaborateur, StatutEp statutEp) |
|
|
|
|
{ |
|
|
|
|
Ep ep = await context.Ep.FindAsync(idEP); |
|
|
|
|
Assert.IsNotNull(ep); |
|
|
|
|
Assert.AreEqual(idEP, ep.IdEP); |
|
|
|
|
Assert.AreEqual(idCollaborateur, ep.IdCollaborateur); |
|
|
|
|
Assert.AreEqual(statutEp, ep.Statut); |
|
|
|
|
|
|
|
|
|
IEpDetailsService epDetailsService = new EpDetailsService(context, transformDTO, collaborateurService); |
|
|
|
|
|
|
|
|
|
EpDTO epDTO = await epDetailsService.GetEp(ep.IdEP); |
|
|
|
|
Assert.IsNotNull(epDTO); |
|
|
|
|
Assert.AreEqual(epDTO.Collaborateur.Id, ep.IdCollaborateur); |
|
|
|
|
Assert.AreEqual(epDTO.Statut, ep.Statut); |
|
|
|
|
Assert.AreEqual(epDTO.Id, ep.IdEP); |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region Récupérer EP exceptions |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region Récupérer EP avec Engagements |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region Récupérer EP avec participant EP |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region Récupérer EP avec RDV entretiens |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region Récupérer EP avec type entretien |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region Récupérer EP avec CommentaireAssistant |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region Récupérer EP avec demandes de délégation |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region Récupérer EP avec demandes de formation |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region |
|
|
|
|
#endregion |
|
|
|
|
} |
|
|
|
|
} |