|
|
@ -101,11 +101,11 @@ namespace EPAServeur.Tests.Services |
|
|
|
|
|
|
|
|
|
|
|
#region Tests GetCollaborateurs Roles |
|
|
|
#region Tests GetCollaborateurs Roles |
|
|
|
|
|
|
|
|
|
|
|
[TestCase("RH")] //9 |
|
|
|
[TestCase("RH")] |
|
|
|
[TestCase("Collaborateur")] //7 |
|
|
|
[TestCase("Collaborateur")] |
|
|
|
[TestCase("Assistant")] //6 |
|
|
|
[TestCase("Assistant")] |
|
|
|
[TestCase("Manager")]//10 |
|
|
|
[TestCase("Manager")] |
|
|
|
[TestCase("RA")]//5 |
|
|
|
[TestCase("RA")] |
|
|
|
public async Task GetCollaborateurs_UnRole(string role) |
|
|
|
public async Task GetCollaborateurs_UnRole(string role) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); |
|
|
|
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); |
|
|
@ -170,5 +170,177 @@ namespace EPAServeur.Tests.Services |
|
|
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Test GetCollaborateurs Tri et Pagination |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
|
public async Task GetCollaborateurs_Asc_Desc() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); |
|
|
|
|
|
|
|
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(); |
|
|
|
|
|
|
|
CollaborateurDTO collaborateurDTLastAsc = collaborateursAsc.Last(); |
|
|
|
|
|
|
|
CollaborateurDTO collaborateurDTOFirstDesc = collaborateursDesc.First(); |
|
|
|
|
|
|
|
CollaborateurDTO collaborateurDTLastDesc = collaborateursDesc.Last(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(collaborateurDTOFirstAsc.Id, collaborateurDTLastDesc.Id); |
|
|
|
|
|
|
|
Assert.AreEqual(collaborateurDTLastAsc.Id, collaborateurDTOFirstDesc.Id); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[TestCase("ma")] |
|
|
|
|
|
|
|
[TestCase("z")] |
|
|
|
|
|
|
|
[TestCase("em")] |
|
|
|
|
|
|
|
[TestCase("")] |
|
|
|
|
|
|
|
public async Task GetCollaborateurs_Texte(string texte) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); |
|
|
|
|
|
|
|
IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursAsync(null, null, true, 1, 50, texte, "", null, null); |
|
|
|
|
|
|
|
string nomprenom, prenomnom; |
|
|
|
|
|
|
|
foreach(CollaborateurDTO collaborateur in collaborateurs) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
nomprenom = collaborateur.Nom.ToLower() + " " + collaborateur.Prenom.ToLower(); |
|
|
|
|
|
|
|
prenomnom = collaborateur.Prenom.ToLower() + " " + collaborateur.Nom.ToLower(); |
|
|
|
|
|
|
|
Assert.IsTrue(nomprenom.Contains(texte) || prenomnom.Contains(texte)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[TestCase(2015,1,1)] |
|
|
|
|
|
|
|
[TestCase(2016,1,1)] |
|
|
|
|
|
|
|
[TestCase(2017,1,1)] |
|
|
|
|
|
|
|
[TestCase(2018,1,1)] |
|
|
|
|
|
|
|
public async Task GetCollaborateurs_DateDebut(int annee, int mois, int jour) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); |
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Assert.IsTrue(collaborateur.DateArrivee >= dateDebut); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[TestCase(2020, 12, 31)] |
|
|
|
|
|
|
|
[TestCase(2019, 12, 31)] |
|
|
|
|
|
|
|
[TestCase(2018, 12, 31)] |
|
|
|
|
|
|
|
[TestCase(2017, 12, 31)] |
|
|
|
|
|
|
|
public async Task GetCollaborateurs_DateFin(int annee, int mois, int jour) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); |
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Assert.IsTrue(collaborateur.DateArrivee < dateFin); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[TestCase(2016,1,1,2018,12,31)] |
|
|
|
|
|
|
|
[TestCase(2017,6,1,2017,6,30)] |
|
|
|
|
|
|
|
[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); |
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Assert.IsTrue(collaborateur.DateArrivee >= dateDebut && collaborateur.DateArrivee < dateFin); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[TestCase(1,15)] |
|
|
|
|
|
|
|
[TestCase(4,5)] |
|
|
|
|
|
|
|
[TestCase(2,15)] |
|
|
|
|
|
|
|
[TestCase(1,20)] |
|
|
|
|
|
|
|
[TestCase(1,37)] |
|
|
|
|
|
|
|
public async Task GetCollaborateur_Paginaion(int numPage, int parPage) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); |
|
|
|
|
|
|
|
IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursAsync(null, null, true, numPage, parPage, "", "", null, null); |
|
|
|
|
|
|
|
Assert.AreEqual(collaborateurs.Count(), parPage); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[TestCase(2, 37, 0)] |
|
|
|
|
|
|
|
[TestCase(3, 15, 7)] |
|
|
|
|
|
|
|
[TestCase(8, 5, 2)] |
|
|
|
|
|
|
|
public async Task GetCollaborateur_Paginaion_2(int numPage, int parPage, int res) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); |
|
|
|
|
|
|
|
IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursAsync(null, null, true, numPage, parPage, "", "", null, null); |
|
|
|
|
|
|
|
Assert.AreEqual(collaborateurs.Count(), res); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[TestCase(0, 4)] |
|
|
|
|
|
|
|
[TestCase(-1, 0)] |
|
|
|
|
|
|
|
[TestCase(-10, -10)] |
|
|
|
|
|
|
|
[TestCase(-10, 20)] |
|
|
|
|
|
|
|
[TestCase(-1, 37)] |
|
|
|
|
|
|
|
public async Task GetCollaborateur_PaginaionValeursParDefaut(int numPage, int parPage) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); |
|
|
|
|
|
|
|
IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursAsync(null, null, true, numPage, parPage, "", "", null, null); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(parPage < 5) |
|
|
|
|
|
|
|
Assert.AreEqual(collaborateurs.Count(), 15); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
Assert.AreEqual(collaborateurs.Count(), parPage); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
|
public async Task GetCollaborateur_OrderByDateArrive() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); |
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
d1 = collaborateurs.ElementAt(i).DateArrivee.Value; |
|
|
|
|
|
|
|
d2 = collaborateurs.ElementAt(i+1).DateArrivee.Value; |
|
|
|
|
|
|
|
Assert.AreEqual(DateTime.Compare(d1, d2),-1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
|
public async Task GetCollaborateur_OrderByBU() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); |
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bu1 = collaborateurs.ElementAt(i).BusinessUnit.Nom; |
|
|
|
|
|
|
|
bu2 = collaborateurs.ElementAt(i + 1).BusinessUnit.Nom; |
|
|
|
|
|
|
|
Console.WriteLine(bu1 + " " + bu2); |
|
|
|
|
|
|
|
Assert.IsTrue(string.Compare(bu1, bu2) <= 0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
|
public async Task GetCollaborateur_OrderByNom() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); |
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
nom1 = collaborateurs.ElementAt(i).Nom; |
|
|
|
|
|
|
|
nom2 = collaborateurs.ElementAt(i+1).Nom; |
|
|
|
|
|
|
|
Assert.IsTrue(string.Compare(nom1, nom2) <= 0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|