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.
Digitalisation_EPA_Serveur/EPAServeur.Tests/Services/EpInformationTests.cs

603 lines
23 KiB

using EPAServeur.Context;
using EPAServeur.IServices;
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.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EPAServeur.Tests.Services
{
[TestFixture]
public class EpInformationTests
{
#region
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();
// Ajout du jeu de données pour les tests
DataSeeder.AddEp(context);
// Détache les entités du context car la base de données InMemory créé des conflits
// entre les clés primaires lors d'un Update ou d'un Insert
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ération des EP en cours
[TestCase(1, 3)] //Tours
[TestCase(2, 3)] //Orléans
[TestCase(3, 3)] // Paris
public async Task GetEpEnCours_UneBU(long? idBUs, int nbElements)
{
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?>{ idBUs }, true, 1, 15, "", "", null, null);
int count = await epInformationService.GetEPEnCoursCount(new List<long?> { idBUs }, "", null, null);
Assert.AreEqual(count, nbElements);
Assert.AreEqual(count, epInformationDTOs.Count());
foreach(EpInformationDTO ep in epInformationDTOs)
{
Assert.AreEqual(ep.Collaborateur.BusinessUnit.Id, idBUs);
Assert.IsTrue(EstEpEnCours(ep.Statut));
}
}
[Test]
public async Task GetEpEnCours_OrleansTours()
{
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1,2 }, true, 1, 15, "", "", null, null);
int count = await epInformationService.GetEPEnCoursCount(new List<long?> { 1, 2 }, "", null, null);
Assert.AreEqual(count, 6);
Assert.AreEqual(count, epInformationDTOs.Count());
long? bu;
foreach(EpInformationDTO ep in epInformationDTOs)
{
bu = ep.Collaborateur.BusinessUnit.Id;
Assert.IsTrue(bu == 1 || bu == 2);
Assert.IsTrue(EstEpEnCours(ep.Statut));
}
}
//tri colonne
[TestCase("agence")]
[TestCase("collaborateur")]
[TestCase("referent")]
[TestCase("dateentretien")]
[TestCase("typeep")]
[TestCase("statutep")]
[TestCase("datearrivee")]
[TestCase("datedisponibilite")]
public async Task GetEpEnCours_TriColonneASC(string tri)
{
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, true, 1, 15, "", tri, null, null);
EpInformationDTO ep1, ep2;
int compare = 0;
for(int i = 0; i < epInformationDTOs.Count()-1; ++i)
{
ep1 = epInformationDTOs.ElementAt(i);
ep2 = epInformationDTOs.ElementAt(i+1);
switch(tri)
{
case "agence":
compare = ep1.Collaborateur.BusinessUnit.Nom.CompareTo(ep2.Collaborateur.BusinessUnit.Nom);
break;
case "collaborateur":
compare = (ep1.Collaborateur.Nom + " " + ep1.Collaborateur.Prenom).CompareTo((ep2.Collaborateur.Nom + " " + ep2.Collaborateur.Prenom));
break;
case "referent":
compare = (ep1.Referent.Nom + " " + ep1.Referent.Prenom).CompareTo((ep2.Referent.Nom + " " + ep2.Referent.Prenom));
break;
case "dateentretien":
compare = ep1.DatePrevisionnelle.Value.CompareTo(ep2.DatePrevisionnelle.Value);
break;
case "typeep":
compare = ep1.Type.CompareTo(ep2.Type);
break;
case "statutep":
compare = ep1.Statut.CompareTo(ep2.Statut);
break;
case "datearrivee":
compare = ep1.Collaborateur.DateArrivee.Value.CompareTo(ep2.Collaborateur.DateArrivee.Value);
break;
case "datedisponibilite":
compare = ep1.DateDisponibilite.Value.CompareTo(ep2.DateDisponibilite.Value);
break;
}
Assert.IsTrue(compare <= 0);
Assert.IsTrue(EstEpEnCours(ep1.Statut));
Assert.IsTrue(EstEpEnCours(ep2.Statut));
}
}
//tri colonne
[TestCase("agence")]
[TestCase("collaborateur")]
[TestCase("referent")]
[TestCase("dateentretien")]
[TestCase("typeep")]
[TestCase("statutep")]
[TestCase("datearrivee")]
[TestCase("datedisponibilite")]
public async Task GetEpEnCours_TriColonneDESC(string tri)
{
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, false, 1, 15, "", tri, null, null);
EpInformationDTO ep1, ep2;
int compare = 0;
for (int i = 0; i < epInformationDTOs.Count() - 1; ++i)
{
ep1 = epInformationDTOs.ElementAt(i);
ep2 = epInformationDTOs.ElementAt(i + 1);
switch (tri)
{
case "agence":
compare = ep1.Collaborateur.BusinessUnit.Nom.CompareTo(ep2.Collaborateur.BusinessUnit.Nom);
break;
case "collaborateur":
compare = (ep1.Collaborateur.Nom + " " + ep1.Collaborateur.Prenom).CompareTo((ep2.Collaborateur.Nom + " " + ep2.Collaborateur.Prenom));
break;
case "referent":
compare = (ep1.Referent.Nom + " " + ep1.Referent.Prenom).CompareTo((ep2.Referent.Nom + " " + ep2.Referent.Prenom));
break;
case "dateentretien":
compare = ep1.DatePrevisionnelle.Value.CompareTo(ep2.DatePrevisionnelle.Value);
break;
case "typeep":
compare = ep1.Type.CompareTo(ep2.Type);
break;
case "statutep":
compare = ep1.Statut.CompareTo(ep2.Statut);
break;
case "datearrivee":
compare = ep1.Collaborateur.DateArrivee.Value.CompareTo(ep2.Collaborateur.DateArrivee.Value);
break;
case "datedisponibilite":
compare = ep1.DateDisponibilite.Value.CompareTo(ep2.DateDisponibilite.Value);
break;
}
Assert.IsTrue(compare >= 0);
Assert.IsTrue(EstEpEnCours(ep1.Statut));
Assert.IsTrue(EstEpEnCours(ep2.Statut));
}
}
//tris date
[TestCase(01, 03, 2021, 5)]
[TestCase(20, 03, 2021, 2)]
[TestCase(01, 04, 2021, 0)]
public async Task GetEpEnCours_TriDateD1(int j, int m, int a, int count)
{
DateTime date = new DateTime(a, m, j);
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, true, 1, 15, "", "", date, null);
Assert.AreEqual(epInformationDTOs.Count(), count);
foreach(EpInformationDTO ep in epInformationDTOs)
{
Assert.IsTrue(date <= ep.DatePrevisionnelle.Value);
Assert.IsTrue(EstEpEnCours(ep.Statut));
}
}
[TestCase(01, 04, 2021, 6)]
[TestCase(15, 03, 2021, 3)]
[TestCase(1, 02, 2021, 0)]
public async Task GetEpEnCours_TriDateD2(int j, int m, int a, int count)
{
DateTime date = new DateTime(a, m, j); IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, true, 1, 15, "", "", null, date);
Assert.AreEqual(epInformationDTOs.Count(), count);
foreach (EpInformationDTO ep in epInformationDTOs)
{
Assert.IsTrue(date >= ep.DatePrevisionnelle.Value);
Assert.IsTrue(EstEpEnCours(ep.Statut));
}
}
[TestCase(01, 02, 2021, 28, 02, 2021, 1)]
[TestCase(01, 02, 2021, 01, 04, 2021, 6)]
[TestCase(15, 02, 2021, 15, 03, 2021, 3)]
[TestCase(01, 01, 2021, 31, 01, 2021, 0)]
[TestCase(01, 01, 2022, 31, 01, 2022, 0)]
public async Task GetEpEnCours_TriDateD1D2(int j1, int m1, int a1, int j2, int m2, int a2, int count)
{
DateTime date1 = new DateTime(a1, m1, j1);
DateTime date2 = new DateTime(a2, m2, j2);
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, true, 1, 15, "", "", date1, date2);
Assert.AreEqual(epInformationDTOs.Count(), count);
foreach (EpInformationDTO ep in epInformationDTOs)
{
Assert.IsTrue(condition: date1 <= ep.DatePrevisionnelle.Value);
Assert.IsTrue(date2 >= ep.DatePrevisionnelle.Value);
Assert.IsTrue(EstEpEnCours(ep.Statut));
}
}
//Tri texte
[TestCase("", 6)]
[TestCase("Ma", 2)]
[TestCase("Ne", 2)]
[TestCase("nE", 2)]
[TestCase("ma", 2)]
[TestCase("D", 2)]
[TestCase("d", 2)]
public async Task GetEpEnCours_texte(string texte, int count)
{
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, true, 1, 15, texte, "", null, null);
Assert.AreEqual(count, epInformationDTOs.Count());
foreach (EpInformationDTO ep in epInformationDTOs)
{
Assert.IsTrue((ep.Collaborateur.Nom + " " + ep.Collaborateur.Prenom).ToLower().Contains(texte.ToLower()) || (ep.Collaborateur.Prenom + " " + ep.Collaborateur.Nom).ToLower().Contains(texte.ToLower()));
Assert.IsTrue(EstEpEnCours(ep.Statut));
}
}
#endregion
#region Récupération des EP signés
[TestCase(1, 3)] //Tours
[TestCase(2, 3)] //Orléans
[TestCase(3, 3)] // Paris
public async Task GetEpSignes_UneBU(long? idBUs, int nbElements)
{
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignes(new List<long?>{ idBUs }, true, 1, 15, "", "", null, null);
int count = await epInformationService.GetEPSignesCount(new List<long?> { idBUs }, "", null, null);
Assert.AreEqual(count, nbElements);
Assert.AreEqual(count, epInformationDTOs.Count());
foreach(EpInformationDTO ep in epInformationDTOs)
{
Assert.AreEqual(ep.Collaborateur.BusinessUnit.Id, idBUs);
Assert.IsTrue(ep.Statut == StatutEp.Signe);
}
}
public async Task GetEpSignes_OrleansTours()
{
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignes(new List<long?> { 1,2 }, true, 1, 15, "", "", null, null);
int count = await epInformationService.GetEPSignesCount(new List<long?> { 1, 2 }, "", null, null);
Assert.AreEqual(count, 8);
Assert.AreEqual(count, epInformationDTOs.Count());
long? bu;
foreach(EpInformationDTO ep in epInformationDTOs)
{
bu = ep.Collaborateur.BusinessUnit.Id;
Assert.IsTrue(bu == 1 || bu == 2);
Assert.IsTrue(ep.Statut == StatutEp.Signe);
}
}
//tri colonne
[TestCase("agence")]
[TestCase("collaborateur")]
[TestCase("referent")]
[TestCase("dateentretien")]
[TestCase("typeep")]
[TestCase("statutep")]
[TestCase("datearrivee")]
[TestCase("datedisponibilite")]
public async Task GetEpSignes_TriColonneASC(string tri)
{
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignes(new List<long?> { 1, 2 }, true, 1, 15, "", tri, null, null);
EpInformationDTO ep1, ep2;
int compare = 0;
for(int i = 0; i < epInformationDTOs.Count()-1; ++i)
{
ep1 = epInformationDTOs.ElementAt(i);
ep2 = epInformationDTOs.ElementAt(i+1);
switch(tri)
{
case "agence":
compare = ep1.Collaborateur.BusinessUnit.Nom.CompareTo(ep2.Collaborateur.BusinessUnit.Nom);
break;
case "collaborateur":
compare = (ep1.Collaborateur.Nom + " " + ep1.Collaborateur.Prenom).CompareTo((ep2.Collaborateur.Nom + " " + ep2.Collaborateur.Prenom));
break;
case "referent":
compare = (ep1.Referent.Nom + " " + ep1.Referent.Prenom).CompareTo((ep2.Referent.Nom + " " + ep2.Referent.Prenom));
break;
case "dateentretien":
compare = ep1.DatePrevisionnelle.Value.CompareTo(ep2.DatePrevisionnelle.Value);
break;
case "typeep":
compare = ep1.Type.CompareTo(ep2.Type);
break;
case "statutep":
compare = ep1.Statut.CompareTo(ep2.Statut);
break;
case "datearrivee":
compare = ep1.Collaborateur.DateArrivee.Value.CompareTo(ep2.Collaborateur.DateArrivee.Value);
break;
case "datedisponibilite":
compare = ep1.DateDisponibilite.Value.CompareTo(ep2.DateDisponibilite.Value);
break;
}
Assert.IsTrue(compare <= 0);
Assert.IsTrue(ep1.Statut == StatutEp.Signe);
Assert.IsTrue(ep2.Statut == StatutEp.Signe);
}
}
//tri colonne
[TestCase("agence")]
[TestCase("collaborateur")]
[TestCase("referent")]
[TestCase("dateentretien")]
[TestCase("typeep")]
[TestCase("statutep")]
[TestCase("datearrivee")]
[TestCase("datedisponibilite")]
public async Task GetEpSignes_TriColonneDESC(string tri)
{
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignes(new List<long?> { 1, 2 }, false, 1, 15, "", tri, null, null);
EpInformationDTO ep1, ep2;
int compare = 0;
for (int i = 0; i < epInformationDTOs.Count() - 1; ++i)
{
ep1 = epInformationDTOs.ElementAt(i);
ep2 = epInformationDTOs.ElementAt(i + 1);
switch (tri)
{
case "agence":
compare = ep1.Collaborateur.BusinessUnit.Nom.CompareTo(ep2.Collaborateur.BusinessUnit.Nom);
break;
case "collaborateur":
compare = (ep1.Collaborateur.Nom + " " + ep1.Collaborateur.Prenom).CompareTo((ep2.Collaborateur.Nom + " " + ep2.Collaborateur.Prenom));
break;
case "referent":
compare = (ep1.Referent.Nom + " " + ep1.Referent.Prenom).CompareTo((ep2.Referent.Nom + " " + ep2.Referent.Prenom));
break;
case "dateentretien":
compare = ep1.DatePrevisionnelle.Value.CompareTo(ep2.DatePrevisionnelle.Value);
break;
case "typeep":
compare = ep1.Type.CompareTo(ep2.Type);
break;
case "statutep":
compare = ep1.Statut.CompareTo(ep2.Statut);
break;
case "datearrivee":
compare = ep1.Collaborateur.DateArrivee.Value.CompareTo(ep2.Collaborateur.DateArrivee.Value);
break;
case "datedisponibilite":
compare = ep1.DateDisponibilite.Value.CompareTo(ep2.DateDisponibilite.Value);
break;
}
Assert.IsTrue(compare >= 0);
Assert.IsTrue(ep1.Statut == StatutEp.Signe);
Assert.IsTrue(ep2.Statut == StatutEp.Signe);
}
}
//tris date
[TestCase(01, 01, 2018, 4)]
[TestCase(01, 01, 2019, 2)]
[TestCase(01, 01, 2020, 1)]
[TestCase(01, 01, 2021, 0)]
[TestCase(01, 01, 2022, 0)]
public async Task GetEpSignes_TriDateD1(int j, int m, int a, int count)
{
DateTime date = new DateTime(a, m, j);
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignes(new List<long?> { 1, 2 }, true, 1, 15, "", "", date, null);
Assert.AreEqual(epInformationDTOs.Count(), count);
foreach(EpInformationDTO ep in epInformationDTOs)
{
Assert.IsTrue(date <= ep.DatePrevisionnelle.Value);
Assert.IsTrue(ep.Statut == StatutEp.Signe);
}
}
[TestCase(31, 12, 2019)]
[TestCase(01, 01, 2019)]
[TestCase(31, 07, 2018)]
[TestCase(31, 07, 2017)]
public async Task GetEpSignes_TriDateD2(int j, int m, int a)
{
DateTime date = new DateTime(a, m, j); IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignes(new List<long?> { 1, 2 }, true, 1, 15, "", "", null, date);
int count = await epInformationService.GetEPSignesCount(new List<long?> { 1, 2 }, "", null, date);
Assert.AreEqual(epInformationDTOs.Count(), count);
foreach (EpInformationDTO ep in epInformationDTOs)
{
Assert.IsTrue(date >= ep.DatePrevisionnelle.Value);
Assert.IsTrue(ep.Statut == StatutEp.Signe);
}
}
[TestCase(01, 07, 2021, 31, 12, 2021, 0)]
[TestCase(01, 09, 2018, 01, 12, 2019, 1)]
[TestCase(01, 01, 2018, 31, 12, 2019, 3)]
[TestCase(01, 01, 2017, 31, 12, 2017, 2)]
public async Task GetEpSignes_TriDateD1D2(int j1, int m1, int a1, int j2, int m2, int a2, int count)
{
DateTime date1 = new DateTime(a1, m1, j1);
DateTime date2 = new DateTime(a2, m2, j2);
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignes(new List<long?> { 1, 2 }, true, 1, 15, "", "", date1, date2);
Assert.AreEqual(epInformationDTOs.Count(), count);
foreach (EpInformationDTO ep in epInformationDTOs)
{
Assert.IsTrue(condition: date1 <= ep.DatePrevisionnelle.Value);
Assert.IsTrue(date2 >= ep.DatePrevisionnelle.Value);
Assert.IsTrue(ep.Statut == StatutEp.Signe);
}
}
//Tri texte
[TestCase("", 6)]
[TestCase("Ma", 1)]
[TestCase("Ne", 1)]
[TestCase("nE", 1)]
[TestCase("ma", 1)]
[TestCase("D", 2)]
[TestCase("d", 2)]
public async Task GetEpSignes_texte(string texte, int count)
{
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignes(new List<long?> { 1, 2 }, true, 1, 15, texte, "", null, null);
Assert.AreEqual(count, epInformationDTOs.Count());
foreach (EpInformationDTO ep in epInformationDTOs)
{
Assert.IsTrue((ep.Collaborateur.Nom + " " + ep.Collaborateur.Prenom).ToLower().Contains(texte.ToLower()) || (ep.Collaborateur.Prenom + " " + ep.Collaborateur.Nom).ToLower().Contains(texte.ToLower()));
Assert.IsTrue(ep.Statut == StatutEp.Signe);
}
}
#endregion
#region Récupération des EP signés d'un collaborateur
[TestCase("ea027734-ff0f-4308-8879-133a09fb3c46", 1)]
[TestCase("56e3d82d-4be4-4449-a1f7-b4004b6bd186", 1)]
[TestCase("3f276ab8-727a-4e26-ad5d-4d296158688e", 1)]
[TestCase("01ee85ff-d7f3-494b-b1de-26ced8fbfa0d", 1)]
[TestCase("eb8b0f33-f529-4985-861e-1207f3312bb5", 2)]
[TestCase("eb8b0f33-f529-4985-861e-1207f3312bb4", 0)]
[TestCase("ea027734-ff0f-4308-8879-133a09fb3c46", 1)]
[TestCase("80220063-a5fa-472b-b610-2e350566df98", 1)]
public async Task GetEPCoursReferent(Guid idReferent, int count)
{
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCoursReferent(idReferent, true, 1, 15, "", "", null, null);
int epCount = await epInformationService.GetEPEnCoursReferentCount(idReferent, "", null, null);
Assert.AreEqual(epCount, count);
foreach(EpInformationDTO ep in epInformationDTOs)
{
Assert.AreEqual(ep.Referent.Id, idReferent);
Assert.IsTrue(EstEpEnCours(ep.Statut));
}
}
#endregion
#region Récupération des EP
[TestCase("56e3d82d-4be4-4449-a1f7-b4004b6bd186", 1)]
[TestCase("3f276ab8-727a-4e26-ad5d-4d296158688e", 1)]
[TestCase("01ee85ff-d7f3-494b-b1de-26ced8fbfa0d", 1)]
[TestCase("eb8b0f33-f529-4985-861e-1207f3312bb5", 2)]
[TestCase("d4fc247b-015a-44d6-8f3e-a52f0902d2bf", 1)]
[TestCase("b799a9de-7743-435e-933f-7f730affc5ae", 1)]
[TestCase("b799a9de-7743-435e-933f-7f730affc5a5", 0)]
[TestCase("ea027734-ff0f-4308-8879-133a09fb3c46", 1)]
public async Task GetEPEnSignesReferent(Guid idReferent, int count)
{
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignesReferent(idReferent, true, 1, 15, "", "", null, null);
int epCount = await epInformationService.GetEPSignesReferentCount(idReferent, "", null, null);
Assert.AreEqual(epCount, count);
foreach (EpInformationDTO ep in epInformationDTOs)
{
Assert.AreEqual(ep.Referent.Id, idReferent);
Assert.IsTrue(ep.Statut.Equals(StatutEp.Signe));
}
}
#endregion
#region Récupérés EP signés collaborateur
[TestCase("301ba7f3-095e-4912-8998-a7c942dc5f23", 1)]
[TestCase("4f3fcd23-a1e4-4c9e-afa2-d06ca9216491", 0)]
[TestCase("e7820f92-eab1-42f5-ae96-5c16e71ff1e6", 1)]
[TestCase("a0f40e2a-cc03-4032-a627-5389e1281c64", 3)]
[TestCase("b5254c6c-7caa-435f-a4bb-e0cf92559832", 1)]
[TestCase("b5254c6c-7caa-435f-a4bb-e0cf92559830", 0)]
[TestCase("13fbe621-1bc9-4f04-afde-b54ca076e239", 3)]
public async Task GetEPSignesCollaborateur(Guid idCollaborateur, int count)
{
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignesCollaborateur(idCollaborateur);
Assert.AreEqual(count, epInformationDTOs.Count());
foreach(EpInformationDTO ep in epInformationDTOs)
{
Assert.AreEqual(ep.Statut, StatutEp.Signe);
Assert.AreEqual(idCollaborateur, ep.Collaborateur.Id);
}
}
#endregion
#region Récupéré EP en cours d'un collaborateur
[TestCase("301ba7f3-095e-4912-8998-a7c942dc5f23", true)]
[TestCase("eb8b0f33-f529-4985-861e-1207f3312bb5", false)]
[TestCase("e7820f92-eab1-42f5-ae96-5c16e71ff1e6", true)]
[TestCase("a0f40e2a-cc03-4032-a627-5389e1281c64", true)]
[TestCase("b799a9de-7743-435e-933f-7f730affc5ae", false)]
[TestCase("de98a866-736f-4295-a669-92a8694e2ee3", true)]
public async Task GetEPEnCoursCollaborateur(Guid idCollaborateur, bool existe)
{
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
EpInformationDTO epInformationDTO = await epInformationService.GetProchainEPCollaborateur(idCollaborateur);
if(existe)
{
Assert.IsNotNull(epInformationDTO);
Assert.IsTrue(EstEpEnCours(epInformationDTO.Statut));
Assert.AreEqual(idCollaborateur, epInformationDTO.Collaborateur.Id);
}
else
{
Assert.IsNull(epInformationDTO);
}
}
#endregion
#region méthodes privées
private bool EstEpEnCours(StatutEp statut)
{
return statut != StatutEp.Annule && statut != StatutEp.Cree && statut != StatutEp.Rejete && statut != StatutEp.Signe;
}
#endregion
}
}