MAJ des tests unitaires: Ajout du service TransformDTO

develop
jboinembalome 3 years ago
parent b64e5c0a23
commit 838bc44b08
  1. 6
      EPAServeur.Tests/Controllers/DemandeDelegationApiTests.cs
  2. 1
      EPAServeur.Tests/Controllers/EngagementsApiTests.cs
  3. 6
      EPAServeur.Tests/Controllers/EpInformationApiTests.cs
  4. 1
      EPAServeur.Tests/Controllers/FormationApiTests.cs
  5. 7
      EPAServeur.Tests/Controllers/NoteApiTests.cs
  6. 1
      EPAServeur.Tests/Controllers/ParticipationFormationApiTests.cs
  7. 1
      EPAServeur.Tests/Controllers/ReferentEPApiTests.cs
  8. 76
      EPAServeur.Tests/Services/CollaborateurServiceTests.cs
  9. 19
      EPAServeur.Tests/Services/DemandeDelegationServiceTests.cs
  10. 53
      EPAServeur.Tests/Services/EngagementServiceTests.cs
  11. 45
      EPAServeur.Tests/Services/EpInformationTests.cs
  12. 82
      EPAServeur.Tests/Services/FormationServiceTests.cs
  13. 36
      EPAServeur.Tests/Services/NoteServiceTests.cs
  14. 36
      EPAServeur.Tests/Services/ParticipationFormationServiceTests.cs
  15. 4
      EPAServeur.Tests/Services/ReferentEPTests.cs

@ -25,6 +25,7 @@ namespace EPAServeur.Tests.Controllers
IDemandeDelegationService demandeDelegationService; IDemandeDelegationService demandeDelegationService;
private ICollaborateurApi collaborateurApi; private ICollaborateurApi collaborateurApi;
private ICollaborateurService collaborateurService; private ICollaborateurService collaborateurService;
private ITransformDTO transformDTO;
#endregion #endregion
#region Setup #region Setup
@ -55,8 +56,9 @@ namespace EPAServeur.Tests.Controllers
} }
collaborateurApi = new CollaborateurApi(); collaborateurApi = new CollaborateurApi();
collaborateurService = new CollaborateurService(collaborateurApi, context); transformDTO = new TransformDTO();
demandeDelegationService = new DemandeDelegationService(collaborateurService, context); collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
demandeDelegationService = new DemandeDelegationService(collaborateurService, context, transformDTO);
} }
#endregion #endregion

@ -64,6 +64,7 @@ namespace EPAServeur.Tests.Controllers
entity.State = EntityState.Detached; entity.State = EntityState.Detached;
} }
services.AddScoped<ITransformDTO, TransformDTO>();
services.AddScoped<ICollaborateurApi, CollaborateurApi>(); services.AddScoped<ICollaborateurApi, CollaborateurApi>();
services.AddScoped<ICollaborateurService, CollaborateurService>(); services.AddScoped<ICollaborateurService, CollaborateurService>();
services.AddScoped<IEngagementService, EngagementService>(); services.AddScoped<IEngagementService, EngagementService>();

@ -23,6 +23,7 @@ namespace EPAServeur.Tests.Controllers
private ICollaborateurService collaborateurService; private ICollaborateurService collaborateurService;
private IEpInformationService epInformationService; private IEpInformationService epInformationService;
private ILogger<EpApiController> logger; private ILogger<EpApiController> logger;
private ITransformDTO transformDTO;
#endregion #endregion
@ -50,8 +51,9 @@ namespace EPAServeur.Tests.Controllers
{ {
entity.State = EntityState.Detached; entity.State = EntityState.Detached;
} }
collaborateurService = new CollaborateurService(new CollaborateurApi(), context); transformDTO = new TransformDTO();
epInformationService = new EpInformationService(context, collaborateurService); collaborateurService = new CollaborateurService(new CollaborateurApi(), context, transformDTO);
epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
} }
#endregion #endregion

@ -63,6 +63,7 @@ namespace EPAServeur.Tests.Controllers
entity.State = EntityState.Detached; entity.State = EntityState.Detached;
} }
services.AddScoped<ITransformDTO, TransformDTO>();
services.AddScoped<ICollaborateurApi, CollaborateurApi>(); services.AddScoped<ICollaborateurApi, CollaborateurApi>();
services.AddScoped<ICollaborateurService, CollaborateurService>(); services.AddScoped<ICollaborateurService, CollaborateurService>();
services.AddScoped<IFormationService, FormationService>(); services.AddScoped<IFormationService, FormationService>();

@ -23,6 +23,7 @@ namespace EPAServeur.Tests.Controllers
private EpContext context; private EpContext context;
private ICollaborateurApi collaborateurApi; private ICollaborateurApi collaborateurApi;
private ICollaborateurService collaborateurService; private ICollaborateurService collaborateurService;
private ITransformDTO transformDTO;
private INoteService noteService; private INoteService noteService;
private ILogger<NotesApiController> logger; private ILogger<NotesApiController> logger;
private Guid? auteur1, collaborateur1; private Guid? auteur1, collaborateur1;
@ -53,8 +54,10 @@ namespace EPAServeur.Tests.Controllers
entity.State = EntityState.Detached; entity.State = EntityState.Detached;
} }
collaborateurApi = new CollaborateurApi(); collaborateurApi = new CollaborateurApi();
collaborateurService = new CollaborateurService(collaborateurApi, context);
noteService = new NoteService(collaborateurApi, collaborateurService, context); transformDTO = new TransformDTO();
collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
noteService = new NoteService(collaborateurApi, collaborateurService, context, transformDTO);
logger = new NullLogger<NotesApiController>(); logger = new NullLogger<NotesApiController>();
auteur1 = new Guid("aa36f34c-9041-42f5-9db3-6536fe7f1696"); auteur1 = new Guid("aa36f34c-9041-42f5-9db3-6536fe7f1696");

@ -65,6 +65,7 @@ namespace EPAServeur.Tests.Controllers
entity.State = EntityState.Detached; entity.State = EntityState.Detached;
} }
services.AddScoped<ITransformDTO, TransformDTO>();
services.AddScoped<ICollaborateurApi, CollaborateurApi>(); services.AddScoped<ICollaborateurApi, CollaborateurApi>();
services.AddScoped<ICollaborateurService, CollaborateurService>(); services.AddScoped<ICollaborateurService, CollaborateurService>();
services.AddScoped<IParticipationFormationService, ParticipationFormationService>(); services.AddScoped<IParticipationFormationService, ParticipationFormationService>();

@ -21,6 +21,7 @@ namespace EPAServeur.Tests.Controllers
#region Variables #region Variables
private EpContext context; private EpContext context;
private ICollaborateurApi collaborateurApi; private ICollaborateurApi collaborateurApi;
private ITransformDTO transformDTO;
private IReferentEPService referentEPService; private IReferentEPService referentEPService;
private Guid? referent, collaborateur1, collaborateur2, collaborateur3; private Guid? referent, collaborateur1, collaborateur2, collaborateur3;
#endregion #endregion

