From ad15e84d51e2a83fe85d698d0b656e27cd4cfd9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yana=C3=ABl=20GRETTE?= Date: Wed, 24 Feb 2021 14:34:12 +0100 Subject: [PATCH] =?UTF-8?q?tests=20et=20impl=C3=A9mentation=20de=20la=20r?= =?UTF-8?q?=C3=A9cup=C3=A9ration=20de=20la=20liste=20des=20EP=20sign=C3=A9?= =?UTF-8?q?s=20d'un=20collaborateur=20et=20du=20prochain=20EP=20collaborat?= =?UTF-8?q?eur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/EpInformationTests.cs | 48 +++++++++++++++++++ EPAServeur/Context/DataSeeder.cs | 10 ++-- EPAServeur/Services/EpInformationService.cs | 11 ++++- 3 files changed, 62 insertions(+), 7 deletions(-) diff --git a/EPAServeur.Tests/Services/EpInformationTests.cs b/EPAServeur.Tests/Services/EpInformationTests.cs index eaea6ff..4a93043 100644 --- a/EPAServeur.Tests/Services/EpInformationTests.cs +++ b/EPAServeur.Tests/Services/EpInformationTests.cs @@ -503,6 +503,7 @@ namespace EPAServeur.Tests.Services [TestCase("3f276ab8-727a-4e26-ad5d-4d296158688e", 1)] [TestCase("01ee85ff-d7f3-494b-b1de-26ced8fbfa0d", 1)] [TestCase("eb8b0f33-f529-4985-861e-1207f3312bb5", 2)] + [TestCase("eb8b0f33-f529-4985-861e-1207f3312bb4", 0)] [TestCase("ea027734-ff0f-4308-8879-133a09fb3c46", 1)] [TestCase("80220063-a5fa-472b-b610-2e350566df98", 1)] public async Task GetEPCoursReferent(Guid idReferent, int count) @@ -526,6 +527,7 @@ namespace EPAServeur.Tests.Services [TestCase("eb8b0f33-f529-4985-861e-1207f3312bb5", 2)] [TestCase("d4fc247b-015a-44d6-8f3e-a52f0902d2bf", 1)] [TestCase("b799a9de-7743-435e-933f-7f730affc5ae", 1)] + [TestCase("b799a9de-7743-435e-933f-7f730affc5a5", 0)] [TestCase("ea027734-ff0f-4308-8879-133a09fb3c46", 1)] public async Task GetEPEnSignesReferent(Guid idReferent, int count) { @@ -541,6 +543,52 @@ namespace EPAServeur.Tests.Services } #endregion + #region Récupérés EP signés collaborateur + [TestCase("301ba7f3-095e-4912-8998-a7c942dc5f23", 1)] + [TestCase("4f3fcd23-a1e4-4c9e-afa2-d06ca9216491", 0)] + [TestCase("e7820f92-eab1-42f5-ae96-5c16e71ff1e6", 1)] + [TestCase("a0f40e2a-cc03-4032-a627-5389e1281c64", 3)] + [TestCase("b5254c6c-7caa-435f-a4bb-e0cf92559832", 1)] + [TestCase("b5254c6c-7caa-435f-a4bb-e0cf92559830", 0)] + [TestCase("13fbe621-1bc9-4f04-afde-b54ca076e239", 3)] + public async Task GetEPSignesCollaborateur(Guid idCollaborateur, int count) + { + IEpInformationService epInformationService = new EpInformationService(context, collaborateurService); + IEnumerable epInformationDTOs = await epInformationService.GetEPSignesCollaborateur(idCollaborateur); + Assert.AreEqual(count, epInformationDTOs.Count()); + foreach(EpInformationDTO ep in epInformationDTOs) + { + Assert.AreEqual(ep.Statut, StatutEp.Signe); + Assert.AreEqual(idCollaborateur, ep.Collaborateur.Id); + } + } + #endregion + + + #region Récupéré EP en cours d'un collaborateur + [TestCase("301ba7f3-095e-4912-8998-a7c942dc5f23", true)] + [TestCase("eb8b0f33-f529-4985-861e-1207f3312bb5", false)] + [TestCase("e7820f92-eab1-42f5-ae96-5c16e71ff1e6", true)] + [TestCase("a0f40e2a-cc03-4032-a627-5389e1281c64", true)] + [TestCase("b799a9de-7743-435e-933f-7f730affc5ae", false)] + [TestCase("de98a866-736f-4295-a669-92a8694e2ee3", true)] + public async Task GetEPEnCoursCollaborateur(Guid idCollaborateur, bool existe) + { + IEpInformationService epInformationService = new EpInformationService(context, collaborateurService); + EpInformationDTO epInformationDTO = await epInformationService.GetProchainEPCollaborateur(idCollaborateur); + if(existe) + { + Assert.IsNotNull(epInformationDTO); + Assert.IsTrue(EstEpEnCours(epInformationDTO.Statut)); + Assert.AreEqual(idCollaborateur, epInformationDTO.Collaborateur.Id); + } + else + { + Assert.IsNull(epInformationDTO); + } + + } + #endregion #region méthodes privées private bool EstEpEnCours(StatutEp statut) diff --git a/EPAServeur/Context/DataSeeder.cs b/EPAServeur/Context/DataSeeder.cs index 424d246..d7e8238 100644 --- a/EPAServeur/Context/DataSeeder.cs +++ b/EPAServeur/Context/DataSeeder.cs @@ -219,7 +219,7 @@ namespace EPAServeur.Context //Ep signés - Ep epSigne1, epSigne2, epSigne3, epSigne4, epSigne5, epSigne6, epSigne7, epSigne8, epSigne9, epSigne10, epSigne11, epSigne12, epSigne13, epSigne14; + Ep epSigne1, epSigne2, epSigne3, epSigne4, epSigne5, epSigne6, epSigne7, epSigne8, epSigne9;//, epSigne10, epSigne11, epSigne12, epSigne13, epSigne14; epSigne1 = new Ep() { DateDisponibilite = new DateTime(2017, 1, 15), @@ -286,7 +286,7 @@ namespace EPAServeur.Context Statut = StatutEp.Signe, IdBu = 2, IdReferent = new Guid("d4fc247b-015a-44d6-8f3e-a52f0902d2bf"), - IdCollaborateur = new Guid("17b87130-0e9d-4b78-b0e3-a11e5f70318d"), + IdCollaborateur = new Guid("a0f40e2a-cc03-4032-a627-5389e1281c64"), Obligatoire = true, }; epContext.Ep.Add(epSigne5); @@ -300,7 +300,7 @@ namespace EPAServeur.Context Statut = StatutEp.Signe, IdBu = 2, IdReferent = new Guid("eb8b0f33-f529-4985-861e-1207f3312bb5"), - IdCollaborateur = new Guid("de98a866-736f-4295-a669-92a8694e2ee3"), + IdCollaborateur = new Guid("a0f40e2a-cc03-4032-a627-5389e1281c64"), Obligatoire = false, }; epContext.Ep.Add(epSigne6); @@ -314,7 +314,7 @@ namespace EPAServeur.Context Statut = StatutEp.Signe, IdBu = 3, IdReferent = new Guid("b799a9de-7743-435e-933f-7f730affc5ae"), - IdCollaborateur = new Guid("4f3fcd23-a1e4-4c9e-afa2-d06ca9216491"), + IdCollaborateur = new Guid("13fbe621-1bc9-4f04-afde-b54ca076e239"), Obligatoire = false, }; epContext.Ep.Add(epSigne7); @@ -328,7 +328,7 @@ namespace EPAServeur.Context Statut = StatutEp.Signe, IdBu = 3, IdReferent = new Guid("ea027734-ff0f-4308-8879-133a09fb3c46"), - IdCollaborateur = new Guid("0968ccd3-1ef5-4041-83f3-1c76afb02bbf"), + IdCollaborateur = new Guid("13fbe621-1bc9-4f04-afde-b54ca076e239"), Obligatoire = true, }; epContext.Ep.Add(epSigne8); diff --git a/EPAServeur/Services/EpInformationService.cs b/EPAServeur/Services/EpInformationService.cs index c0cdc1b..b2ea22c 100644 --- a/EPAServeur/Services/EpInformationService.cs +++ b/EPAServeur/Services/EpInformationService.cs @@ -75,7 +75,9 @@ namespace EPAServeur.Services public async Task> GetEPSignesCollaborateur(Guid? idCollaborateur) { - throw new NotImplementedException(); + IEnumerable eps = context.Ep.Where(ep => ep.IdCollaborateur.Equals(idCollaborateur)).Where(ep => ep.Statut.Equals(StatutEp.Signe)); + + return await GetEpInformationDTOs(eps, true, 1, maxParPage, "", "", null, null); } public async Task GetEPSignesCount(List idBUs, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) @@ -99,7 +101,12 @@ namespace EPAServeur.Services public async Task GetProchainEPCollaborateur(Guid? idCollaborateur) { - throw new NotImplementedException(); + Ep ep = context.Ep.Where(ep => ep.IdCollaborateur.Equals(idCollaborateur)).OrderBy(ep => ep.DateDisponibilite).AsEnumerable().Where(ep => EstEpEnCours(ep.Statut)).FirstOrDefault(); + if (ep == null) + return null; + IEnumerable collaborateurDTOs = await collaborateurService.GetCollaborateurDTOsAsync(new List() { ep.IdReferent, ep.IdCollaborateur }); + return EpToEpDTO(ep, collaborateurDTOs); + } #endregion