@ -261,6 +261,36 @@ namespace EPAServeur.Tests.Services
}
}
[TestCase(true, "participants")]
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParNombreDeParticipantsCroissant ( bool? asc , string tri )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
// Act
IEnumerable < FormationDetailsDTO > formationDTOs = await formationService . GetFormationsAsync ( null , null , asc , null , null , null , tri , null , null ) ;
// Assert
Assert . AreEqual ( 0 , formationDTOs . First ( ) . NbParticipations ) ;
Assert . AreEqual ( 3 , formationDTOs . Last ( ) . NbParticipations ) ;
}
[TestCase(false, "participants")]
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParNombreDeParticipantsDecroissant ( bool? asc , string tri )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
// Act
IEnumerable < FormationDetailsDTO > formationDTOs = await formationService . GetFormationsAsync ( null , null , asc , null , null , null , tri , null , null ) ;
// Assert
Assert . AreEqual ( 3 , formationDTOs . First ( ) . NbParticipations ) ;
Assert . AreEqual ( 0 , formationDTOs . Last ( ) . NbParticipations ) ;
}
[TestCase(true, "origine")]
[TestCase(true, "origine")]
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParOrigineCroissante ( bool? asc , string tri )
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParOrigineCroissante ( bool? asc , string tri )
{
{
@ -439,13 +469,13 @@ namespace EPAServeur.Tests.Services
#region Tests GetFormationsCountAsync
#region Tests GetFormationsCountAsync
[TestCase(1, new int[] { 1 , 2 , 3 } , 1 , 5 , "formation" , "2020-09-30" , "2020-11-30" ) ]
[TestCase(1, new int[] { 1 , 2 , 3 } , "formation" , "2020-09-30" , "2020-11-30" ) ]
[TestCase(1, new int[] { 1 } , 1 , 5 , "Formation Mainframe Complète" , null , null ) ]
[TestCase(1, new int[] { 1 } , "Formation Mainframe Complète" , null , null ) ]
[TestCase(null, null, 2, 10, null, null, null)]
[TestCase(null, null, null, null, null)]
[TestCase(null, new int[] { 1 } , 1 , 1 0 , null , null , null ) ]
[TestCase(null, new int[] { 1 } , null , null , null ) ]
[TestCase(1, null, 1, 10, "for", null, null)]
[TestCase(1, null, "for", null, null)]
[TestCase(1, new int[] { } , 1 , 1 0 , "for" , null , null ) ]
[TestCase(1, new int[] { } , "for" , null , null ) ]
public async Task GetFormationsCountAsync_PasseDesParamsValides_RetourneLeNombreTotalDeFormations ( long? idAgence , int [ ] arrIdStatuts , int? numPage , int? parPAge , string texte , DateTime ? dateDebut , DateTime ? dateFin )
public async Task GetFormationsCountAsync_PasseDesParamsValides_RetourneLeNombreTotalDeFormations ( long? idAgence , int [ ] arrIdStatuts , string texte , DateTime ? dateDebut , DateTime ? dateFin )
{
{
// Arrange
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
@ -457,16 +487,16 @@ namespace EPAServeur.Tests.Services
idStatuts = null ;
idStatuts = null ;
// Act
// Act
long count = await formationService . GetFormationsCountAsync ( idAgence , idStatuts , numPage , parPAge , texte , dateDebut , dateFin ) ;
long count = await formationService . GetFormationsCountAsync ( idAgence , idStatuts , texte , dateDebut , dateFin ) ;
// Assert
// Assert
Assert . Less ( 0 , count ) ;
Assert . Less ( 0 , count ) ;
}
}
[TestCase(1, new int[] { 1 } , 1 , 1 5 , "azerty" , null , null ) ]
[TestCase(1, new int[] { 1 } , "azerty" , null , null ) ]
[TestCase(-1, new int[] { - 1 } , - 1 , - 1 , "azerty" , null , null ) ]
[TestCase(-1, new int[] { - 1 } , "azerty" , null , null ) ]
[TestCase(0, new int[] { 0 } , 0 , 0 , null , null , null ) ]
[TestCase(0, new int[] { 0 } , null , null , null ) ]
public async Task GetFormationsCountAsync_PasseDesParamsInvalides_RetourneZero ( long? idAgence , int [ ] arrIdStatuts , int? numPage , int? parPAge , string texte , DateTime ? dateDebut , DateTime ? dateFin )
public async Task GetFormationsCountAsync_PasseDesParamsInvalides_RetourneZero ( long? idAgence , int [ ] arrIdStatuts , string texte , DateTime ? dateDebut , DateTime ? dateFin )
{
{
// Arrange
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
@ -478,7 +508,7 @@ namespace EPAServeur.Tests.Services
idStatuts = null ;
idStatuts = null ;
// Act
// Act
long count = await formationService . GetFormationsCountAsync ( idAgence , idStatuts , numPage , parPAge , texte , dateDebut , dateFin ) ;
long count = await formationService . GetFormationsCountAsync ( idAgence , idStatuts , texte , dateDebut , dateFin ) ;
// Assert
// Assert
Assert . AreEqual ( 0 , count ) ;
Assert . AreEqual ( 0 , count ) ;