From b0bc3d9d5f288d806d47b1cdffa2415305e7e1ed Mon Sep 17 00:00:00 2001 From: jboinembalome Date: Mon, 15 Mar 2021 10:45:10 +0100 Subject: [PATCH] =?UTF-8?q?Mise=20=C3=A0=20jour=20des=20tests=20unitaires?= =?UTF-8?q?=20en=20fonction=20du=20param=C3=A8tres=20statutsEp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/DemandeFormationApiTests.cs | 10 +-- .../Services/DemandeFormationServiceTests.cs | 68 ++++++++++--------- 2 files changed, 42 insertions(+), 36 deletions(-) diff --git a/EPAServeur.Tests/Controllers/DemandeFormationApiTests.cs b/EPAServeur.Tests/Controllers/DemandeFormationApiTests.cs index 85eace0..37f1911 100644 --- a/EPAServeur.Tests/Controllers/DemandeFormationApiTests.cs +++ b/EPAServeur.Tests/Controllers/DemandeFormationApiTests.cs @@ -93,7 +93,7 @@ namespace EPAServeur.Tests.Controllers DemandesFormationApiController DemandesFormationApiController = new DemandesFormationApiController(demandeFormationService, new NullLogger(), mockEnvironment.Object); // Act - var okResult = DemandesFormationApiController.GetDemandesFormation(null, null, null, null, null, null, null, null, null); + var okResult = DemandesFormationApiController.GetDemandesFormation(null, null, null, null, null, null, null, null, null, null); // Assert Assert.IsInstanceOf(okResult.Result); @@ -109,7 +109,7 @@ namespace EPAServeur.Tests.Controllers int idLastDemandeFormation = 3; // Act - var okResult = DemandesFormationApiController.GetDemandesFormation(null, null, null, 1, 5, null, null, null, null).Result as OkObjectResult; + var okResult = DemandesFormationApiController.GetDemandesFormation(null, null, null, null, 1, 5, null, null, null, null).Result as OkObjectResult; // Assert Assert.IsInstanceOf>(okResult.Value); @@ -129,7 +129,7 @@ namespace EPAServeur.Tests.Controllers DemandesFormationApiController DemandesFormationApiController = new DemandesFormationApiController(demandeFormationService, new NullLogger(), mockEnvironment.Object); // Act - var okResult = DemandesFormationApiController.GetDemandesFormationCount(null, null, null, null, null); + var okResult = DemandesFormationApiController.GetDemandesFormationCount(null, null, null, null, null, null); // Assert Assert.IsInstanceOf(okResult.Result); @@ -140,10 +140,10 @@ namespace EPAServeur.Tests.Controllers { // Arrange DemandesFormationApiController DemandesFormationApiController = new DemandesFormationApiController(demandeFormationService, new NullLogger(), mockEnvironment.Object); - int nbDemandeFormation = 10; + int nbDemandeFormation = 12; // Act - var okResult = DemandesFormationApiController.GetDemandesFormationCount(null, null, null, null, null).Result as OkObjectResult; + var okResult = DemandesFormationApiController.GetDemandesFormationCount(null, null, null, null, null, null).Result as OkObjectResult; // Assert Assert.IsInstanceOf(okResult.Value); diff --git a/EPAServeur.Tests/Services/DemandeFormationServiceTests.cs b/EPAServeur.Tests/Services/DemandeFormationServiceTests.cs index eac801e..ca68862 100644 --- a/EPAServeur.Tests/Services/DemandeFormationServiceTests.cs +++ b/EPAServeur.Tests/Services/DemandeFormationServiceTests.cs @@ -61,18 +61,19 @@ namespace EPAServeur.Tests.Services #region Tests GetDemandesFormationAsync - [TestCase(new EtatDemande[] { EtatDemande.EnAttente, EtatDemande.Validee, EtatDemande.Rejetee }, new long[] { 1, 2 }, true, 1, 20, "gaillard", null, null, null)] - [TestCase(new EtatDemande[] { EtatDemande.EnAttente, EtatDemande.Validee, EtatDemande.Rejetee }, new long[] { 1 }, false, 1, 5, "gaillard", null, null, null)] - [TestCase(null, null, null, 2, 5, null, null, null, null)] - [TestCase(null, new long[] { 1 }, null, 1, 10, null, null, null, null)] - [TestCase(new EtatDemande[] { EtatDemande.Rejetee }, null, null, 1, 10, "gai", null, null, null)] - [TestCase(new EtatDemande[] { EtatDemande.EnAttente, EtatDemande.Validee, EtatDemande.Rejetee }, new long[] { }, null, 1, 50, "gai", null, null, null)] - public async Task GetDemandesFormationAsync_PasseDesParamsValides_RetourneDesDemandesDeFormations(EtatDemande[] arrEtatDemandes, long[] arrIdBUs, bool? asc, int? numPage, int? parPAge, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) + [TestCase(new EtatDemande[] { EtatDemande.EnAttente, EtatDemande.Validee, EtatDemande.Rejetee }, new long[] { 1, 2 }, new StatutEp[] { StatutEp.Signe, StatutEp.SignatureReferent }, true, 1, 20, "gaillard", null, null, null)] + [TestCase(new EtatDemande[] { EtatDemande.EnAttente, EtatDemande.Validee, EtatDemande.Rejetee }, new long[] { 1 }, new StatutEp[] { StatutEp.Signe, StatutEp.SignatureReferent }, false, 1, 5, "gaillard", null, null, null)] + [TestCase(null, null, null, null, 2, 5, null, null, null, null)] + [TestCase(null, new long[] { 1 }, null, null, 1, 10, null, null, null, null)] + [TestCase(new EtatDemande[] { EtatDemande.Rejetee }, null, null, null, 1, 10, "gai", null, null, null)] + [TestCase(new EtatDemande[] { EtatDemande.EnAttente, EtatDemande.Validee, EtatDemande.Rejetee }, new long[] { }, new StatutEp[] { StatutEp.Signe, StatutEp.SignatureReferent }, null, 1, 50, "gai", null, null, null)] + public async Task GetDemandesFormationAsync_PasseDesParamsValides_RetourneDesDemandesDeFormations(EtatDemande[] arrEtatDemandes, long[] arrIdBUs, StatutEp[] arrStatutsEp, bool? asc, int? numPage, int? parPAge, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) { // Arrange DemandeFormationService demandeFormationService = new DemandeFormationService(epContext, collaborateurService, transformDTO); List idBUs; List etatDemandes; + List statutsEp; if (arrEtatDemandes != null) etatDemandes = arrEtatDemandes.ToList(); @@ -84,8 +85,13 @@ namespace EPAServeur.Tests.Services else idBUs = null; + if (arrStatutsEp != null) + statutsEp = arrStatutsEp.ToList(); + else + statutsEp = null; + // Act - IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(etatDemandes, idBUs, asc, numPage, parPAge, texte, tri, dateDebut, dateFin); + IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(etatDemandes, idBUs, statutsEp, asc, numPage, parPAge, texte, tri, dateDebut, dateFin); // Assert Assert.Less(0, demandeFormationDTOs.Count()); @@ -99,7 +105,7 @@ namespace EPAServeur.Tests.Services DemandeFormationService demandeFormationService = new DemandeFormationService(epContext, collaborateurService, transformDTO); // Act - IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, null, numPage, parPage, null, null, null, null); + IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, null, null, numPage, parPage, null, null, null, null); // Assert Assert.AreEqual(parPage, demandeFormationDTOs.Count()); @@ -121,10 +127,10 @@ namespace EPAServeur.Tests.Services nbDemandeFormationDeuxiemePage = 5; break; case 6: - nbDemandeFormationDeuxiemePage = 4; + nbDemandeFormationDeuxiemePage = 6; break; case 10: - nbDemandeFormationDeuxiemePage = 0; + nbDemandeFormationDeuxiemePage = 2; break; default: nbDemandeFormationDeuxiemePage = 0; @@ -132,7 +138,7 @@ namespace EPAServeur.Tests.Services } // Act - IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, null, numPage, parPage, null, null, null, null); + IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, null, null, numPage, parPage, null, null, null, null); // Assert Assert.AreEqual(nbDemandeFormationDeuxiemePage, demandeFormationDTOs.Count()); @@ -145,7 +151,7 @@ namespace EPAServeur.Tests.Services DemandeFormationService demandeFormationService = new DemandeFormationService(epContext, collaborateurService, transformDTO); // Act - IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, asc, null, null, null, tri, null, null); + IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, null, asc, null, null, null, tri, null, null); // Assert Assert.AreEqual("Orléans", demandeFormationDTOs.First().Collaborateur.BusinessUnit.Nom); @@ -159,7 +165,7 @@ namespace EPAServeur.Tests.Services DemandeFormationService demandeFormationService = new DemandeFormationService(epContext, collaborateurService, transformDTO); // Act - IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, asc, null, null, null, tri, null, null); + IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, null, asc, null, null, null, tri, null, null); // Assert Assert.AreEqual("Tours", demandeFormationDTOs.First().Collaborateur.BusinessUnit.Nom); @@ -176,7 +182,7 @@ namespace EPAServeur.Tests.Services DemandeFormationService demandeFormationService = new DemandeFormationService(epContext, collaborateurService, transformDTO); // Act - IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, asc, null, null, null, tri, null, null); + IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, null, asc, null, null, null, tri, null, null); // Assert Assert.AreEqual("Gaillard", demandeFormationDTOs.First().Collaborateur.Nom); @@ -193,7 +199,7 @@ namespace EPAServeur.Tests.Services DemandeFormationService demandeFormationService = new DemandeFormationService(epContext, collaborateurService, transformDTO); // Act - IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, asc, null, null, null, tri, null, null); + IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, null, asc, null, null, null, tri, null, null); // Assert Assert.AreEqual("Vasseur", demandeFormationDTOs.First().Collaborateur.Nom); @@ -208,7 +214,7 @@ namespace EPAServeur.Tests.Services DemandeFormationService demandeFormationService = new DemandeFormationService(epContext, collaborateurService, transformDTO); // Act - IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, asc, null, null, null, tri, null, null); + IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, null, asc, null, null, null, tri, null, null); // Assert Assert.AreEqual(new DateTime(2020, 1, 22, 9, 0, 0), demandeFormationDTOs.First().DateDemande); @@ -222,7 +228,7 @@ namespace EPAServeur.Tests.Services DemandeFormationService demandeFormationService = new DemandeFormationService(epContext, collaborateurService, transformDTO); // Act - IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, asc, null, null, null, tri, null, null); + IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, null, asc, null, null, null, tri, null, null); // Assert Assert.AreEqual(new DateTime(2020, 12, 22, 9, 0, 0), demandeFormationDTOs.First().DateDemande); @@ -236,7 +242,7 @@ namespace EPAServeur.Tests.Services DemandeFormationService demandeFormationService = new DemandeFormationService(epContext, collaborateurService, transformDTO); // Act - IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, asc, null, null, null, tri, null, null); + IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, null, asc, null, null, null, tri, null, null); // Assert Assert.IsFalse(demandeFormationDTOs.First().DemandeRH); @@ -250,7 +256,7 @@ namespace EPAServeur.Tests.Services DemandeFormationService demandeFormationService = new DemandeFormationService(epContext, collaborateurService, transformDTO); // Act - IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, asc, null, null, null, tri, null, null); + IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, null, asc, null, null, null, tri, null, null); // Assert Assert.IsTrue(demandeFormationDTOs.First().DemandeRH); @@ -264,7 +270,7 @@ namespace EPAServeur.Tests.Services DemandeFormationService demandeFormationService = new DemandeFormationService(epContext, collaborateurService, transformDTO); // Act - IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, asc, null, null, null, tri, null, null); + IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, null, asc, null, null, null, tri, null, null); // Assert Assert.AreEqual(EtatDemande.EnAttente, demandeFormationDTOs.First().EtatDemande); @@ -278,7 +284,7 @@ namespace EPAServeur.Tests.Services DemandeFormationService demandeFormationService = new DemandeFormationService(epContext, collaborateurService, transformDTO); // Act - IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, asc, null, null, null, tri, null, null); + IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, null, asc, null, null, null, tri, null, null); // Assert Assert.AreEqual(EtatDemande.Rejetee, demandeFormationDTOs.First().EtatDemande); @@ -293,7 +299,7 @@ namespace EPAServeur.Tests.Services DemandeFormationService demandeFormationService = new DemandeFormationService(epContext, collaborateurService, transformDTO); // Act - IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, asc, null, null, null, tri, null, null); + IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, null, asc, null, null, null, tri, null, null); // Assert Assert.IsNull(demandeFormationDTOs.First().DateDerniereReponse); @@ -307,7 +313,7 @@ namespace EPAServeur.Tests.Services DemandeFormationService demandeFormationService = new DemandeFormationService(epContext, collaborateurService, transformDTO); // Act - IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, asc, null, null, null, tri, null, null); + IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, null, asc, null, null, null, tri, null, null); // Assert Assert.AreEqual(new DateTime(2020, 12, 27, 9, 0, 0), demandeFormationDTOs.First().DateDerniereReponse); @@ -321,7 +327,7 @@ namespace EPAServeur.Tests.Services DemandeFormationService demandeFormationService = new DemandeFormationService(epContext, collaborateurService, transformDTO); // Act - IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, null, null, null, null, null, dateDebut, null); + IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, null, null, null, null, null, null, dateDebut, null); // Assert Assert.IsTrue(demandeFormationDTOs.Any(d => d.DateDemande >= dateDebut)); @@ -334,7 +340,7 @@ namespace EPAServeur.Tests.Services DemandeFormationService demandeFormationService = new DemandeFormationService(epContext, collaborateurService, transformDTO); // Act - IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, null, null, null, null, null, null, dateFin); + IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, null, null, null, null, null, null, null, dateFin); // Assert Assert.IsTrue(demandeFormationDTOs.Any(d => d.DateDemande <= dateFin)); @@ -347,7 +353,7 @@ namespace EPAServeur.Tests.Services DemandeFormationService demandeFormationService = new DemandeFormationService(epContext, collaborateurService, transformDTO); // Act - IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, null, null, null, null, null, dateDebut, dateFin); + IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, null, null, null, null, null, null, dateDebut, dateFin); // Assert Assert.IsTrue(demandeFormationDTOs.Any(d => d.DateDemande >= dateDebut && d.DateDemande <= dateFin)); @@ -360,7 +366,7 @@ namespace EPAServeur.Tests.Services DemandeFormationService demandeFormationService = new DemandeFormationService(epContext, collaborateurService, transformDTO); // Act - IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, null, null, null, null, null, dateDebut, dateFin); + IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, null, null, null, null, null, null, null, dateDebut, dateFin); // Assert Assert.Zero(demandeFormationDTOs.Count()); @@ -382,7 +388,7 @@ namespace EPAServeur.Tests.Services idBUs = null; // Act - IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, idBUs, null, null, null, texte, null, dateDebut, dateFin); + IEnumerable demandeFormationDTOs = await demandeFormationService.GetDemandesFormationAsync(null, idBUs, null, null, null, null, texte, null, dateDebut, dateFin); // Assert Assert.Zero(demandeFormationDTOs.Count()); @@ -411,7 +417,7 @@ namespace EPAServeur.Tests.Services idBUs = null; // Act - long count = await demandeFormationService.GetDemandesFormationCountAsync(null, idBUs, texte, dateDebut, dateFin); + long count = await demandeFormationService.GetDemandesFormationCountAsync(null, idBUs, null, texte, dateDebut, dateFin); // Assert Assert.Less(0, count); @@ -433,7 +439,7 @@ namespace EPAServeur.Tests.Services idBUs = null; // Act - long count = await demandeFormationService.GetDemandesFormationCountAsync(null, idBUs, texte, dateDebut, dateFin); + long count = await demandeFormationService.GetDemandesFormationCountAsync(null, idBUs, null, texte, dateDebut, dateFin); // Assert Assert.AreEqual(0, count);