@ -20,6 +20,8 @@ namespace EPAServeur.Tests.Services
#region #region
private EpContext context; private EpContext context;
private ICollaborateurApi collaborateurApi; private ICollaborateurApi collaborateurApi;
private ITransformDTO transformDTO;
#endregion #endregion
#region Setup #region Setup
@ -46,6 +48,7 @@ namespace EPAServeur.Tests.Services
{ {
entity.State = EntityState.Detached; entity.State = EntityState.Detached;
} }
transformDTO = new TransformDTO();
collaborateurApi = new CollaborateurApi(); collaborateurApi = new CollaborateurApi();
} }
#endregion #endregion
@ -57,7 +60,8 @@ namespace EPAServeur.Tests.Services
[TestCase("4f3fcd23-a1e4-4c9e-afa2-d06ca9216491")] [TestCase("4f3fcd23-a1e4-4c9e-afa2-d06ca9216491")]
public async Task GetCollaborateurById_Ok(Guid? id) public async Task GetCollaborateurById_Ok(Guid? id)
{ {
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
CollaborateurDTO collaborateurDTO = await collaborateurService.GetCollaborateurByIdAsync(id); CollaborateurDTO collaborateurDTO = await collaborateurService.GetCollaborateurByIdAsync(id);
Assert.IsNotNull(collaborateurDTO); Assert.IsNotNull(collaborateurDTO);
@ -69,7 +73,8 @@ namespace EPAServeur.Tests.Services
[TestCase("coty.lemoine@apside-groupe.com")] [TestCase("coty.lemoine@apside-groupe.com")]
public async Task GetCollaborateurByMail_Ok(string mail) public async Task GetCollaborateurByMail_Ok(string mail)
{ {
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
CollaborateurDTO collaborateurDTO = await collaborateurService.GetCollaborateurByMailAsync(mail); CollaborateurDTO collaborateurDTO = await collaborateurService.GetCollaborateurByMailAsync(mail);
Assert.IsNotNull(collaborateurDTO); Assert.IsNotNull(collaborateurDTO);
@ -79,10 +84,10 @@ namespace EPAServeur.Tests.Services
[TestCase("006226f6-51b2-4a02-a302-7447f7fccc04")] [TestCase("006226f6-51b2-4a02-a302-7447f7fccc04")]
[TestCase("e5d36da4-df16-4d19-8a11-1ba2f6efc80c")] [TestCase("e5d36da4-df16-4d19-8a11-1ba2f6efc80c")]
[TestCase("92b29b9c-40a4-4aa0-9412-bc97a379e52f")] [TestCase("92b29b9c-40a4-4aa0-9412-bc97a379e52f")]
public async Task GetCollaborateurById_CollaborateurNotFound(Guid? id) public void GetCollaborateurById_CollaborateurNotFound(Guid? id)
{ {
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
AsyncTestDelegate exception = () => collaborateurService.GetCollaborateurByIdAsync(id); AsyncTestDelegate exception = () => collaborateurService.GetCollaborateurByIdAsync(id);
Assert.ThrowsAsync(typeof(CollaborateurNotFoundException), exception); Assert.ThrowsAsync(typeof(CollaborateurNotFoundException), exception);
} }
@ -90,9 +95,10 @@ namespace EPAServeur.Tests.Services
[TestCase("nicolas@apside.fr")] [TestCase("nicolas@apside.fr")]
[TestCase("rousseau@apside.fr")] [TestCase("rousseau@apside.fr")]
[TestCase("lemoine@apside.fr")] [TestCase("lemoine@apside.fr")]
public async Task GetCollaborateurByMail_CollaborateurNotFound(string mail) public void GetCollaborateurByMail_CollaborateurNotFound(string mail)
{ {
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
AsyncTestDelegate exception = () => collaborateurService.GetCollaborateurByMailAsync(mail); AsyncTestDelegate exception = () => collaborateurService.GetCollaborateurByMailAsync(mail);
Assert.ThrowsAsync(typeof(CollaborateurNotFoundException), exception); Assert.ThrowsAsync(typeof(CollaborateurNotFoundException), exception);
} }
@ -108,7 +114,7 @@ namespace EPAServeur.Tests.Services
[TestCase("RA")] [TestCase("RA")]
public async Task GetCollaborateurs_UnRole(string role) public async Task GetCollaborateurs_UnRole(string role)
{ {
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
List<string> roles = new List<string>(); List<string> roles = new List<string>();
roles.Add(role); roles.Add(role);
@ -142,7 +148,7 @@ namespace EPAServeur.Tests.Services
[Test] [Test]
public async Task GetCollaborateurs_RoleRH_RoleAssistant() public async Task GetCollaborateurs_RoleRH_RoleAssistant()
{ {
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
List<string> roles = new List<string>(); List<string> roles = new List<string>();
roles.Add("Assistant"); roles.Add("Assistant");
@ -156,7 +162,7 @@ namespace EPAServeur.Tests.Services
[Test] [Test]
public async Task GetCollaborateurs_RoleRA_RoleManager() public async Task GetCollaborateurs_RoleRA_RoleManager()
{ {
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
List<string> roles = new List<string>(); List<string> roles = new List<string>();
roles.Add("Manager"); roles.Add("Manager");
@ -175,7 +181,8 @@ namespace EPAServeur.Tests.Services
[Test] [Test]
public async Task GetCollaborateurs_Asc_Desc() public async Task GetCollaborateurs_Asc_Desc()
{ {
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
IEnumerable<CollaborateurDTO> collaborateursAsc = await collaborateurService.GetCollaborateursAsync(null, null, true, 1, 50, "", "", null, null); IEnumerable<CollaborateurDTO> collaborateursAsc = await collaborateurService.GetCollaborateursAsync(null, null, true, 1, 50, "", "", null, null);
IEnumerable<CollaborateurDTO> collaborateursDesc = await collaborateurService.GetCollaborateursAsync(null, null, false, 1, 50, "", "", null, null); IEnumerable<CollaborateurDTO> collaborateursDesc = await collaborateurService.GetCollaborateursAsync(null, null, false, 1, 50, "", "", null, null);
CollaborateurDTO collaborateurDTOFirstAsc = collaborateursAsc.First(); CollaborateurDTO collaborateurDTOFirstAsc = collaborateursAsc.First();
@ -193,7 +200,8 @@ namespace EPAServeur.Tests.Services
[TestCase("")] [TestCase("")]
public async Task GetCollaborateurs_Texte(string texte) public async Task GetCollaborateurs_Texte(string texte)
{ {
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursAsync(null, null, true, 1, 50, texte, "", null, null); IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursAsync(null, null, true, 1, 50, texte, "", null, null);
string nomprenom, prenomnom; string nomprenom, prenomnom;
foreach(CollaborateurDTO collaborateur in collaborateurs) foreach(CollaborateurDTO collaborateur in collaborateurs)
@ -210,7 +218,8 @@ namespace EPAServeur.Tests.Services
[TestCase(2018,1,1)] [TestCase(2018,1,1)]
public async Task GetCollaborateurs_DateDebut(int annee, int mois, int jour) public async Task GetCollaborateurs_DateDebut(int annee, int mois, int jour)
{ {
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
DateTime dateDebut = new DateTime(annee, mois, jour); DateTime dateDebut = new DateTime(annee, mois, jour);
IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursAsync(null, null, true, 1, 50, "", "", dateDebut, null); IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursAsync(null, null, true, 1, 50, "", "", dateDebut, null);
foreach(CollaborateurDTO collaborateur in collaborateurs) foreach(CollaborateurDTO collaborateur in collaborateurs)
@ -225,7 +234,8 @@ namespace EPAServeur.Tests.Services
[TestCase(2017, 12, 31)] [TestCase(2017, 12, 31)]
public async Task GetCollaborateurs_DateFin(int annee, int mois, int jour) public async Task GetCollaborateurs_DateFin(int annee, int mois, int jour)
{ {
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
DateTime dateFin = new DateTime(annee, mois, jour); DateTime dateFin = new DateTime(annee, mois, jour);
IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursAsync(null, null, true, 1, 50, "", "", null, dateFin); IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursAsync(null, null, true, 1, 50, "", "", null, dateFin);
foreach (CollaborateurDTO collaborateur in collaborateurs) foreach (CollaborateurDTO collaborateur in collaborateurs)
@ -240,8 +250,9 @@ namespace EPAServeur.Tests.Services
[TestCase(2019,1,1,2019,12,31)] [TestCase(2019,1,1,2019,12,31)]
public async Task GetCollaborateurs_DateDebutDateFin(int anneeDeb, int moisDeb, int jourDeb, int anneeFin, int moisFin, int jourFin) public async Task GetCollaborateurs_DateDebutDateFin(int anneeDeb, int moisDeb, int jourDeb, int anneeFin, int moisFin, int jourFin)
{ {
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
DateTime dateDebut= new DateTime(anneeDeb, moisDeb, jourDeb);
DateTime dateDebut = new DateTime(anneeDeb, moisDeb, jourDeb);
DateTime dateFin = new DateTime(anneeFin, moisFin, jourFin); DateTime dateFin = new DateTime(anneeFin, moisFin, jourFin);
IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursAsync(null, null, true, 1, 50, "", "", dateDebut, dateFin); IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursAsync(null, null, true, 1, 50, "", "", dateDebut, dateFin);
foreach (CollaborateurDTO collaborateur in collaborateurs) foreach (CollaborateurDTO collaborateur in collaborateurs)
@ -259,7 +270,8 @@ namespace EPAServeur.Tests.Services
[TestCase(1,37)] [TestCase(1,37)]
public async Task GetCollaborateur_Paginaion(int numPage, int parPage) public async Task GetCollaborateur_Paginaion(int numPage, int parPage)
{ {
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursAsync(null, null, true, numPage, parPage, "", "", null, null); IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursAsync(null, null, true, numPage, parPage, "", "", null, null);
Assert.AreEqual(collaborateurs.Count(), parPage); Assert.AreEqual(collaborateurs.Count(), parPage);
} }
@ -269,7 +281,8 @@ namespace EPAServeur.Tests.Services
[TestCase(8, 5, 2)] [TestCase(8, 5, 2)]
public async Task GetCollaborateur_Paginaion_2(int numPage, int parPage, int res) public async Task GetCollaborateur_Paginaion_2(int numPage, int parPage, int res)
{ {
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursAsync(null, null, true, numPage, parPage, "", "", null, null); IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursAsync(null, null, true, numPage, parPage, "", "", null, null);
Assert.AreEqual(collaborateurs.Count(), res); Assert.AreEqual(collaborateurs.Count(), res);
} }
@ -281,7 +294,8 @@ namespace EPAServeur.Tests.Services
[TestCase(-1, 37)] [TestCase(-1, 37)]
public async Task GetCollaborateur_PaginaionValeursParDefaut(int numPage, int parPage) public async Task GetCollaborateur_PaginaionValeursParDefaut(int numPage, int parPage)
{ {
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursAsync(null, null, true, numPage, parPage, "", "", null, null); IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursAsync(null, null, true, numPage, parPage, "", "", null, null);
if(parPage < 5) if(parPage < 5)
@ -294,7 +308,8 @@ namespace EPAServeur.Tests.Services
[Test] [Test]
public async Task GetCollaborateur_OrderByDateArrive() public async Task GetCollaborateur_OrderByDateArrive()
{ {
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursAsync(null, null, true, 1, 30, "", "datearrivee", null, null); IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursAsync(null, null, true, 1, 30, "", "datearrivee", null, null);
DateTime d1, d2; DateTime d1, d2;
for(int i = 0; i < collaborateurs.Count() -1; ++i) for(int i = 0; i < collaborateurs.Count() -1; ++i)
@ -310,7 +325,8 @@ namespace EPAServeur.Tests.Services
[Test] [Test]
public async Task GetCollaborateur_OrderByBU() public async Task GetCollaborateur_OrderByBU()
{ {
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursAsync(null, null, true, 1, 30, "", "businessunit", null, null); IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursAsync(null, null, true, 1, 30, "", "businessunit", null, null);
string bu1, bu2; string bu1, bu2;
for (int i = 0; i < collaborateurs.Count() - 1; ++i) for (int i = 0; i < collaborateurs.Count() - 1; ++i)
@ -327,7 +343,8 @@ namespace EPAServeur.Tests.Services
[Test] [Test]
public async Task GetCollaborateur_OrderByNom() public async Task GetCollaborateur_OrderByNom()
{ {
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursAsync(null, null, true, 1, 30, "", "collaborateur", null, null); IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursAsync(null, null, true, 1, 30, "", "collaborateur", null, null);
string nom1, nom2; string nom1, nom2;
for (int i = 0; i < collaborateurs.Count() - 1; ++i) for (int i = 0; i < collaborateurs.Count() - 1; ++i)
@ -348,7 +365,8 @@ namespace EPAServeur.Tests.Services
[TestCase("642bc07f-051a-4088-8a73-425b44998673")] [TestCase("642bc07f-051a-4088-8a73-425b44998673")]
public async Task GetCollaborateurByReferentPlusCount(Guid idReferent) public async Task GetCollaborateurByReferentPlusCount(Guid idReferent)
{ {
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursByReferentAsync(idReferent, true, 1, 15, "", ""); IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursByReferentAsync(idReferent, true, 1, 15, "", "");
int count = await collaborateurService.GetCollaborateursCountByReferentAsync(idReferent, ""); int count = await collaborateurService.GetCollaborateursCountByReferentAsync(idReferent, "");
Assert.AreEqual(count, collaborateurs.Count()); Assert.AreEqual(count, collaborateurs.Count());
@ -361,7 +379,8 @@ namespace EPAServeur.Tests.Services
[TestCase("ca1f480a-9918-4cea-819c-62e5c7f2b332")] [TestCase("ca1f480a-9918-4cea-819c-62e5c7f2b332")]
public void GetCollaborateurByReferent_ReferentNotFound(Guid idReferent) public void GetCollaborateurByReferent_ReferentNotFound(Guid idReferent)
{ {
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
AsyncTestDelegate exception = () => collaborateurService.GetCollaborateursByReferentAsync(idReferent, true, 1, 15, "", ""); AsyncTestDelegate exception = () => collaborateurService.GetCollaborateursByReferentAsync(idReferent, true, 1, 15, "", "");
Assert.ThrowsAsync(typeof(ReferentNotFoundException), exception); Assert.ThrowsAsync(typeof(ReferentNotFoundException), exception);
} }
@ -375,7 +394,8 @@ namespace EPAServeur.Tests.Services
[Test] [Test]
public async Task GetCollaborateurByGuids() public async Task GetCollaborateurByGuids()
{ {
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
List<Guid?> guids = new List<Guid?>(); List<Guid?> guids = new List<Guid?>();
guids.Add(new Guid("ebd911ef-a6a8-4047-afdc-9a9066aa1a07")); guids.Add(new Guid("ebd911ef-a6a8-4047-afdc-9a9066aa1a07"));
guids.Add(new Guid("71d33f6d-695a-4dc6-ae1a-b1605fd2073d")); guids.Add(new Guid("71d33f6d-695a-4dc6-ae1a-b1605fd2073d"));
@ -394,7 +414,8 @@ namespace EPAServeur.Tests.Services
[Test] [Test]
public async Task GetCollaborateurByGuidsAvecIdsNonExistantEnPlus() public async Task GetCollaborateurByGuidsAvecIdsNonExistantEnPlus()
{ {
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
List<Guid?> guids = new List<Guid?>(); List<Guid?> guids = new List<Guid?>();
guids.Add(new Guid("b645f582-0a5d-48dc-97a1-4ebb0fb3a29f")); guids.Add(new Guid("b645f582-0a5d-48dc-97a1-4ebb0fb3a29f"));
guids.Add(new Guid()); guids.Add(new Guid());
@ -414,7 +435,8 @@ namespace EPAServeur.Tests.Services
[Test] [Test]
public async Task GetCollaborateurByGuidsAvecIdsNonExistantUniquement() public async Task GetCollaborateurByGuidsAvecIdsNonExistantUniquement()
{ {
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
List<Guid?> guids = new List<Guid?>(); List<Guid?> guids = new List<Guid?>();
guids.Add(new Guid()); guids.Add(new Guid());
guids.Add(new Guid()); guids.Add(new Guid());

@ -23,6 +23,8 @@ namespace EPAServeur.Tests.Services
private EpContext context; private EpContext context;
private ICollaborateurApi collaborateurApi; private ICollaborateurApi collaborateurApi;
private ICollaborateurService collaborateurService; private ICollaborateurService collaborateurService;
private ITransformDTO transformDTO;
#endregion #endregion
#region Setup #region Setup
@ -52,7 +54,8 @@ namespace EPAServeur.Tests.Services
entity.State = EntityState.Detached; entity.State = EntityState.Detached;
} }
collaborateurApi = new CollaborateurApi(); collaborateurApi = new CollaborateurApi();
collaborateurService = new CollaborateurService(collaborateurApi, context); transformDTO = new TransformDTO();
collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
} }
#endregion #endregion
@ -65,7 +68,7 @@ namespace EPAServeur.Tests.Services
[TestCase("17b87130-0e9d-4b78-b0e3-a11e5f70318d", 1)] [TestCase("17b87130-0e9d-4b78-b0e3-a11e5f70318d", 1)]
public async Task RecupererDemandesDelegation_OK(Guid? idReferent, int count) public async Task RecupererDemandesDelegation_OK(Guid? idReferent, int count)
{ {
IDemandeDelegationService demandeDelegationService = new DemandeDelegationService(collaborateurService, context); IDemandeDelegationService demandeDelegationService = new DemandeDelegationService(collaborateurService, context, transformDTO);
IEnumerable<DemandeDelegationDTO> demandesDelegation = await demandeDelegationService.RecupererDemandesDelegation(idReferent); IEnumerable<DemandeDelegationDTO> demandesDelegation = await demandeDelegationService.RecupererDemandesDelegation(idReferent);
foreach (DemandeDelegationDTO demandeDelegation in demandesDelegation) foreach (DemandeDelegationDTO demandeDelegation in demandesDelegation)
{ {
@ -80,7 +83,7 @@ namespace EPAServeur.Tests.Services
public void RecupererDemandeDelegation_ReferentNotFound() public void RecupererDemandeDelegation_ReferentNotFound()
{ {
Guid? idReferent = new Guid(); Guid? idReferent = new Guid();
IDemandeDelegationService demandeDelegationService = new DemandeDelegationService(collaborateurService, context); IDemandeDelegationService demandeDelegationService = new DemandeDelegationService(collaborateurService, context, transformDTO);
AsyncTestDelegate exception = () => demandeDelegationService.RecupererDemandesDelegation(idReferent); AsyncTestDelegate exception = () => demandeDelegationService.RecupererDemandesDelegation(idReferent);
Assert.ThrowsAsync(typeof(ReferentNotFoundException), exception); Assert.ThrowsAsync(typeof(ReferentNotFoundException), exception);
} }
@ -93,7 +96,7 @@ namespace EPAServeur.Tests.Services
[TestCase(5)] [TestCase(5)]
public async Task UpdateDemandeDelegation_ReponsePositive(long id) public async Task UpdateDemandeDelegation_ReponsePositive(long id)
{ {
IDemandeDelegationService demandeDelegationService = new DemandeDelegationService(collaborateurService, context); IDemandeDelegationService demandeDelegationService = new DemandeDelegationService(collaborateurService, context, transformDTO);
DemandeDelegation demandeDelegation = await context.DemandeDelegation.FindAsync(id); DemandeDelegation demandeDelegation = await context.DemandeDelegation.FindAsync(id);
long idEp = demandeDelegation.IdEP; long idEp = demandeDelegation.IdEP;
@ -125,7 +128,7 @@ namespace EPAServeur.Tests.Services
[TestCase(6)] [TestCase(6)]
public async Task UpdateDemandeDelegation_ReponseNegative(long id) public async Task UpdateDemandeDelegation_ReponseNegative(long id)
{ {
IDemandeDelegationService demandeDelegationService = new DemandeDelegationService(collaborateurService, context); IDemandeDelegationService demandeDelegationService = new DemandeDelegationService(collaborateurService, context, transformDTO);
DemandeDelegation demandeDelegation = await context.DemandeDelegation.FindAsync(id); DemandeDelegation demandeDelegation = await context.DemandeDelegation.FindAsync(id);
long idEp = demandeDelegation.IdEP; long idEp = demandeDelegation.IdEP;
@ -156,7 +159,7 @@ namespace EPAServeur.Tests.Services
[TestCase(10, EtatDemande.Rejetee, "exemple refus")] [TestCase(10, EtatDemande.Rejetee, "exemple refus")]
public void UpdateDemandeDelegation_DemandeNonExistante(long id, EtatDemande etatDemande, string raisonRefus) public void UpdateDemandeDelegation_DemandeNonExistante(long id, EtatDemande etatDemande, string raisonRefus)
{ {
IDemandeDelegationService demandeDelegationService = new DemandeDelegationService(collaborateurService, context); IDemandeDelegationService demandeDelegationService = new DemandeDelegationService(collaborateurService, context, transformDTO);
DemandeDelegationDTO demandeDTO = new DemandeDelegationDTO() DemandeDelegationDTO demandeDTO = new DemandeDelegationDTO()
{ {
Id = id, Id = id,
@ -176,7 +179,7 @@ namespace EPAServeur.Tests.Services
[TestCase(4, 1,EtatDemande.Rejetee, "exemple refus")] [TestCase(4, 1,EtatDemande.Rejetee, "exemple refus")]
public void UpdateDemandeDelegation_DemandeIncompatible(long id, long idIncompatible, EtatDemande etatDemande, string raisonRefus) public void UpdateDemandeDelegation_DemandeIncompatible(long id, long idIncompatible, EtatDemande etatDemande, string raisonRefus)
{ {
IDemandeDelegationService demandeDelegationService = new DemandeDelegationService(collaborateurService, context); IDemandeDelegationService demandeDelegationService = new DemandeDelegationService(collaborateurService, context, transformDTO);
DemandeDelegationDTO demandeDTO = new DemandeDelegationDTO() DemandeDelegationDTO demandeDTO = new DemandeDelegationDTO()
{ {
Id = id, Id = id,
@ -199,7 +202,7 @@ namespace EPAServeur.Tests.Services
[TestCase(7, EtatDemande.Rejetee, "")] [TestCase(7, EtatDemande.Rejetee, "")]
public async Task UpdateDemandeDelegation_DemandeInvalid(long id, EtatDemande etatDemande, string raisonRefus) public async Task UpdateDemandeDelegation_DemandeInvalid(long id, EtatDemande etatDemande, string raisonRefus)
{ {
IDemandeDelegationService demandeDelegationService = new DemandeDelegationService(collaborateurService, context); IDemandeDelegationService demandeDelegationService = new DemandeDelegationService(collaborateurService, context, transformDTO);
DemandeDelegation demandeDelegation = await context.DemandeDelegation.FindAsync(id); DemandeDelegation demandeDelegation = await context.DemandeDelegation.FindAsync(id);
long idEp = demandeDelegation.IdEP; long idEp = demandeDelegation.IdEP;

@ -23,6 +23,8 @@ namespace EPAServeur.Tests.Services
private EpContext epContext; private EpContext epContext;
private ICollaborateurApi collaborateurApi; private ICollaborateurApi collaborateurApi;
private ICollaborateurService collaborateurService; private ICollaborateurService collaborateurService;
private ITransformDTO transformDTO;
#endregion #endregion
#region Setup #region Setup
@ -37,7 +39,8 @@ namespace EPAServeur.Tests.Services
epContext = new EpContext(optionBuider); epContext = new EpContext(optionBuider);
collaborateurApi = new CollaborateurApi(); collaborateurApi = new CollaborateurApi();
collaborateurService = new CollaborateurService(collaborateurApi, epContext); transformDTO = new TransformDTO();
collaborateurService = new CollaborateurService(collaborateurApi, epContext, transformDTO);
epContext.Database.EnsureDeleted(); epContext.Database.EnsureDeleted();
epContext.Database.EnsureCreated(); epContext.Database.EnsureCreated();
epContext.SaveChanges(); epContext.SaveChanges();
@ -61,7 +64,7 @@ namespace EPAServeur.Tests.Services
public async Task GetEngagementsAsync_PasseDesParamsDesIdBUValides_RetourneDesEngagements(long[] arrIdBUs) public async Task GetEngagementsAsync_PasseDesParamsDesIdBUValides_RetourneDesEngagements(long[] arrIdBUs)
{ {
// Arrange // Arrange
EngagementService engagementService = new EngagementService(epContext, collaborateurService); EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO);
List<long> idBUs = arrIdBUs.Select(x => x).ToList(); List<long> idBUs = arrIdBUs.Select(x => x).ToList();
// Act // Act
@ -76,7 +79,7 @@ namespace EPAServeur.Tests.Services
public async Task GetEngagementsAsync_PasseDesParamsDesEtatsDEngagementsValides_RetourneDesEngagements(EtatEngagement[] arrEtatsEngagement) public async Task GetEngagementsAsync_PasseDesParamsDesEtatsDEngagementsValides_RetourneDesEngagements(EtatEngagement[] arrEtatsEngagement)
{ {
// Arrange // Arrange
EngagementService engagementService = new EngagementService(epContext, collaborateurService); EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO);
List<long> idBUs = new List<long>() { 1, 2, 3 }; List<long> idBUs = new List<long>() { 1, 2, 3 };
List<EtatEngagement> etatEngagements = arrEtatsEngagement.Select(x => x).ToList(); List<EtatEngagement> etatEngagements = arrEtatsEngagement.Select(x => x).ToList();
@ -92,7 +95,7 @@ namespace EPAServeur.Tests.Services
public async Task GetEngagementsAsync_PasseEnParamNumPageEtParPage_RetourneLaPremierePageDesEngagements(int? numPage, int? parPage) public async Task GetEngagementsAsync_PasseEnParamNumPageEtParPage_RetourneLaPremierePageDesEngagements(int? numPage, int? parPage)
{ {
// Arrange // Arrange
EngagementService engagementService = new EngagementService(epContext, collaborateurService); EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO);
List<long> idBUs = new List<long>() { 1, 2, 3 }; List<long> idBUs = new List<long>() { 1, 2, 3 };
// Act // Act
@ -109,7 +112,7 @@ namespace EPAServeur.Tests.Services
public async Task GetEngagementsAsync_PasseEnParamNumPageEtParPage_RetourneLaDeuxiemePageDesFormations(int? numPage, int? parPage) public async Task GetEngagementsAsync_PasseEnParamNumPageEtParPage_RetourneLaDeuxiemePageDesFormations(int? numPage, int? parPage)
{ {
// Arrange // Arrange
EngagementService engagementService = new EngagementService(epContext, collaborateurService); EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO);
List<long> idBUs = new List<long>() { 1, 2, 3 }; List<long> idBUs = new List<long>() { 1, 2, 3 };
int? nbEngagementDeuxiemePage; int? nbEngagementDeuxiemePage;
@ -142,7 +145,7 @@ namespace EPAServeur.Tests.Services
public async Task GetEngagementsAsync_PasseEnParamAscEtTri_RetourneDesEngagementsOrdonnancesParActionCroissant(bool? asc, string tri) public async Task GetEngagementsAsync_PasseEnParamAscEtTri_RetourneDesEngagementsOrdonnancesParActionCroissant(bool? asc, string tri)
{ {
// Arrange // Arrange
EngagementService engagementService = new EngagementService(epContext, collaborateurService); EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO);
List<long> idBUs = new List<long>() { 1, 2, 3 }; List<long> idBUs = new List<long>() { 1, 2, 3 };
// Act // Act
@ -159,7 +162,7 @@ namespace EPAServeur.Tests.Services
public async Task GetEngagementsAsync_PasseEnParamAscEtTri_RetourneDesEngagementsOrdonnancesParActionDecroissant(bool? asc, string tri) public async Task GetEngagementsAsync_PasseEnParamAscEtTri_RetourneDesEngagementsOrdonnancesParActionDecroissant(bool? asc, string tri)
{ {
// Arrange // Arrange
EngagementService engagementService = new EngagementService(epContext, collaborateurService); EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO);
List<long> idBUs = new List<long>() { 1, 2, 3 }; List<long> idBUs = new List<long>() { 1, 2, 3 };
// Act // Act
@ -174,7 +177,7 @@ namespace EPAServeur.Tests.Services
public async Task GetEngagementsAsync_PasseEnParamAscEtTri_RetourneDesEngagementsOrdonnancesParDispositifCroissant() public async Task GetEngagementsAsync_PasseEnParamAscEtTri_RetourneDesEngagementsOrdonnancesParDispositifCroissant()
{ {
// Arrange // Arrange
EngagementService engagementService = new EngagementService(epContext, collaborateurService); EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO);
List<long> idBUs = new List<long>() { 1, 2, 3 }; List<long> idBUs = new List<long>() { 1, 2, 3 };
bool? asc = true; bool? asc = true;
string tri = "dispositif"; string tri = "dispositif";
@ -191,7 +194,7 @@ namespace EPAServeur.Tests.Services
public async Task GetEngagementsAsync_PasseEnParamAscEtTri_RetourneDesEngagementsOrdonnancesParDispositifDecroissant() public async Task GetEngagementsAsync_PasseEnParamAscEtTri_RetourneDesEngagementsOrdonnancesParDispositifDecroissant()
{ {
// Arrange // Arrange
EngagementService engagementService = new EngagementService(epContext, collaborateurService); EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO);
List<long> idBUs = new List<long>() { 1, 2, 3 }; List<long> idBUs = new List<long>() { 1, 2, 3 };
bool? asc = false; bool? asc = false;
string tri = "dispositif"; string tri = "dispositif";
@ -208,7 +211,7 @@ namespace EPAServeur.Tests.Services
public async Task GetEngagementsAsync_PasseEnParamAscEtTri_RetourneDesEngagementsOrdonnancesParModaliteCroissante() public async Task GetEngagementsAsync_PasseEnParamAscEtTri_RetourneDesEngagementsOrdonnancesParModaliteCroissante()
{ {
// Arrange // Arrange
EngagementService engagementService = new EngagementService(epContext, collaborateurService); EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO);
List<long> idBUs = new List<long>() { 1, 2, 3 }; List<long> idBUs = new List<long>() { 1, 2, 3 };
bool? asc = true; bool? asc = true;
string tri = "modalite"; string tri = "modalite";
@ -225,7 +228,7 @@ namespace EPAServeur.Tests.Services
public async Task GetEngagementsAsync_PasseEnParamAscEtTri_RetourneDesEngagementsOrdonnancesParModaliteDecroissante() public async Task GetEngagementsAsync_PasseEnParamAscEtTri_RetourneDesEngagementsOrdonnancesParModaliteDecroissante()
{ {
// Arrange // Arrange
EngagementService engagementService = new EngagementService(epContext, collaborateurService); EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO);
List<long> idBUs = new List<long>() { 1, 2, 3 }; List<long> idBUs = new List<long>() { 1, 2, 3 };
bool? asc = false; bool? asc = false;
string tri = "modalite"; string tri = "modalite";
@ -242,7 +245,7 @@ namespace EPAServeur.Tests.Services
public async Task GetEngagementsAsync_PasseEnParamAscEtTri_RetourneDesEngagementsOrdonnancesParDateCroissante() public async Task GetEngagementsAsync_PasseEnParamAscEtTri_RetourneDesEngagementsOrdonnancesParDateCroissante()
{ {
// Arrange // Arrange
EngagementService engagementService = new EngagementService(epContext, collaborateurService); EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO);
List<long> idBUs = new List<long>() { 1, 2, 3 }; List<long> idBUs = new List<long>() { 1, 2, 3 };
bool? asc = true; bool? asc = true;
string tri = "date"; string tri = "date";
@ -259,7 +262,7 @@ namespace EPAServeur.Tests.Services
public async Task GetEngagementsAsync_PasseEnParamAscEtTri_RetourneDesEngagementsOrdonnancesParDateDecroissante() public async Task GetEngagementsAsync_PasseEnParamAscEtTri_RetourneDesEngagementsOrdonnancesParDateDecroissante()
{ {
// Arrange // Arrange
EngagementService engagementService = new EngagementService(epContext, collaborateurService); EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO);
List<long> idBUs = new List<long>() { 1, 2, 3 }; List<long> idBUs = new List<long>() { 1, 2, 3 };
bool? asc = false; bool? asc = false;
string tri = "date"; string tri = "date";
@ -279,7 +282,7 @@ namespace EPAServeur.Tests.Services
public async Task GetEngagementsAsync_PasseDesParamsInvalides_RetourneZeroEngagement(long[] arrIdBUs, string texte) public async Task GetEngagementsAsync_PasseDesParamsInvalides_RetourneZeroEngagement(long[] arrIdBUs, string texte)
{ {
// Arrange // Arrange
EngagementService engagementService = new EngagementService(epContext, collaborateurService); EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO);
List<long> idBUs; List<long> idBUs;
if (arrIdBUs != null) if (arrIdBUs != null)
@ -298,7 +301,7 @@ namespace EPAServeur.Tests.Services
public void GetEngagementsAsync_PasseDesParamsUneListeDIdsBUVide_LeveUneEngagementInvalidException() public void GetEngagementsAsync_PasseDesParamsUneListeDIdsBUVide_LeveUneEngagementInvalidException()
{ {
// Arrange // Arrange
EngagementService engagementService = new EngagementService(epContext, collaborateurService); EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO);
List<long> idBUs = new List<long>(); List<long> idBUs = new List<long>();
// Act // Act
@ -312,7 +315,7 @@ namespace EPAServeur.Tests.Services
public void GetEngagementsAsync_PasseDesParamsUneListeDIdsBUNull_LeveUneEngagementInvalidException() public void GetEngagementsAsync_PasseDesParamsUneListeDIdsBUNull_LeveUneEngagementInvalidException()
{ {
// Arrange // Arrange
EngagementService engagementService = new EngagementService(epContext, collaborateurService); EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO);
List<long> idBUs = null; List<long> idBUs = null;
// Act // Act
@ -332,7 +335,7 @@ namespace EPAServeur.Tests.Services
public async Task GetEngagementsCountAsync_PasseDesParamsValides_RetourneLeNombreTotalDEngagements(long[] arrIdBUs, string texte) public async Task GetEngagementsCountAsync_PasseDesParamsValides_RetourneLeNombreTotalDEngagements(long[] arrIdBUs, string texte)
{ {
// Arrange // Arrange
EngagementService engagementService = new EngagementService(epContext, collaborateurService); EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO);
List<long> idBUs; List<long> idBUs;
if (arrIdBUs != null) if (arrIdBUs != null)
@ -353,7 +356,7 @@ namespace EPAServeur.Tests.Services
public async Task GetEngagementsCountAsync_PasseDesParamsInvalides_RetourneZero(long[] arrIdBUs, string texte) public async Task GetEngagementsCountAsync_PasseDesParamsInvalides_RetourneZero(long[] arrIdBUs, string texte)
{ {
// Arrange // Arrange
EngagementService engagementService = new EngagementService(epContext, collaborateurService); EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO);
List<long> idBUs; List<long> idBUs;
if (arrIdBUs != null) if (arrIdBUs != null)
@ -378,7 +381,7 @@ namespace EPAServeur.Tests.Services
public async Task RepondreEngagementAsync_ModifieUnEngagementValide_EngagementModifieAvecSucces(long idEngagement, long idEp, EtatEngagement etatEngagement, string raisonNonRealisable) public async Task RepondreEngagementAsync_ModifieUnEngagementValide_EngagementModifieAvecSucces(long idEngagement, long idEp, EtatEngagement etatEngagement, string raisonNonRealisable)
{ {
// Arrange // Arrange
EngagementService engagementService = new EngagementService(epContext, collaborateurService); EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO);
EpInformationDTO epInformationDTO = epContext.Ep.Where(ep => ep.IdEP == idEp) EpInformationDTO epInformationDTO = epContext.Ep.Where(ep => ep.IdEP == idEp)
.Select(ep => new EpInformationDTO .Select(ep => new EpInformationDTO
@ -423,7 +426,7 @@ namespace EPAServeur.Tests.Services
string raisonNonRealisableAvantUpdate = null; string raisonNonRealisableAvantUpdate = null;
string raisonNonRealisableApresUpdate = "La date limite pour respecter l'engagement est passée."; string raisonNonRealisableApresUpdate = "La date limite pour respecter l'engagement est passée.";
// Arrange // Arrange
EngagementService engagementService = new EngagementService(epContext, collaborateurService); EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO);
EpInformationDTO epInformationDTO = epContext.Ep.Where(ep => ep.IdEP == idEp) EpInformationDTO epInformationDTO = epContext.Ep.Where(ep => ep.IdEP == idEp)
.Select(ep => new EpInformationDTO .Select(ep => new EpInformationDTO
@ -469,7 +472,7 @@ namespace EPAServeur.Tests.Services
public void RepondreEngagementAsync_ModifieUnEngagementAvecDesProprietesInvalide_LeveUneEngagementInvalidException(long idEngagement, long idEp, string action, string dispositif, string modalite, DateTime? dateLimite, EtatEngagement etatEngagement, string raisonNonRealisable) public void RepondreEngagementAsync_ModifieUnEngagementAvecDesProprietesInvalide_LeveUneEngagementInvalidException(long idEngagement, long idEp, string action, string dispositif, string modalite, DateTime? dateLimite, EtatEngagement etatEngagement, string raisonNonRealisable)
{ {
// Arrange // Arrange
EngagementService engagementService = new EngagementService(epContext, collaborateurService); EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO);
EpInformationDTO epInformationDTO = epContext.Ep.Where(ep => ep.IdEP == idEp) EpInformationDTO epInformationDTO = epContext.Ep.Where(ep => ep.IdEP == idEp)
.Select(ep => new EpInformationDTO .Select(ep => new EpInformationDTO
@ -505,7 +508,7 @@ namespace EPAServeur.Tests.Services
public void RepondreEngagementAsync_ModifieUnEngagementNull_LeveUneEngagementInvalidException() public void RepondreEngagementAsync_ModifieUnEngagementNull_LeveUneEngagementInvalidException()
{ {
// Arrange // Arrange
EngagementService engagementService = new EngagementService(epContext, collaborateurService); EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO);
EngagementDTO engagementDTO = null; EngagementDTO engagementDTO = null;
long idEngagement = 1; long idEngagement = 1;
@ -520,7 +523,7 @@ namespace EPAServeur.Tests.Services
public void RepondreEngagementAsync_ModifieUnEngagementAvecUnEPInexistantDansLaBDD_LeveUneEngagementInvalidException() public void RepondreEngagementAsync_ModifieUnEngagementAvecUnEPInexistantDansLaBDD_LeveUneEngagementInvalidException()
{ {
// Arrange // Arrange
EngagementService engagementService = new EngagementService(epContext, collaborateurService); EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO);
long idEngagement = 1; long idEngagement = 1;
EpInformationDTO epInformationDTO = new EpInformationDTO EpInformationDTO epInformationDTO = new EpInformationDTO
{ {
@ -561,7 +564,7 @@ namespace EPAServeur.Tests.Services
long idEngagementIncorrecte = 2; long idEngagementIncorrecte = 2;
long idEp = 9; long idEp = 9;
EngagementService engagementService = new EngagementService(epContext, collaborateurService); EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO);
EpInformationDTO epInformationDTO = epContext.Ep.Where(ep => ep.IdEP == idEp) EpInformationDTO epInformationDTO = epContext.Ep.Where(ep => ep.IdEP == idEp)
.Select(ep => new EpInformationDTO .Select(ep => new EpInformationDTO
@ -600,7 +603,7 @@ namespace EPAServeur.Tests.Services
long idEngagement = 0; long idEngagement = 0;
long idEp = 9; long idEp = 9;
EngagementService engagementService = new EngagementService(epContext, collaborateurService); EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO);
EpInformationDTO epInformationDTO = epContext.Ep.Where(ep => ep.IdEP == idEp) EpInformationDTO epInformationDTO = epContext.Ep.Where(ep => ep.IdEP == idEp)
.Select(ep => new EpInformationDTO .Select(ep => new EpInformationDTO

@ -20,6 +20,8 @@ namespace EPAServeur.Tests.Services
#region #region
private EpContext context; private EpContext context;
private ICollaborateurService collaborateurService; private ICollaborateurService collaborateurService;
private ITransformDTO transformDTO;
#endregion #endregion
@ -47,7 +49,8 @@ namespace EPAServeur.Tests.Services
{ {
entity.State = EntityState.Detached; entity.State = EntityState.Detached;
} }
collaborateurService = new CollaborateurService(new CollaborateurApi(), context); transformDTO = new TransformDTO();
collaborateurService = new CollaborateurService(new CollaborateurApi(), context, transformDTO);
} }
#endregion #endregion
@ -58,7 +61,7 @@ namespace EPAServeur.Tests.Services
[TestCase(3, 3)] // Paris [TestCase(3, 3)] // Paris
public async Task GetEpEnCours_UneBU(long? idBUs, int nbElements) public async Task GetEpEnCours_UneBU(long? idBUs, int nbElements)
{ {
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService); IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?>{ idBUs }, true, 1, 15, "", "", null, null); IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?>{ idBUs }, true, 1, 15, "", "", null, null);
int count = await epInformationService.GetEPEnCoursCount(new List<long?> { idBUs }, true, 1, 15, "", "", null, null); int count = await epInformationService.GetEPEnCoursCount(new List<long?> { idBUs }, true, 1, 15, "", "", null, null);
@ -74,7 +77,7 @@ namespace EPAServeur.Tests.Services
[Test] [Test]
public async Task GetEpEnCours_OrleansTours() public async Task GetEpEnCours_OrleansTours()
{ {
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService); IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1,2 }, true, 1, 15, "", "", null, null); 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 }, true, 1, 15, "", "", null, null); int count = await epInformationService.GetEPEnCoursCount(new List<long?> { 1, 2 }, true, 1, 15, "", "", null, null);
@ -100,7 +103,7 @@ namespace EPAServeur.Tests.Services
[TestCase("datedisponibilite")] [TestCase("datedisponibilite")]
public async Task GetEpEnCours_TriColonneASC(string tri) public async Task GetEpEnCours_TriColonneASC(string tri)
{ {
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService); IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, true, 1, 15, "", tri, null, null); IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, true, 1, 15, "", tri, null, null);
EpInformationDTO ep1, ep2; EpInformationDTO ep1, ep2;
int compare = 0; int compare = 0;
@ -153,7 +156,7 @@ namespace EPAServeur.Tests.Services
[TestCase("datedisponibilite")] [TestCase("datedisponibilite")]
public async Task GetEpEnCours_TriColonneDESC(string tri) public async Task GetEpEnCours_TriColonneDESC(string tri)
{ {
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService); IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, false, 1, 15, "", tri, null, null); IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, false, 1, 15, "", tri, null, null);
EpInformationDTO ep1, ep2; EpInformationDTO ep1, ep2;
int compare = 0; int compare = 0;
@ -201,7 +204,7 @@ namespace EPAServeur.Tests.Services
public async Task GetEpEnCours_TriDateD1(int j, int m, int a, int count) public async Task GetEpEnCours_TriDateD1(int j, int m, int a, int count)
{ {
DateTime date = new DateTime(a, m, j); DateTime date = new DateTime(a, m, j);
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService); IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, true, 1, 15, "", "", date, null); IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, true, 1, 15, "", "", date, null);
Assert.AreEqual(epInformationDTOs.Count(), count); Assert.AreEqual(epInformationDTOs.Count(), count);
@ -217,7 +220,7 @@ namespace EPAServeur.Tests.Services
[TestCase(1, 02, 2021, 0)] [TestCase(1, 02, 2021, 0)]
public async Task GetEpEnCours_TriDateD2(int j, int m, int a, int count) 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); 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); IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, true, 1, 15, "", "", null, date);
Assert.AreEqual(epInformationDTOs.Count(), count); Assert.AreEqual(epInformationDTOs.Count(), count);
@ -237,7 +240,7 @@ namespace EPAServeur.Tests.Services
{ {
DateTime date1 = new DateTime(a1, m1, j1); DateTime date1 = new DateTime(a1, m1, j1);
DateTime date2 = new DateTime(a2, m2, j2); DateTime date2 = new DateTime(a2, m2, j2);
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService); IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, true, 1, 15, "", "", date1, date2); IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, true, 1, 15, "", "", date1, date2);
Assert.AreEqual(epInformationDTOs.Count(), count); Assert.AreEqual(epInformationDTOs.Count(), count);
@ -259,7 +262,7 @@ namespace EPAServeur.Tests.Services
[TestCase("d", 2)] [TestCase("d", 2)]
public async Task GetEpEnCours_texte(string texte, int count) public async Task GetEpEnCours_texte(string texte, int count)
{ {
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService); IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, true, 1, 15, texte, "", null, null); IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, true, 1, 15, texte, "", null, null);
Assert.AreEqual(count, epInformationDTOs.Count()); Assert.AreEqual(count, epInformationDTOs.Count());
foreach (EpInformationDTO ep in epInformationDTOs) foreach (EpInformationDTO ep in epInformationDTOs)
@ -279,7 +282,7 @@ namespace EPAServeur.Tests.Services
[TestCase(3, 3)] // Paris [TestCase(3, 3)] // Paris
public async Task GetEpSignes_UneBU(long? idBUs, int nbElements) public async Task GetEpSignes_UneBU(long? idBUs, int nbElements)
{ {
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService); IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignes(new List<long?>{ idBUs }, true, 1, 15, "", "", null, null); IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignes(new List<long?>{ idBUs }, true, 1, 15, "", "", null, null);
int count = await epInformationService.GetEPSignesCount(new List<long?> { idBUs }, true, 1, 15, "", "", null, null); int count = await epInformationService.GetEPSignesCount(new List<long?> { idBUs }, true, 1, 15, "", "", null, null);
@ -295,7 +298,7 @@ namespace EPAServeur.Tests.Services
public async Task GetEpSignes_OrleansTours() public async Task GetEpSignes_OrleansTours()
{ {
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService); IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignes(new List<long?> { 1,2 }, true, 1, 15, "", "", null, null); 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 }, true, 1, 15, "", "", null, null); int count = await epInformationService.GetEPSignesCount(new List<long?> { 1, 2 }, true, 1, 15, "", "", null, null);
@ -321,7 +324,7 @@ namespace EPAServeur.Tests.Services
[TestCase("datedisponibilite")] [TestCase("datedisponibilite")]
public async Task GetEpSignes_TriColonneASC(string tri) public async Task GetEpSignes_TriColonneASC(string tri)
{ {
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService); IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignes(new List<long?> { 1, 2 }, true, 1, 15, "", tri, null, null); IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignes(new List<long?> { 1, 2 }, true, 1, 15, "", tri, null, null);
EpInformationDTO ep1, ep2; EpInformationDTO ep1, ep2;
int compare = 0; int compare = 0;
@ -375,7 +378,7 @@ namespace EPAServeur.Tests.Services
[TestCase("datedisponibilite")] [TestCase("datedisponibilite")]
public async Task GetEpSignes_TriColonneDESC(string tri) public async Task GetEpSignes_TriColonneDESC(string tri)
{ {
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService); IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignes(new List<long?> { 1, 2 }, false, 1, 15, "", tri, null, null); IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignes(new List<long?> { 1, 2 }, false, 1, 15, "", tri, null, null);
EpInformationDTO ep1, ep2; EpInformationDTO ep1, ep2;
int compare = 0; int compare = 0;
@ -426,7 +429,7 @@ namespace EPAServeur.Tests.Services
public async Task GetEpSignes_TriDateD1(int j, int m, int a, int count) public async Task GetEpSignes_TriDateD1(int j, int m, int a, int count)
{ {
DateTime date = new DateTime(a, m, j); DateTime date = new DateTime(a, m, j);
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService); IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignes(new List<long?> { 1, 2 }, true, 1, 15, "", "", date, null); IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignes(new List<long?> { 1, 2 }, true, 1, 15, "", "", date, null);
Assert.AreEqual(epInformationDTOs.Count(), count); Assert.AreEqual(epInformationDTOs.Count(), count);
@ -443,7 +446,7 @@ namespace EPAServeur.Tests.Services
[TestCase(31, 07, 2017)] [TestCase(31, 07, 2017)]
public async Task GetEpSignes_TriDateD2(int j, int m, int a) public async Task GetEpSignes_TriDateD2(int j, int m, int a)
{ {
DateTime date = new DateTime(a, m, j); IEpInformationService epInformationService = new EpInformationService(context, collaborateurService); 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); 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 }, true, 1, 15, "", "", null, date); int count = await epInformationService.GetEPSignesCount(new List<long?> { 1, 2 }, true, 1, 15, "", "", null, date);
@ -463,7 +466,7 @@ namespace EPAServeur.Tests.Services
{ {
DateTime date1 = new DateTime(a1, m1, j1); DateTime date1 = new DateTime(a1, m1, j1);
DateTime date2 = new DateTime(a2, m2, j2); DateTime date2 = new DateTime(a2, m2, j2);
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService); IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignes(new List<long?> { 1, 2 }, true, 1, 15, "", "", date1, date2); IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignes(new List<long?> { 1, 2 }, true, 1, 15, "", "", date1, date2);
Assert.AreEqual(epInformationDTOs.Count(), count); Assert.AreEqual(epInformationDTOs.Count(), count);
@ -485,7 +488,7 @@ namespace EPAServeur.Tests.Services
[TestCase("d", 2)] [TestCase("d", 2)]
public async Task GetEpSignes_texte(string texte, int count) public async Task GetEpSignes_texte(string texte, int count)
{ {
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService); IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignes(new List<long?> { 1, 2 }, true, 1, 15, texte, "", null, null); IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignes(new List<long?> { 1, 2 }, true, 1, 15, texte, "", null, null);
Assert.AreEqual(count, epInformationDTOs.Count()); Assert.AreEqual(count, epInformationDTOs.Count());
foreach (EpInformationDTO ep in epInformationDTOs) foreach (EpInformationDTO ep in epInformationDTOs)
@ -508,7 +511,7 @@ namespace EPAServeur.Tests.Services
[TestCase("80220063-a5fa-472b-b610-2e350566df98", 1)] [TestCase("80220063-a5fa-472b-b610-2e350566df98", 1)]
public async Task GetEPCoursReferent(Guid idReferent, int count) public async Task GetEPCoursReferent(Guid idReferent, int count)
{ {
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService); IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCoursReferent(idReferent, true, 1, 15, "", "", null, null); IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCoursReferent(idReferent, true, 1, 15, "", "", null, null);
int epCount = await epInformationService.GetEPEnCoursReferentCount(idReferent, true, 1, 15, "", "", null, null); int epCount = await epInformationService.GetEPEnCoursReferentCount(idReferent, true, 1, 15, "", "", null, null);
Assert.AreEqual(epCount, count); Assert.AreEqual(epCount, count);
@ -531,7 +534,7 @@ namespace EPAServeur.Tests.Services
[TestCase("ea027734-ff0f-4308-8879-133a09fb3c46", 1)] [TestCase("ea027734-ff0f-4308-8879-133a09fb3c46", 1)]
public async Task GetEPEnSignesReferent(Guid idReferent, int count) public async Task GetEPEnSignesReferent(Guid idReferent, int count)
{ {
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService); IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignesReferent(idReferent, true, 1, 15, "", "", null, null); IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignesReferent(idReferent, true, 1, 15, "", "", null, null);
int epCount = await epInformationService.GetEPSignesReferentCount(idReferent, true, 1, 15, "", "", null, null); int epCount = await epInformationService.GetEPSignesReferentCount(idReferent, true, 1, 15, "", "", null, null);
Assert.AreEqual(epCount, count); Assert.AreEqual(epCount, count);
@ -553,7 +556,7 @@ namespace EPAServeur.Tests.Services
[TestCase("13fbe621-1bc9-4f04-afde-b54ca076e239", 3)] [TestCase("13fbe621-1bc9-4f04-afde-b54ca076e239", 3)]
public async Task GetEPSignesCollaborateur(Guid idCollaborateur, int count) public async Task GetEPSignesCollaborateur(Guid idCollaborateur, int count)
{ {
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService); IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignesCollaborateur(idCollaborateur); IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignesCollaborateur(idCollaborateur);
Assert.AreEqual(count, epInformationDTOs.Count()); Assert.AreEqual(count, epInformationDTOs.Count());
foreach(EpInformationDTO ep in epInformationDTOs) foreach(EpInformationDTO ep in epInformationDTOs)
@ -574,7 +577,7 @@ namespace EPAServeur.Tests.Services
[TestCase("de98a866-736f-4295-a669-92a8694e2ee3", true)] [TestCase("de98a866-736f-4295-a669-92a8694e2ee3", true)]
public async Task GetEPEnCoursCollaborateur(Guid idCollaborateur, bool existe) public async Task GetEPEnCoursCollaborateur(Guid idCollaborateur, bool existe)
{ {
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService); IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
EpInformationDTO epInformationDTO = await epInformationService.GetProchainEPCollaborateur(idCollaborateur); EpInformationDTO epInformationDTO = await epInformationService.GetProchainEPCollaborateur(idCollaborateur);
if(existe) if(existe)
{ {

@ -22,6 +22,7 @@ namespace EPAServeur.Tests.Services
private EpContext epContext; private EpContext epContext;
private ICollaborateurApi collaborateurApi; private ICollaborateurApi collaborateurApi;
private ICollaborateurService collaborateurService; private ICollaborateurService collaborateurService;
private ITransformDTO transformDTO;
#endregion #endregion
#region Setup #region Setup
@ -36,7 +37,8 @@ namespace EPAServeur.Tests.Services
epContext = new EpContext(optionBuider); epContext = new EpContext(optionBuider);
collaborateurApi = new CollaborateurApi(); collaborateurApi = new CollaborateurApi();
collaborateurService = new CollaborateurService(collaborateurApi, epContext); transformDTO = new TransformDTO();
collaborateurService = new CollaborateurService(collaborateurApi, epContext, transformDTO);
epContext.Database.EnsureDeleted(); epContext.Database.EnsureDeleted();
epContext.Database.EnsureCreated(); epContext.Database.EnsureCreated();
epContext.SaveChanges(); epContext.SaveChanges();
@ -59,7 +61,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationByIdAsync_PasseEnParamUnIdExistantDansLeJeuDeDonneesFictif_RetourneUneFormation() public async Task GetFormationByIdAsync_PasseEnParamUnIdExistantDansLeJeuDeDonneesFictif_RetourneUneFormation()
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
FormationDTO formationDTO = await formationService.GetFormationByIdAsync(3); FormationDTO formationDTO = await formationService.GetFormationByIdAsync(3);
@ -85,7 +87,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationByIdAsync_PasseEnParamUnIdExistantDansLeJeuDeDonneesFictif_RetourneUneFormationSansParticipation() public async Task GetFormationByIdAsync_PasseEnParamUnIdExistantDansLeJeuDeDonneesFictif_RetourneUneFormationSansParticipation()
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
long idFormation = 11; long idFormation = 11;
// Act // Act
@ -114,7 +116,7 @@ namespace EPAServeur.Tests.Services
public void GetFormationByIdAsync_PasseEnParamUnIdInexistantDansLeJeuDeDonneesFictif_LeveUneFormationNotFoundException(long idFormation) public void GetFormationByIdAsync_PasseEnParamUnIdInexistantDansLeJeuDeDonneesFictif_LeveUneFormationNotFoundException(long idFormation)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
AsyncTestDelegate throwException = () => formationService.GetFormationByIdAsync(idFormation); AsyncTestDelegate throwException = () => formationService.GetFormationByIdAsync(idFormation);
@ -136,7 +138,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseDesParamsValides_RetourneDesFormations(long? idAgence, int[] arrIdStatuts, bool? asc, int? numPage, int? parPAge, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) public async Task GetFormationsAsync_PasseDesParamsValides_RetourneDesFormations(long? idAgence, int[] arrIdStatuts, bool? asc, int? numPage, int? parPAge, string texte, string tri, DateTime? dateDebut, DateTime? dateFin)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
List<int?> idStatuts; List<int?> idStatuts;
if (arrIdStatuts != null) if (arrIdStatuts != null)
@ -156,7 +158,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamNumPageEtParPage_RetourneLaPremierePageDesFormations(int? numPage, int? parPAge) public async Task GetFormationsAsync_PasseEnParamNumPageEtParPage_RetourneLaPremierePageDesFormations(int? numPage, int? parPAge)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, null, numPage, parPAge, null, null, null, null); IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, null, numPage, parPAge, null, null, null, null);
@ -172,7 +174,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamNumPageEtParPage_RetourneLaDeuxiemePageDesFormations(int? numPage, int? parPAge) public async Task GetFormationsAsync_PasseEnParamNumPageEtParPage_RetourneLaDeuxiemePageDesFormations(int? numPage, int? parPAge)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
int? nbFormationDeuxiemePage; int? nbFormationDeuxiemePage;
switch (parPAge) switch (parPAge)
@ -204,7 +206,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParIntituleCroissant(bool? asc, string tri) public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParIntituleCroissant(bool? asc, string tri)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null); IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null);
@ -221,7 +223,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParIntituleDecroissant(bool? asc, string tri) public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParIntituleDecroissant(bool? asc, string tri)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null); IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null);
@ -236,7 +238,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParStatutCroissant(bool? asc, string tri) public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParStatutCroissant(bool? asc, string tri)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null); IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null);
@ -251,7 +253,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParStatutDecroissant(bool? asc, string tri) public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParStatutDecroissant(bool? asc, string tri)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null); IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null);
@ -266,7 +268,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParNombreDeParticipantsCroissant(bool? asc, string tri) public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParNombreDeParticipantsCroissant(bool? asc, string tri)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null); IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null);
@ -281,7 +283,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParNombreDeParticipantsDecroissant(bool? asc, string tri) public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParNombreDeParticipantsDecroissant(bool? asc, string tri)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null); IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null);
@ -296,7 +298,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParOrigineCroissante(bool? asc, string tri) public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParOrigineCroissante(bool? asc, string tri)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null); IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null);
@ -311,7 +313,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParOrigineDecroissante(bool? asc, string tri) public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParOrigineDecroissante(bool? asc, string tri)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null); IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null);
@ -326,7 +328,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParDateCroissante(bool? asc, string tri) public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParDateCroissante(bool? asc, string tri)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null); IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null);
@ -341,7 +343,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParDateDecroissante(bool? asc, string tri) public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParDateDecroissante(bool? asc, string tri)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null); IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null);
@ -356,7 +358,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParCertificationCroissante(bool? asc, string tri) public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParCertificationCroissante(bool? asc, string tri)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null); IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null);
@ -371,7 +373,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParCertificationDecroissante(bool? asc, string tri) public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParCertificationDecroissante(bool? asc, string tri)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null); IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null);
@ -387,7 +389,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamUneDateDeDebut_RetourneDesFormationsAvecUneDateDeDebutSuperieur(DateTime dateDebut) public async Task GetFormationsAsync_PasseEnParamUneDateDeDebut_RetourneDesFormationsAvecUneDateDeDebutSuperieur(DateTime dateDebut)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, null, null, null, null, null, dateDebut, null); IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, null, null, null, null, null, dateDebut, null);
@ -402,7 +404,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamUneDateDeFin_RetourneDesFormationsAvecUneDateDeFinInferieur(DateTime dateFin) public async Task GetFormationsAsync_PasseEnParamUneDateDeFin_RetourneDesFormationsAvecUneDateDeFinInferieur(DateTime dateFin)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, null, null, null, null, null, null, dateFin); IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, null, null, null, null, null, null, dateFin);
@ -417,7 +419,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamUneDateDeDebutEtUneDateDeFin_RetourneDesFormationsAvecUneDateDeDebutSuperieurUneDateDeFinInferieur(DateTime dateDebut, DateTime dateFin) public async Task GetFormationsAsync_PasseEnParamUneDateDeDebutEtUneDateDeFin_RetourneDesFormationsAvecUneDateDeDebutSuperieurUneDateDeFinInferieur(DateTime dateDebut, DateTime dateFin)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, null, null, null, null, null, dateDebut, dateFin); IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, null, null, null, null, null, dateDebut, dateFin);
@ -435,7 +437,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamUneDateDeDebutSuperieurEtUneDateDeFinInferieur_RetourneZeroFormation(DateTime dateDebut, DateTime dateFin) public async Task GetFormationsAsync_PasseEnParamUneDateDeDebutSuperieurEtUneDateDeFinInferieur_RetourneZeroFormation(DateTime dateDebut, DateTime dateFin)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, null, null, null, null, null, dateDebut, dateFin); IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, null, null, null, null, null, dateDebut, dateFin);
@ -450,7 +452,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseDesParamsInvalides_RetourneZeroFormation(long? idAgence, int[] arrIdStatuts, bool? asc, int? numPage, int? parPAge, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) public async Task GetFormationsAsync_PasseDesParamsInvalides_RetourneZeroFormation(long? idAgence, int[] arrIdStatuts, bool? asc, int? numPage, int? parPAge, string texte, string tri, DateTime? dateDebut, DateTime? dateFin)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
List<int?> idStatuts; List<int?> idStatuts;
if (arrIdStatuts != null) if (arrIdStatuts != null)
@ -479,7 +481,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsCountAsync_PasseDesParamsValides_RetourneLeNombreTotalDeFormations(long? idAgence, int[] arrIdStatuts, string texte, DateTime? dateDebut, DateTime? dateFin) public async Task GetFormationsCountAsync_PasseDesParamsValides_RetourneLeNombreTotalDeFormations(long? idAgence, int[] arrIdStatuts, string texte, DateTime? dateDebut, DateTime? dateFin)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
List<int?> idStatuts; List<int?> idStatuts;
if (arrIdStatuts != null) if (arrIdStatuts != null)
@ -500,7 +502,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsCountAsync_PasseDesParamsInvalides_RetourneZero(long? idAgence, int[] arrIdStatuts, string texte, DateTime? dateDebut, DateTime? dateFin) public async Task GetFormationsCountAsync_PasseDesParamsInvalides_RetourneZero(long? idAgence, int[] arrIdStatuts, string texte, DateTime? dateDebut, DateTime? dateFin)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
List<int?> idStatuts; List<int?> idStatuts;
if (arrIdStatuts != null) if (arrIdStatuts != null)
@ -524,7 +526,7 @@ namespace EPAServeur.Tests.Services
public async Task GetModesFormationAsync_RetourneTousLesModesDeFormation() public async Task GetModesFormationAsync_RetourneTousLesModesDeFormation()
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
IEnumerable<ModeFormationDTO> modeFormationDTOs = await formationService.GetModesFormationAsync(); IEnumerable<ModeFormationDTO> modeFormationDTOs = await formationService.GetModesFormationAsync();
@ -542,7 +544,7 @@ namespace EPAServeur.Tests.Services
public async Task GetOriginesAsyncFormation_RetourneToutesLesOriginesDeFormation() public async Task GetOriginesAsyncFormation_RetourneToutesLesOriginesDeFormation()
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
IEnumerable<OrigineFormationDTO> origineFormationDTOs = await formationService.GetOriginesFormationAsync(); IEnumerable<OrigineFormationDTO> origineFormationDTOs = await formationService.GetOriginesFormationAsync();
@ -560,7 +562,7 @@ namespace EPAServeur.Tests.Services
public async Task GetStatutsFormationAsyncFormation_RetourneTousLesStatutsDeFormation() public async Task GetStatutsFormationAsyncFormation_RetourneTousLesStatutsDeFormation()
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
IEnumerable<StatutFormationDTO> statutFormationDTOs = await formationService.GetStatutsFormationAsync(); IEnumerable<StatutFormationDTO> statutFormationDTOs = await formationService.GetStatutsFormationAsync();
@ -578,7 +580,7 @@ namespace EPAServeur.Tests.Services
public async Task GetTypesFormationAsync_RetourneTousLesTypesDeFormation() public async Task GetTypesFormationAsync_RetourneTousLesTypesDeFormation()
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
IEnumerable<TypeFormationDTO> typeFormationDTOs = await formationService.GetTypesFormationAsync(); IEnumerable<TypeFormationDTO> typeFormationDTOs = await formationService.GetTypesFormationAsync();
@ -623,7 +625,7 @@ namespace EPAServeur.Tests.Services
EstCertifiee = false EstCertifiee = false
}; };
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
FormationDTO formationAjoute = await formationService.AddFormationAsync(formation); FormationDTO formationAjoute = await formationService.AddFormationAsync(formation);
@ -652,7 +654,7 @@ namespace EPAServeur.Tests.Services
// Arrange // Arrange
FormationDTO formation = null; FormationDTO formation = null;
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
AsyncTestDelegate throwException = () => formationService.AddFormationAsync(formation); AsyncTestDelegate throwException = () => formationService.AddFormationAsync(formation);
@ -701,7 +703,7 @@ namespace EPAServeur.Tests.Services
EstCertifiee = false EstCertifiee = false
}; };
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
AsyncTestDelegate throwException = () => formationService.AddFormationAsync(formation); AsyncTestDelegate throwException = () => formationService.AddFormationAsync(formation);
@ -747,7 +749,7 @@ namespace EPAServeur.Tests.Services
EstCertifiee = false EstCertifiee = false
}; };
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
AsyncTestDelegate throwException = () => formationService.AddFormationAsync(formation); AsyncTestDelegate throwException = () => formationService.AddFormationAsync(formation);
@ -773,7 +775,7 @@ namespace EPAServeur.Tests.Services
OrigineFormationDTO origineFormationCollaborateur = epContext.OrigineFormation.Where(mode => mode.IdOrigineFormation == idOrigine) OrigineFormationDTO origineFormationCollaborateur = epContext.OrigineFormation.Where(mode => mode.IdOrigineFormation == idOrigine)
.Select(mode => new OrigineFormationDTO { Id = mode.IdOrigineFormation, Libelle = mode.Libelle }).FirstOrDefault(); .Select(mode => new OrigineFormationDTO { Id = mode.IdOrigineFormation, Libelle = mode.Libelle }).FirstOrDefault();
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
FormationDTO formation = await formationService.GetFormationByIdAsync(idFormation); FormationDTO formation = await formationService.GetFormationByIdAsync(idFormation);
@ -837,7 +839,7 @@ namespace EPAServeur.Tests.Services
OrigineFormationDTO origineFormationCollaborateur = epContext.OrigineFormation.Where(mode => mode.IdOrigineFormation == idOrigine) OrigineFormationDTO origineFormationCollaborateur = epContext.OrigineFormation.Where(mode => mode.IdOrigineFormation == idOrigine)
.Select(mode => new OrigineFormationDTO { Id = mode.IdOrigineFormation, Libelle = mode.Libelle }).FirstOrDefault(); .Select(mode => new OrigineFormationDTO { Id = mode.IdOrigineFormation, Libelle = mode.Libelle }).FirstOrDefault();
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
FormationDTO formation = await formationService.GetFormationByIdAsync(idFormation); FormationDTO formation = await formationService.GetFormationByIdAsync(idFormation);
@ -876,7 +878,7 @@ namespace EPAServeur.Tests.Services
OrigineFormationDTO origineFormationCollaborateur = epContext.OrigineFormation.Where(mode => mode.IdOrigineFormation == idOrigine) OrigineFormationDTO origineFormationCollaborateur = epContext.OrigineFormation.Where(mode => mode.IdOrigineFormation == idOrigine)
.Select(mode => new OrigineFormationDTO { Id = mode.IdOrigineFormation, Libelle = mode.Libelle }).FirstOrDefault(); .Select(mode => new OrigineFormationDTO { Id = mode.IdOrigineFormation, Libelle = mode.Libelle }).FirstOrDefault();
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
FormationDTO formation = await formationService.GetFormationByIdAsync(1); FormationDTO formation = await formationService.GetFormationByIdAsync(1);
@ -914,7 +916,7 @@ namespace EPAServeur.Tests.Services
OrigineFormationDTO origineFormationCollaborateur = epContext.OrigineFormation.Where(mode => mode.IdOrigineFormation == idOrigine) OrigineFormationDTO origineFormationCollaborateur = epContext.OrigineFormation.Where(mode => mode.IdOrigineFormation == idOrigine)
.Select(mode => new OrigineFormationDTO { Id = mode.IdOrigineFormation, Libelle = mode.Libelle }).FirstOrDefault(); .Select(mode => new OrigineFormationDTO { Id = mode.IdOrigineFormation, Libelle = mode.Libelle }).FirstOrDefault();
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
FormationDTO formation = new FormationDTO FormationDTO formation = new FormationDTO
{ {
@ -950,7 +952,7 @@ namespace EPAServeur.Tests.Services
public async Task DeleteFormationByIdAsync_SupprimeUneFormationAvecUnIdValide_FormationSupprimeAvecSucces(long idFormation) public async Task DeleteFormationByIdAsync_SupprimeUneFormationAvecUnIdValide_FormationSupprimeAvecSucces(long idFormation)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
bool existFormation = true; bool existFormation = true;
// Act // Act
@ -967,7 +969,7 @@ namespace EPAServeur.Tests.Services
public void DeleteFormationByIdAsync_SupprimeUneFormationAvecUnIdInvalide_LeveUneFormationNotFoundException(long idFormation) public void DeleteFormationByIdAsync_SupprimeUneFormationAvecUnIdInvalide_LeveUneFormationNotFoundException(long idFormation)
{ {
// Arrange // Arrange
FormationService formationService = new FormationService(epContext, collaborateurService); FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act // Act
AsyncTestDelegate throwException = () => formationService.DeleteFormationByIdAsync(idFormation); AsyncTestDelegate throwException = () => formationService.DeleteFormationByIdAsync(idFormation);

@ -21,6 +21,7 @@ namespace EPAServeur.Tests.Services
private EpContext context; private EpContext context;
private ICollaborateurApi collaborateurApi; private ICollaborateurApi collaborateurApi;
private ICollaborateurService collaborateurService; private ICollaborateurService collaborateurService;
private ITransformDTO transformDTO;
private Guid? auteur1, auteur2, auteur3; private Guid? auteur1, auteur2, auteur3;
private Guid? collaborateur1, collaborateur2, collaborateur3; private Guid? collaborateur1, collaborateur2, collaborateur3;
private Guid? auteurNonExistant, collaborateurNonExistant, collaborateurParti, referentParti; private Guid? auteurNonExistant, collaborateurNonExistant, collaborateurParti, referentParti;
@ -51,7 +52,8 @@ namespace EPAServeur.Tests.Services
entity.State = EntityState.Detached; entity.State = EntityState.Detached;
} }
collaborateurApi = new CollaborateurApi(); collaborateurApi = new CollaborateurApi();
collaborateurService = new CollaborateurService(collaborateurApi, context); transformDTO = new TransformDTO();
collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
auteur1 = new Guid("aa36f34c-9041-42f5-9db3-6536fe7f1696"); auteur1 = new Guid("aa36f34c-9041-42f5-9db3-6536fe7f1696");
@ -81,7 +83,7 @@ namespace EPAServeur.Tests.Services
CollaborateurDTO collaborateur2DTO = await collaborateurService.GetCollaborateurByIdAsync(collaborateur2); CollaborateurDTO collaborateur2DTO = await collaborateurService.GetCollaborateurByIdAsync(collaborateur2);
CollaborateurDTO collaborateur3DTO = await collaborateurService.GetCollaborateurByIdAsync(collaborateur3); CollaborateurDTO collaborateur3DTO = await collaborateurService.GetCollaborateurByIdAsync(collaborateur3);
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context); INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context, transformDTO);
DateTime date = DateTime.Now; DateTime date = DateTime.Now;
DetailsNoteDTO noteAjoutee1, noteAjoutee2; DetailsNoteDTO noteAjoutee1, noteAjoutee2;
@ -203,7 +205,7 @@ namespace EPAServeur.Tests.Services
CollaborateurDTO collaborateurDTO = await collaborateurService.GetCollaborateurByIdAsync(collaborateur1); CollaborateurDTO collaborateurDTO = await collaborateurService.GetCollaborateurByIdAsync(collaborateur1);
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context); INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context, transformDTO);
DateTime date = DateTime.Now; DateTime date = DateTime.Now;
DetailsNoteDTO noteAjoutee1 = new DetailsNoteDTO() DetailsNoteDTO noteAjoutee1 = new DetailsNoteDTO()
@ -226,7 +228,7 @@ namespace EPAServeur.Tests.Services
{ {
CollaborateurDTO collaborateurDTO = await collaborateurService.GetCollaborateurByIdAsync(collaborateur1); CollaborateurDTO collaborateurDTO = await collaborateurService.GetCollaborateurByIdAsync(collaborateur1);
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context); INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context, transformDTO);
DateTime date = DateTime.Now; DateTime date = DateTime.Now;
DetailsNoteDTO note = new DetailsNoteDTO() DetailsNoteDTO note = new DetailsNoteDTO()
@ -249,7 +251,7 @@ namespace EPAServeur.Tests.Services
CollaborateurDTO collaborateurDTO = await collaborateurService.GetCollaborateurByIdAsync(collaborateur1); CollaborateurDTO collaborateurDTO = await collaborateurService.GetCollaborateurByIdAsync(collaborateur1);
collaborateurDTO.Id = collaborateurNonExistant; collaborateurDTO.Id = collaborateurNonExistant;
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context); INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context, transformDTO);
DateTime date = DateTime.Now; DateTime date = DateTime.Now;
DetailsNoteDTO note = new DetailsNoteDTO() DetailsNoteDTO note = new DetailsNoteDTO()
@ -274,7 +276,7 @@ namespace EPAServeur.Tests.Services
CollaborateurDTO collaborateurDTO = await collaborateurService.GetCollaborateurByIdAsync(collaborateur1); CollaborateurDTO collaborateurDTO = await collaborateurService.GetCollaborateurByIdAsync(collaborateur1);
CollaborateurDTO collaborateurPartiDTO = await collaborateurService.GetCollaborateurByIdAsync(collaborateurParti); CollaborateurDTO collaborateurPartiDTO = await collaborateurService.GetCollaborateurByIdAsync(collaborateurParti);
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context); INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context, transformDTO);
DateTime date = DateTime.Now; DateTime date = DateTime.Now;
@ -317,7 +319,7 @@ namespace EPAServeur.Tests.Services
[TestCase(9)] [TestCase(9)]
public async Task GetNote_NoteNotNull(long id) public async Task GetNote_NoteNotNull(long id)
{ {
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context); INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context, transformDTO);
DetailsNoteDTO detailsNoteDTO = await noteService.GetNoteByIdAsync(id); DetailsNoteDTO detailsNoteDTO = await noteService.GetNoteByIdAsync(id);
Assert.NotNull(detailsNoteDTO); Assert.NotNull(detailsNoteDTO);
@ -341,7 +343,7 @@ namespace EPAServeur.Tests.Services
[TestCase(100)] [TestCase(100)]
public void GetNote_NoteNotFoundException(long id) public void GetNote_NoteNotFoundException(long id)
{ {
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context); INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context, transformDTO);
AsyncTestDelegate exception = () => noteService.GetNoteByIdAsync(id); AsyncTestDelegate exception = () => noteService.GetNoteByIdAsync(id);
Assert.ThrowsAsync(typeof(NoteNotFoundException), exception); Assert.ThrowsAsync(typeof(NoteNotFoundException), exception);
} }
@ -350,7 +352,7 @@ namespace EPAServeur.Tests.Services
[TestCase(7)] [TestCase(7)]
public void GetNote_ReferentNotFoundException(long id) public void GetNote_ReferentNotFoundException(long id)
{ {
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context); INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context, transformDTO);
AsyncTestDelegate exception = () => noteService.GetNoteByIdAsync(id); AsyncTestDelegate exception = () => noteService.GetNoteByIdAsync(id);
Assert.ThrowsAsync(typeof(ReferentNotFoundException), exception); Assert.ThrowsAsync(typeof(ReferentNotFoundException), exception);
} }
@ -359,7 +361,7 @@ namespace EPAServeur.Tests.Services
[TestCase(10)] [TestCase(10)]
public void GetNote_CollaborateurNotFoundException(long id) public void GetNote_CollaborateurNotFoundException(long id)
{ {
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context); INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context, transformDTO);
AsyncTestDelegate exception = () => noteService.GetNoteByIdAsync(id); AsyncTestDelegate exception = () => noteService.GetNoteByIdAsync(id);
Assert.ThrowsAsync(typeof(CollaborateurNotFoundException), exception); Assert.ThrowsAsync(typeof(CollaborateurNotFoundException), exception);
} }
@ -375,7 +377,7 @@ namespace EPAServeur.Tests.Services
[TestCase(8)] [TestCase(8)]
public async Task SupprimerNote_Succes(long id) public async Task SupprimerNote_Succes(long id)
{ {
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context); INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context, transformDTO);
await noteService.SupprimerNoteAsync(id); await noteService.SupprimerNoteAsync(id);
Note note = await context.Note.FindAsync(id); Note note = await context.Note.FindAsync(id);
@ -393,7 +395,7 @@ namespace EPAServeur.Tests.Services
[TestCase(100)] [TestCase(100)]
public void SupprimerNote_NoteNotFoundException(long id) public void SupprimerNote_NoteNotFoundException(long id)
{ {
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context); INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context, transformDTO);
AsyncTestDelegate exception = () => noteService.SupprimerNoteAsync(id); AsyncTestDelegate exception = () => noteService.SupprimerNoteAsync(id);
Assert.ThrowsAsync(typeof(NoteNotFoundException), exception); Assert.ThrowsAsync(typeof(NoteNotFoundException), exception);
@ -410,7 +412,7 @@ namespace EPAServeur.Tests.Services
[TestCase(9)] [TestCase(9)]
public async Task UpdateNote_UpdateTitreEtTexte(long id) public async Task UpdateNote_UpdateTitreEtTexte(long id)
{ {
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context); INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context, transformDTO);
DetailsNoteDTO note = await noteService.GetNoteByIdAsync(id); DetailsNoteDTO note = await noteService.GetNoteByIdAsync(id);
note.Titre = "Titre à jour " + id; note.Titre = "Titre à jour " + id;
note.Texte= "Texte à jour " + id; note.Texte= "Texte à jour " + id;
@ -433,7 +435,7 @@ namespace EPAServeur.Tests.Services
[TestCase(9)] [TestCase(9)]
public async Task UpdateNote_UpdateTexte(long id) public async Task UpdateNote_UpdateTexte(long id)
{ {
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context); INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context, transformDTO);
DetailsNoteDTO note = await noteService.GetNoteByIdAsync(id); DetailsNoteDTO note = await noteService.GetNoteByIdAsync(id);
note.Texte = "Texte à jour " + id; note.Texte = "Texte à jour " + id;
DetailsNoteDTO noteUpdate = await noteService.UpdateNoteAsync(id, note); DetailsNoteDTO noteUpdate = await noteService.UpdateNoteAsync(id, note);
@ -455,7 +457,7 @@ namespace EPAServeur.Tests.Services
[TestCase(9)] [TestCase(9)]
public async Task UpdateNote_UpdateTitre(long id) public async Task UpdateNote_UpdateTitre(long id)
{ {
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context); INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context, transformDTO);
DetailsNoteDTO note = await noteService.GetNoteByIdAsync(id); DetailsNoteDTO note = await noteService.GetNoteByIdAsync(id);
note.Titre = "Titre à jour " + id; note.Titre = "Titre à jour " + id;
DetailsNoteDTO noteUpdate = await noteService.UpdateNoteAsync(id, note); DetailsNoteDTO noteUpdate = await noteService.UpdateNoteAsync(id, note);
@ -479,7 +481,7 @@ namespace EPAServeur.Tests.Services
[TestCase(9,7)] [TestCase(9,7)]
public async Task UpdateNote_NoteIdImcompatibleExceptionId(long id, long mauvaisId) public async Task UpdateNote_NoteIdImcompatibleExceptionId(long id, long mauvaisId)
{ {
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context); INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context, transformDTO);
DetailsNoteDTO note = await noteService.GetNoteByIdAsync(id); DetailsNoteDTO note = await noteService.GetNoteByIdAsync(id);
note.Titre = "Titre à jour " + id; note.Titre = "Titre à jour " + id;
note.Texte = "Texte à jour " + id; note.Texte = "Texte à jour " + id;
@ -493,7 +495,7 @@ namespace EPAServeur.Tests.Services
[TestCase(9)] [TestCase(9)]
public async Task UpdateNote_NoteIdImcompatibleExceptionDate(long id) public async Task UpdateNote_NoteIdImcompatibleExceptionDate(long id)
{ {
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context); INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context, transformDTO);
DetailsNoteDTO note = await noteService.GetNoteByIdAsync(id); DetailsNoteDTO note = await noteService.GetNoteByIdAsync(id);
note.Titre = "Titre à jour " + id; note.Titre = "Titre à jour " + id;
note.Texte = "Texte à jour " + id; note.Texte = "Texte à jour " + id;

@ -23,6 +23,7 @@ namespace EPAServeur.Tests.Services
private EpContext epContext; private EpContext epContext;
private ICollaborateurApi collaborateurApi; private ICollaborateurApi collaborateurApi;
private ICollaborateurService collaborateurService; private ICollaborateurService collaborateurService;
private ITransformDTO transformDTO;
#endregion #endregion
#region Setup #region Setup
@ -37,7 +38,8 @@ namespace EPAServeur.Tests.Services
epContext = new EpContext(optionBuider); epContext = new EpContext(optionBuider);
collaborateurApi = new CollaborateurApi(); collaborateurApi = new CollaborateurApi();
collaborateurService = new CollaborateurService(collaborateurApi, epContext); transformDTO = new TransformDTO();
collaborateurService = new CollaborateurService(collaborateurApi, epContext, transformDTO);
epContext.Database.EnsureDeleted(); epContext.Database.EnsureDeleted();
epContext.Database.EnsureCreated(); epContext.Database.EnsureCreated();
epContext.SaveChanges(); epContext.SaveChanges();
@ -61,7 +63,7 @@ namespace EPAServeur.Tests.Services
public async Task GetEvaluationCollaborateurAsync_PasseEnParamUnIdExistantDansLeJeuDeDonneesFictif_RetourneUneEvaluation() public async Task GetEvaluationCollaborateurAsync_PasseEnParamUnIdExistantDansLeJeuDeDonneesFictif_RetourneUneEvaluation()
{ {
// Arrange // Arrange
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService); ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO);
long idParticipationFormation = 5; long idParticipationFormation = 5;
// Act // Act
EvaluationDTO evaluationDTO = await participationFormationService.GetEvaluationCollaborateurAsync(idParticipationFormation); EvaluationDTO evaluationDTO = await participationFormationService.GetEvaluationCollaborateurAsync(idParticipationFormation);
@ -79,7 +81,7 @@ namespace EPAServeur.Tests.Services
public void GetEvaluationCollaborateurAsync_PasseEnParamUnIdInexistantDansLeJeuDeDonneesFictif_LeveUneParticipationFormationNotFoundException(long idParticipationFormation) public void GetEvaluationCollaborateurAsync_PasseEnParamUnIdInexistantDansLeJeuDeDonneesFictif_LeveUneParticipationFormationNotFoundException(long idParticipationFormation)
{ {
// Arrange // Arrange
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService); ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO);
// Act // Act
AsyncTestDelegate throwException = () => participationFormationService.GetEvaluationCollaborateurAsync(idParticipationFormation); AsyncTestDelegate throwException = () => participationFormationService.GetEvaluationCollaborateurAsync(idParticipationFormation);
@ -97,7 +99,7 @@ namespace EPAServeur.Tests.Services
public async Task GetParticipationByCollaborateurAsync_PasseDesParamsValides_RetourneDesParticipationsFormations(Guid idCollaborateur) public async Task GetParticipationByCollaborateurAsync_PasseDesParamsValides_RetourneDesParticipationsFormations(Guid idCollaborateur)
{ {
// Arrange // Arrange
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService); ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO);
// Act // Act
IEnumerable<ParticipationFormationDTO> participationFormationDTOs = await participationFormationService.GetParticipationsByCollaborateurAsync(idCollaborateur); IEnumerable<ParticipationFormationDTO> participationFormationDTOs = await participationFormationService.GetParticipationsByCollaborateurAsync(idCollaborateur);
@ -111,7 +113,7 @@ namespace EPAServeur.Tests.Services
public async Task GetParticipationByCollaborateurAsync_PasseDesParamsInvalides_RetourneZeroParticipation(Guid idCollaborateur) public async Task GetParticipationByCollaborateurAsync_PasseDesParamsInvalides_RetourneZeroParticipation(Guid idCollaborateur)
{ {
// Arrange // Arrange
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService); ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO);
// Act // Act
IEnumerable<ParticipationFormationDTO> participationFormationDTOs = await participationFormationService.GetParticipationsByCollaborateurAsync(idCollaborateur); IEnumerable<ParticipationFormationDTO> participationFormationDTOs = await participationFormationService.GetParticipationsByCollaborateurAsync(idCollaborateur);
@ -128,7 +130,7 @@ namespace EPAServeur.Tests.Services
public async Task EvaluerFormationAsync_EvaluerUneFormationValide_EvaluationRealiseeAvecSucces() public async Task EvaluerFormationAsync_EvaluerUneFormationValide_EvaluationRealiseeAvecSucces()
{ {
// Arrange // Arrange
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService); ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO);
long idParticipationFormation = 5; long idParticipationFormation = 5;
EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation)
@ -198,7 +200,7 @@ namespace EPAServeur.Tests.Services
{ {
// Arrange // Arrange
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService); ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO);
long idParticipationFormation = 5; long idParticipationFormation = 5;
EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation)
@ -259,7 +261,7 @@ namespace EPAServeur.Tests.Services
{ {
// Arrange // Arrange
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService); ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO);
long idParticipationFormation = 5; long idParticipationFormation = 5;
bool? estCertifiee = null; bool? estCertifiee = null;
@ -321,7 +323,7 @@ namespace EPAServeur.Tests.Services
{ {
// Arrange // Arrange
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService); ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO);
long idParticipationFormation = 5; long idParticipationFormation = 5;
DateTime? dateDebut = null; DateTime? dateDebut = null;
@ -383,7 +385,7 @@ namespace EPAServeur.Tests.Services
{ {
// Arrange // Arrange
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService); ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO);
long idParticipationFormation = 5; long idParticipationFormation = 5;
EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation)
@ -411,7 +413,7 @@ namespace EPAServeur.Tests.Services
{ {
// Arrange // Arrange
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService); ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO);
long idParticipationFormation = 5; long idParticipationFormation = 5;
EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation)
@ -439,7 +441,7 @@ namespace EPAServeur.Tests.Services
{ {
// Arrange // Arrange
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService); ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO);
long idParticipationFormation = 5; long idParticipationFormation = 5;
EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation)
@ -498,7 +500,7 @@ namespace EPAServeur.Tests.Services
{ {
// Arrange // Arrange
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService); ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO);
long idParticipationFormation = 5; long idParticipationFormation = 5;
EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation)
@ -558,7 +560,7 @@ namespace EPAServeur.Tests.Services
{ {
// Arrange // Arrange
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService); ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO);
long idParticipationFormation = 5; long idParticipationFormation = 5;
EvaluationDTO evaluationDTO = null; EvaluationDTO evaluationDTO = null;
@ -574,7 +576,7 @@ namespace EPAServeur.Tests.Services
public async Task EvaluerFormationAsync_EvaluerUneFormationAvecUnIdIncorrecte_LeveUneParticipationFormationIncompatibleIdException(long idParticipationFormationIncompatible) public async Task EvaluerFormationAsync_EvaluerUneFormationAvecUnIdIncorrecte_LeveUneParticipationFormationIncompatibleIdException(long idParticipationFormationIncompatible)
{ {
// Arrange // Arrange
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService); ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO);
long idParticipationFormation = 5; long idParticipationFormation = 5;
EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation)
@ -634,7 +636,7 @@ namespace EPAServeur.Tests.Services
public async Task EvaluerFormationAsync_EvaluerUneFormationAvecUnIdIncorrecteAuNiveauDuDTO_LeveUneParticipationFormationIncompatibleIdException(long? idParticipationFormationIncompatible) public async Task EvaluerFormationAsync_EvaluerUneFormationAvecUnIdIncorrecteAuNiveauDuDTO_LeveUneParticipationFormationIncompatibleIdException(long? idParticipationFormationIncompatible)
{ {
// Arrange // Arrange
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService); ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO);
long idParticipationFormation = 5; long idParticipationFormation = 5;
EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation)
@ -695,7 +697,7 @@ namespace EPAServeur.Tests.Services
{ {
// Arrange // Arrange
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService); ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO);
long idParticipationFormation = 5; long idParticipationFormation = 5;
long idParticipationFormationInexistant = 0; long idParticipationFormationInexistant = 0;

@ -22,6 +22,7 @@ namespace EPAServeur.Tests.Services
private EpContext context; private EpContext context;
private ICollaborateurApi collaborateurApi; private ICollaborateurApi collaborateurApi;
private ICollaborateurService collaborateurService; private ICollaborateurService collaborateurService;
private ITransformDTO transformDTO;
private Guid? referent1; private Guid? referent1;
private Guid? collaborateur1, collaborateur2, collaborateur3; private Guid? collaborateur1, collaborateur2, collaborateur3;
private Guid? collaborateurNonExistant, collaborateurParti; private Guid? collaborateurNonExistant, collaborateurParti;
@ -48,7 +49,8 @@ namespace EPAServeur.Tests.Services
entity.State = EntityState.Detached; entity.State = EntityState.Detached;
} }
collaborateurApi = new CollaborateurApi(); collaborateurApi = new CollaborateurApi();
collaborateurService = new CollaborateurService(collaborateurApi, context); transformDTO = new TransformDTO();
collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
referent1 = new Guid("aa36f34c-9041-42f5-9db3-6536fe7f1696"); referent1 = new Guid("aa36f34c-9041-42f5-9db3-6536fe7f1696");

Loading…
Cancel
Save