MAJ des tests unitaires: Ajout du service TransformDTO

develop
jboinembalome 4 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;
private ICollaborateurApi collaborateurApi;
private ICollaborateurService collaborateurService;
private ITransformDTO transformDTO;
#endregion
#region Setup
@ -55,8 +56,9 @@ namespace EPAServeur.Tests.Controllers
}
collaborateurApi = new CollaborateurApi();
collaborateurService = new CollaborateurService(collaborateurApi, context);
demandeDelegationService = new DemandeDelegationService(collaborateurService, context);
transformDTO = new TransformDTO();
collaborateurService = new CollaborateurService(collaborateurApi, context, transformDTO);
demandeDelegationService = new DemandeDelegationService(collaborateurService, context, transformDTO);
}
#endregion

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

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

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

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

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

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

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

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

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

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

@ -22,6 +22,7 @@ namespace EPAServeur.Tests.Services
private EpContext epContext;
private ICollaborateurApi collaborateurApi;
private ICollaborateurService collaborateurService;
private ITransformDTO transformDTO;
#endregion
#region Setup
@ -36,7 +37,8 @@ namespace EPAServeur.Tests.Services
epContext = new EpContext(optionBuider);
collaborateurApi = new CollaborateurApi();
collaborateurService = new CollaborateurService(collaborateurApi, epContext);
transformDTO = new TransformDTO();
collaborateurService = new CollaborateurService(collaborateurApi, epContext, transformDTO);
epContext.Database.EnsureDeleted();
epContext.Database.EnsureCreated();
epContext.SaveChanges();
@ -59,7 +61,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationByIdAsync_PasseEnParamUnIdExistantDansLeJeuDeDonneesFictif_RetourneUneFormation()
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
FormationDTO formationDTO = await formationService.GetFormationByIdAsync(3);
@ -85,7 +87,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationByIdAsync_PasseEnParamUnIdExistantDansLeJeuDeDonneesFictif_RetourneUneFormationSansParticipation()
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
long idFormation = 11;
// Act
@ -114,7 +116,7 @@ namespace EPAServeur.Tests.Services
public void GetFormationByIdAsync_PasseEnParamUnIdInexistantDansLeJeuDeDonneesFictif_LeveUneFormationNotFoundException(long idFormation)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
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)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
List<int?> idStatuts;
if (arrIdStatuts != null)
@ -156,7 +158,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamNumPageEtParPage_RetourneLaPremierePageDesFormations(int? numPage, int? parPAge)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
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)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
int? nbFormationDeuxiemePage;
switch (parPAge)
@ -204,7 +206,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParIntituleCroissant(bool? asc, string tri)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
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)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
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)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
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)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
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)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
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)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
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)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
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)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
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)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
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)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
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)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
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)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
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)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
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)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
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)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
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)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
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)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
List<int?> idStatuts;
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)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
List<int?> idStatuts;
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)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
List<int?> idStatuts;
if (arrIdStatuts != null)
@ -524,7 +526,7 @@ namespace EPAServeur.Tests.Services
public async Task GetModesFormationAsync_RetourneTousLesModesDeFormation()
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
IEnumerable<ModeFormationDTO> modeFormationDTOs = await formationService.GetModesFormationAsync();
@ -542,7 +544,7 @@ namespace EPAServeur.Tests.Services
public async Task GetOriginesAsyncFormation_RetourneToutesLesOriginesDeFormation()
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
IEnumerable<OrigineFormationDTO> origineFormationDTOs = await formationService.GetOriginesFormationAsync();
@ -560,7 +562,7 @@ namespace EPAServeur.Tests.Services
public async Task GetStatutsFormationAsyncFormation_RetourneTousLesStatutsDeFormation()
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
IEnumerable<StatutFormationDTO> statutFormationDTOs = await formationService.GetStatutsFormationAsync();
@ -578,7 +580,7 @@ namespace EPAServeur.Tests.Services
public async Task GetTypesFormationAsync_RetourneTousLesTypesDeFormation()
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
IEnumerable<TypeFormationDTO> typeFormationDTOs = await formationService.GetTypesFormationAsync();
@ -623,7 +625,7 @@ namespace EPAServeur.Tests.Services
EstCertifiee = false
};
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
FormationDTO formationAjoute = await formationService.AddFormationAsync(formation);
@ -652,7 +654,7 @@ namespace EPAServeur.Tests.Services
// Arrange
FormationDTO formation = null;
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
AsyncTestDelegate throwException = () => formationService.AddFormationAsync(formation);
@ -701,7 +703,7 @@ namespace EPAServeur.Tests.Services
EstCertifiee = false
};
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
AsyncTestDelegate throwException = () => formationService.AddFormationAsync(formation);
@ -747,7 +749,7 @@ namespace EPAServeur.Tests.Services
EstCertifiee = false
};
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
AsyncTestDelegate throwException = () => formationService.AddFormationAsync(formation);
@ -773,7 +775,7 @@ namespace EPAServeur.Tests.Services
OrigineFormationDTO origineFormationCollaborateur = epContext.OrigineFormation.Where(mode => mode.IdOrigineFormation == idOrigine)
.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);
@ -837,7 +839,7 @@ namespace EPAServeur.Tests.Services
OrigineFormationDTO origineFormationCollaborateur = epContext.OrigineFormation.Where(mode => mode.IdOrigineFormation == idOrigine)
.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);
@ -876,7 +878,7 @@ namespace EPAServeur.Tests.Services
OrigineFormationDTO origineFormationCollaborateur = epContext.OrigineFormation.Where(mode => mode.IdOrigineFormation == idOrigine)
.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);
@ -914,7 +916,7 @@ namespace EPAServeur.Tests.Services
OrigineFormationDTO origineFormationCollaborateur = epContext.OrigineFormation.Where(mode => mode.IdOrigineFormation == idOrigine)
.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
{
@ -950,7 +952,7 @@ namespace EPAServeur.Tests.Services
public async Task DeleteFormationByIdAsync_SupprimeUneFormationAvecUnIdValide_FormationSupprimeAvecSucces(long idFormation)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
bool existFormation = true;
// Act
@ -967,7 +969,7 @@ namespace EPAServeur.Tests.Services
public void DeleteFormationByIdAsync_SupprimeUneFormationAvecUnIdInvalide_LeveUneFormationNotFoundException(long idFormation)
{
// Arrange
FormationService formationService = new FormationService(epContext, collaborateurService);
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO);
// Act
AsyncTestDelegate throwException = () => formationService.DeleteFormationByIdAsync(idFormation);

@ -21,6 +21,7 @@ namespace EPAServeur.Tests.Services
private EpContext context;
private ICollaborateurApi collaborateurApi;
private ICollaborateurService collaborateurService;
private ITransformDTO transformDTO;
private Guid? auteur1, auteur2, auteur3;
private Guid? collaborateur1, collaborateur2, collaborateur3;
private Guid? auteurNonExistant, collaborateurNonExistant, collaborateurParti, referentParti;
@ -51,7 +52,8 @@ namespace EPAServeur.Tests.Services
entity.State = EntityState.Detached;
}
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");
@ -81,7 +83,7 @@ namespace EPAServeur.Tests.Services
CollaborateurDTO collaborateur2DTO = await collaborateurService.GetCollaborateurByIdAsync(collaborateur2);
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;
DetailsNoteDTO noteAjoutee1, noteAjoutee2;
@ -203,7 +205,7 @@ namespace EPAServeur.Tests.Services
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;
DetailsNoteDTO noteAjoutee1 = new DetailsNoteDTO()
@ -226,7 +228,7 @@ namespace EPAServeur.Tests.Services
{
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;
DetailsNoteDTO note = new DetailsNoteDTO()
@ -249,7 +251,7 @@ namespace EPAServeur.Tests.Services
CollaborateurDTO collaborateurDTO = await collaborateurService.GetCollaborateurByIdAsync(collaborateur1);
collaborateurDTO.Id = collaborateurNonExistant;
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context);
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context, transformDTO);
DateTime date = DateTime.Now;
DetailsNoteDTO note = new DetailsNoteDTO()
@ -274,7 +276,7 @@ namespace EPAServeur.Tests.Services
CollaborateurDTO collaborateurDTO = await collaborateurService.GetCollaborateurByIdAsync(collaborateur1);
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;
@ -317,7 +319,7 @@ namespace EPAServeur.Tests.Services
[TestCase(9)]
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);
Assert.NotNull(detailsNoteDTO);
@ -341,7 +343,7 @@ namespace EPAServeur.Tests.Services
[TestCase(100)]
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);
Assert.ThrowsAsync(typeof(NoteNotFoundException), exception);
}
@ -350,7 +352,7 @@ namespace EPAServeur.Tests.Services
[TestCase(7)]
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);
Assert.ThrowsAsync(typeof(ReferentNotFoundException), exception);
}
@ -359,7 +361,7 @@ namespace EPAServeur.Tests.Services
[TestCase(10)]
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);
Assert.ThrowsAsync(typeof(CollaborateurNotFoundException), exception);
}
@ -375,7 +377,7 @@ namespace EPAServeur.Tests.Services
[TestCase(8)]
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);
Note note = await context.Note.FindAsync(id);
@ -393,7 +395,7 @@ namespace EPAServeur.Tests.Services
[TestCase(100)]
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);
Assert.ThrowsAsync(typeof(NoteNotFoundException), exception);
@ -410,7 +412,7 @@ namespace EPAServeur.Tests.Services
[TestCase(9)]
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);
note.Titre = "Titre à jour " + id;
note.Texte= "Texte à jour " + id;
@ -433,7 +435,7 @@ namespace EPAServeur.Tests.Services
[TestCase(9)]
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);
note.Texte = "Texte à jour " + id;
DetailsNoteDTO noteUpdate = await noteService.UpdateNoteAsync(id, note);
@ -455,7 +457,7 @@ namespace EPAServeur.Tests.Services
[TestCase(9)]
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);
note.Titre = "Titre à jour " + id;
DetailsNoteDTO noteUpdate = await noteService.UpdateNoteAsync(id, note);
@ -479,7 +481,7 @@ namespace EPAServeur.Tests.Services
[TestCase(9,7)]
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);
note.Titre = "Titre à jour " + id;
note.Texte = "Texte à jour " + id;
@ -493,7 +495,7 @@ namespace EPAServeur.Tests.Services
[TestCase(9)]
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);
note.Titre = "Titre à jour " + id;
note.Texte = "Texte à jour " + id;

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

@ -22,6 +22,7 @@ namespace EPAServeur.Tests.Services
private EpContext context;
private ICollaborateurApi collaborateurApi;
private ICollaborateurService collaborateurService;
private ITransformDTO transformDTO;
private Guid? referent1;
private Guid? collaborateur1, collaborateur2, collaborateur3;
private Guid? collaborateurNonExistant, collaborateurParti;
@ -48,7 +49,8 @@ namespace EPAServeur.Tests.Services
entity.State = EntityState.Detached;
}
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");

Loading…
Cancel
Save