tests et implémentation de la récupération de la liste des EP signés d'un collaborateur et du prochain EP collaborateur

develop
Yanaël GRETTE 4 years ago
parent 586702001f
commit ad15e84d51
  1. 48
      EPAServeur.Tests/Services/EpInformationTests.cs
  2. 10
      EPAServeur/Context/DataSeeder.cs
  3. 11
      EPAServeur/Services/EpInformationService.cs

@ -503,6 +503,7 @@ namespace EPAServeur.Tests.Services
[TestCase("3f276ab8-727a-4e26-ad5d-4d296158688e", 1)] [TestCase("3f276ab8-727a-4e26-ad5d-4d296158688e", 1)]
[TestCase("01ee85ff-d7f3-494b-b1de-26ced8fbfa0d", 1)] [TestCase("01ee85ff-d7f3-494b-b1de-26ced8fbfa0d", 1)]
[TestCase("eb8b0f33-f529-4985-861e-1207f3312bb5", 2)] [TestCase("eb8b0f33-f529-4985-861e-1207f3312bb5", 2)]
[TestCase("eb8b0f33-f529-4985-861e-1207f3312bb4", 0)]
[TestCase("ea027734-ff0f-4308-8879-133a09fb3c46", 1)] [TestCase("ea027734-ff0f-4308-8879-133a09fb3c46", 1)]
[TestCase("80220063-a5fa-472b-b610-2e350566df98", 1)] [TestCase("80220063-a5fa-472b-b610-2e350566df98", 1)]
public async Task GetEPCoursReferent(Guid idReferent, int count) public async Task GetEPCoursReferent(Guid idReferent, int count)
@ -526,6 +527,7 @@ namespace EPAServeur.Tests.Services
[TestCase("eb8b0f33-f529-4985-861e-1207f3312bb5", 2)] [TestCase("eb8b0f33-f529-4985-861e-1207f3312bb5", 2)]
[TestCase("d4fc247b-015a-44d6-8f3e-a52f0902d2bf", 1)] [TestCase("d4fc247b-015a-44d6-8f3e-a52f0902d2bf", 1)]
[TestCase("b799a9de-7743-435e-933f-7f730affc5ae", 1)] [TestCase("b799a9de-7743-435e-933f-7f730affc5ae", 1)]
[TestCase("b799a9de-7743-435e-933f-7f730affc5a5", 0)]
[TestCase("ea027734-ff0f-4308-8879-133a09fb3c46", 1)] [TestCase("ea027734-ff0f-4308-8879-133a09fb3c46", 1)]
public async Task GetEPEnSignesReferent(Guid idReferent, int count) public async Task GetEPEnSignesReferent(Guid idReferent, int count)
{ {
@ -541,6 +543,52 @@ namespace EPAServeur.Tests.Services
} }
#endregion #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<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignesCollaborateur(idCollaborateur);
Assert.AreEqual(count, epInformationDTOs.Count());
foreach(EpInformationDTO ep in epInformationDTOs)
{
Assert.AreEqual(ep.Statut, StatutEp.Signe);
Assert.AreEqual(idCollaborateur, ep.Collaborateur.Id);
}
}
#endregion
#region Récupéré EP en cours d'un collaborateur
[TestCase("301ba7f3-095e-4912-8998-a7c942dc5f23", true)]
[TestCase("eb8b0f33-f529-4985-861e-1207f3312bb5", false)]
[TestCase("e7820f92-eab1-42f5-ae96-5c16e71ff1e6", true)]
[TestCase("a0f40e2a-cc03-4032-a627-5389e1281c64", true)]
[TestCase("b799a9de-7743-435e-933f-7f730affc5ae", false)]
[TestCase("de98a866-736f-4295-a669-92a8694e2ee3", true)]
public async Task GetEPEnCoursCollaborateur(Guid idCollaborateur, bool existe)
{
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService);
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 #region méthodes privées
private bool EstEpEnCours(StatutEp statut) private bool EstEpEnCours(StatutEp statut)

@ -219,7 +219,7 @@ namespace EPAServeur.Context
//Ep signés //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() epSigne1 = new Ep()
{ {
DateDisponibilite = new DateTime(2017, 1, 15), DateDisponibilite = new DateTime(2017, 1, 15),
@ -286,7 +286,7 @@ namespace EPAServeur.Context
Statut = StatutEp.Signe, Statut = StatutEp.Signe,
IdBu = 2, IdBu = 2,
IdReferent = new Guid("d4fc247b-015a-44d6-8f3e-a52f0902d2bf"), 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, Obligatoire = true,
}; };
epContext.Ep.Add(epSigne5); epContext.Ep.Add(epSigne5);
@ -300,7 +300,7 @@ namespace EPAServeur.Context
Statut = StatutEp.Signe, Statut = StatutEp.Signe,
IdBu = 2, IdBu = 2,
IdReferent = new Guid("eb8b0f33-f529-4985-861e-1207f3312bb5"), 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, Obligatoire = false,
}; };
epContext.Ep.Add(epSigne6); epContext.Ep.Add(epSigne6);
@ -314,7 +314,7 @@ namespace EPAServeur.Context
Statut = StatutEp.Signe, Statut = StatutEp.Signe,
IdBu = 3, IdBu = 3,
IdReferent = new Guid("b799a9de-7743-435e-933f-7f730affc5ae"), 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, Obligatoire = false,
}; };
epContext.Ep.Add(epSigne7); epContext.Ep.Add(epSigne7);
@ -328,7 +328,7 @@ namespace EPAServeur.Context
Statut = StatutEp.Signe, Statut = StatutEp.Signe,
IdBu = 3, IdBu = 3,
IdReferent = new Guid("ea027734-ff0f-4308-8879-133a09fb3c46"), 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, Obligatoire = true,
}; };
epContext.Ep.Add(epSigne8); epContext.Ep.Add(epSigne8);

@ -75,7 +75,9 @@ namespace EPAServeur.Services
public async Task<IEnumerable<EpInformationDTO>> GetEPSignesCollaborateur(Guid? idCollaborateur) public async Task<IEnumerable<EpInformationDTO>> GetEPSignesCollaborateur(Guid? idCollaborateur)
{ {
throw new NotImplementedException(); IEnumerable<Ep> 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<int> GetEPSignesCount(List<long?> idBUs, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) public async Task<int> GetEPSignesCount(List<long?> 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<EpInformationDTO> GetProchainEPCollaborateur(Guid? idCollaborateur) public async Task<EpInformationDTO> 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<CollaborateurDTO> collaborateurDTOs = await collaborateurService.GetCollaborateurDTOsAsync(new List<Guid?>() { ep.IdReferent, ep.IdCollaborateur });
return EpToEpDTO(ep, collaborateurDTOs);
} }
#endregion #endregion

Loading…
Cancel
Save