|
|
@ -38,7 +38,7 @@ namespace EPAServeur.Tests.Services |
|
|
|
context.SaveChanges(); |
|
|
|
context.SaveChanges(); |
|
|
|
|
|
|
|
|
|
|
|
// Ajout du jeu de données pour les tests |
|
|
|
// Ajout du jeu de données pour les tests |
|
|
|
DataSeeder.AddNotes(context); |
|
|
|
DataSeeder.AddRereferentEP(context); |
|
|
|
|
|
|
|
|
|
|
|
// Détache les entités du context car la base de données InMemory créé des conflits |
|
|
|
// Détache les entités du context car la base de données InMemory créé des conflits |
|
|
|
// entre les clés primaires lors d'un Update ou d'un Insert |
|
|
|
// entre les clés primaires lors d'un Update ou d'un Insert |
|
|
@ -340,7 +340,93 @@ namespace EPAServeur.Tests.Services |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion |
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region GetCollaborateurs par referent |
|
|
|
|
|
|
|
[TestCase("aa36f34c-9041-42f5-9db3-6536fe7f1696")] |
|
|
|
|
|
|
|
[TestCase("01ee85ff-d7f3-494b-b1de-26ced8fbfa0d")] |
|
|
|
|
|
|
|
[TestCase("e7820f92-eab1-42f5-ae96-5c16e71ff1e6")] |
|
|
|
|
|
|
|
[TestCase("de98a866-736f-4295-a669-92a8694e2ee3")] |
|
|
|
|
|
|
|
[TestCase("642bc07f-051a-4088-8a73-425b44998673")] |
|
|
|
|
|
|
|
public async Task GetCollaborateurByReferentPlusCount(Guid idReferent) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); |
|
|
|
|
|
|
|
IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateursByReferentAsync(idReferent, true, 1, 15, "", ""); |
|
|
|
|
|
|
|
int count = await collaborateurService.GetCollaborateursCountByReferentAsync(idReferent, ""); |
|
|
|
|
|
|
|
Assert.AreEqual(count, collaborateurs.Count()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[TestCase("8a68e248-65f8-11eb-ae93-0242ac130002")] |
|
|
|
|
|
|
|
[TestCase("c43a975f-2b83-423b-96e5-ff98c6bd5bd3")] |
|
|
|
|
|
|
|
[TestCase("e6b66b62-9ddb-423e-8f58-0a647514ecfe")] |
|
|
|
|
|
|
|
[TestCase("ca1f480a-9918-4cea-819c-62e5c7f2b332")] |
|
|
|
|
|
|
|
public void GetCollaborateurByReferent_ReferentNotFound(Guid idReferent) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); |
|
|
|
|
|
|
|
AsyncTestDelegate exception = () => collaborateurService.GetCollaborateursByReferentAsync(idReferent, true, 1, 15, "", ""); |
|
|
|
|
|
|
|
Assert.ThrowsAsync(typeof(ReferentNotFoundException), exception); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region GetCollaborateurs by guids |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
|
public async Task GetCollaborateurByGuids() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); |
|
|
|
|
|
|
|
List<Guid?> guids = new List<Guid?>(); |
|
|
|
|
|
|
|
guids.Add(new Guid("ebd911ef-a6a8-4047-afdc-9a9066aa1a07")); |
|
|
|
|
|
|
|
guids.Add(new Guid("71d33f6d-695a-4dc6-ae1a-b1605fd2073d")); |
|
|
|
|
|
|
|
guids.Add(new Guid("56e3d82d-4be4-4449-a1f7-b4004b6bd186")); |
|
|
|
|
|
|
|
guids.Add(new Guid("a43b6f4f-f199-4dd0-93b6-a1cb2c0a0d14")); |
|
|
|
|
|
|
|
guids.Add(new Guid("a0f40e2a-cc03-4032-a627-5389e1281c64")); |
|
|
|
|
|
|
|
guids.Add(new Guid("a29d707c-5d82-4c48-bed1-a6d1c1710047")); |
|
|
|
|
|
|
|
IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateurDTOsAsync(guids); |
|
|
|
|
|
|
|
foreach(CollaborateurDTO c in collaborateurs) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Assert.IsTrue(guids.Contains(c.Id)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Assert.AreEqual(guids.Count, collaborateurs.Count()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
|
public async Task GetCollaborateurByGuidsAvecIdsNonExistantEnPlus() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); |
|
|
|
|
|
|
|
List<Guid?> guids = new List<Guid?>(); |
|
|
|
|
|
|
|
guids.Add(new Guid("b645f582-0a5d-48dc-97a1-4ebb0fb3a29f")); |
|
|
|
|
|
|
|
guids.Add(new Guid()); |
|
|
|
|
|
|
|
guids.Add(new Guid("f42f65cb-dcc1-407f-a048-f67efbe88d65")); |
|
|
|
|
|
|
|
guids.Add(new Guid("e634de52-d921-4ae8-954d-215f39712041")); |
|
|
|
|
|
|
|
guids.Add(new Guid("ad63ff07-6dae-4b02-8d49-1cacf1e8a224")); |
|
|
|
|
|
|
|
guids.Add(new Guid("25d2b0ce-5c95-4ccc-98bb-63b06c4ee4ad")); |
|
|
|
|
|
|
|
guids.Add(new Guid()); |
|
|
|
|
|
|
|
IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateurDTOsAsync(guids); |
|
|
|
|
|
|
|
foreach (CollaborateurDTO c in collaborateurs) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Assert.IsTrue(guids.Contains(c.Id)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Assert.AreEqual(guids.Count, collaborateurs.Count()+2); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
|
public async Task GetCollaborateurByGuidsAvecIdsNonExistantUniquement() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ICollaborateurService collaborateurService = new CollaborateurService(collaborateurApi, context); |
|
|
|
|
|
|
|
List<Guid?> guids = new List<Guid?>(); |
|
|
|
|
|
|
|
guids.Add(new Guid()); |
|
|
|
|
|
|
|
guids.Add(new Guid()); |
|
|
|
|
|
|
|
guids.Add(new Guid()); |
|
|
|
|
|
|
|
guids.Add(new Guid()); |
|
|
|
|
|
|
|
guids.Add(new Guid()); |
|
|
|
|
|
|
|
guids.Add(new Guid()); |
|
|
|
|
|
|
|
IEnumerable<CollaborateurDTO> collaborateurs = await collaborateurService.GetCollaborateurDTOsAsync(guids); |
|
|
|
|
|
|
|
Assert.AreNotEqual(guids.Count, collaborateurs.Count()); |
|
|
|
|
|
|
|
Assert.AreEqual(0, collaborateurs.Count()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|