@ -22,6 +22,7 @@ namespace EPAServeur.Tests.Services
private EpContext epContext ;
private ICollaborateurApi collaborateurApi ;
private ICollaborateurService collaborateurService ;
private ITransformDTO transformDTO ;
# endregion
#region Setup
@ -36,7 +37,8 @@ namespace EPAServeur.Tests.Services
epContext = new EpContext ( optionBuider ) ;
collaborateurApi = new CollaborateurApi ( ) ;
collaborateurService = new CollaborateurService ( collaborateurApi , epContext ) ;
transformDTO = new TransformDTO ( ) ;
collaborateurService = new CollaborateurService ( collaborateurApi , epContext , transformDTO ) ;
epContext . Database . EnsureDeleted ( ) ;
epContext . Database . EnsureCreated ( ) ;
epContext . SaveChanges ( ) ;
@ -59,7 +61,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationByIdAsync_PasseEnParamUnIdExistantDansLeJeuDeDonneesFictif_RetourneUneFormation ( )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
FormationDTO formationDTO = await formationService . GetFormationByIdAsync ( 3 ) ;
@ -85,7 +87,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationByIdAsync_PasseEnParamUnIdExistantDansLeJeuDeDonneesFictif_RetourneUneFormationSansParticipation ( )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
long idFormation = 1 1 ;
// Act
@ -114,7 +116,7 @@ namespace EPAServeur.Tests.Services
public void GetFormationByIdAsync_PasseEnParamUnIdInexistantDansLeJeuDeDonneesFictif_LeveUneFormationNotFoundException ( long idFormation )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
AsyncTestDelegate throwException = ( ) = > formationService . GetFormationByIdAsync ( idFormation ) ;
@ -136,7 +138,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseDesParamsValides_RetourneDesFormations ( long? idAgence , int [ ] arrIdStatuts , bool? asc , int? numPage , int? parPAge , string texte , string tri , DateTime ? dateDebut , DateTime ? dateFin )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
List < int? > idStatuts ;
if ( arrIdStatuts ! = null )
@ -156,7 +158,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamNumPageEtParPage_RetourneLaPremierePageDesFormations ( int? numPage , int? parPAge )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
IEnumerable < FormationDetailsDTO > formationDTOs = await formationService . GetFormationsAsync ( null , null , null , numPage , parPAge , null , null , null , null ) ;
@ -172,7 +174,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamNumPageEtParPage_RetourneLaDeuxiemePageDesFormations ( int? numPage , int? parPAge )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
int? nbFormationDeuxiemePage ;
switch ( parPAge )
@ -204,7 +206,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParIntituleCroissant ( bool? asc , string tri )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
IEnumerable < FormationDetailsDTO > formationDTOs = await formationService . GetFormationsAsync ( null , null , asc , null , null , null , tri , null , null ) ;
@ -221,7 +223,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParIntituleDecroissant ( bool? asc , string tri )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
IEnumerable < FormationDetailsDTO > formationDTOs = await formationService . GetFormationsAsync ( null , null , asc , null , null , null , tri , null , null ) ;
@ -236,7 +238,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParStatutCroissant ( bool? asc , string tri )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
IEnumerable < FormationDetailsDTO > formationDTOs = await formationService . GetFormationsAsync ( null , null , asc , null , null , null , tri , null , null ) ;
@ -251,7 +253,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParStatutDecroissant ( bool? asc , string tri )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
IEnumerable < FormationDetailsDTO > formationDTOs = await formationService . GetFormationsAsync ( null , null , asc , null , null , null , tri , null , null ) ;
@ -266,7 +268,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParNombreDeParticipantsCroissant ( bool? asc , string tri )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
IEnumerable < FormationDetailsDTO > formationDTOs = await formationService . GetFormationsAsync ( null , null , asc , null , null , null , tri , null , null ) ;
@ -281,7 +283,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParNombreDeParticipantsDecroissant ( bool? asc , string tri )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
IEnumerable < FormationDetailsDTO > formationDTOs = await formationService . GetFormationsAsync ( null , null , asc , null , null , null , tri , null , null ) ;
@ -296,7 +298,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParOrigineCroissante ( bool? asc , string tri )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
IEnumerable < FormationDetailsDTO > formationDTOs = await formationService . GetFormationsAsync ( null , null , asc , null , null , null , tri , null , null ) ;
@ -311,7 +313,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParOrigineDecroissante ( bool? asc , string tri )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
IEnumerable < FormationDetailsDTO > formationDTOs = await formationService . GetFormationsAsync ( null , null , asc , null , null , null , tri , null , null ) ;
@ -326,7 +328,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParDateCroissante ( bool? asc , string tri )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
IEnumerable < FormationDetailsDTO > formationDTOs = await formationService . GetFormationsAsync ( null , null , asc , null , null , null , tri , null , null ) ;
@ -341,7 +343,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParDateDecroissante ( bool? asc , string tri )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
IEnumerable < FormationDetailsDTO > formationDTOs = await formationService . GetFormationsAsync ( null , null , asc , null , null , null , tri , null , null ) ;
@ -356,7 +358,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParCertificationCroissante ( bool? asc , string tri )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
IEnumerable < FormationDetailsDTO > formationDTOs = await formationService . GetFormationsAsync ( null , null , asc , null , null , null , tri , null , null ) ;
@ -371,7 +373,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParCertificationDecroissante ( bool? asc , string tri )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
IEnumerable < FormationDetailsDTO > formationDTOs = await formationService . GetFormationsAsync ( null , null , asc , null , null , null , tri , null , null ) ;
@ -387,7 +389,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamUneDateDeDebut_RetourneDesFormationsAvecUneDateDeDebutSuperieur ( DateTime dateDebut )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
IEnumerable < FormationDetailsDTO > formationDTOs = await formationService . GetFormationsAsync ( null , null , null , null , null , null , null , dateDebut , null ) ;
@ -402,7 +404,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamUneDateDeFin_RetourneDesFormationsAvecUneDateDeFinInferieur ( DateTime dateFin )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
IEnumerable < FormationDetailsDTO > formationDTOs = await formationService . GetFormationsAsync ( null , null , null , null , null , null , null , null , dateFin ) ;
@ -417,7 +419,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamUneDateDeDebutEtUneDateDeFin_RetourneDesFormationsAvecUneDateDeDebutSuperieurUneDateDeFinInferieur ( DateTime dateDebut , DateTime dateFin )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
IEnumerable < FormationDetailsDTO > formationDTOs = await formationService . GetFormationsAsync ( null , null , null , null , null , null , null , dateDebut , dateFin ) ;
@ -435,7 +437,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseEnParamUneDateDeDebutSuperieurEtUneDateDeFinInferieur_RetourneZeroFormation ( DateTime dateDebut , DateTime dateFin )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
IEnumerable < FormationDetailsDTO > formationDTOs = await formationService . GetFormationsAsync ( null , null , null , null , null , null , null , dateDebut , dateFin ) ;
@ -450,7 +452,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsAsync_PasseDesParamsInvalides_RetourneZeroFormation ( long? idAgence , int [ ] arrIdStatuts , bool? asc , int? numPage , int? parPAge , string texte , string tri , DateTime ? dateDebut , DateTime ? dateFin )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
List < int? > idStatuts ;
if ( arrIdStatuts ! = null )
@ -479,7 +481,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsCountAsync_PasseDesParamsValides_RetourneLeNombreTotalDeFormations ( long? idAgence , int [ ] arrIdStatuts , string texte , DateTime ? dateDebut , DateTime ? dateFin )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
List < int? > idStatuts ;
if ( arrIdStatuts ! = null )
@ -500,7 +502,7 @@ namespace EPAServeur.Tests.Services
public async Task GetFormationsCountAsync_PasseDesParamsInvalides_RetourneZero ( long? idAgence , int [ ] arrIdStatuts , string texte , DateTime ? dateDebut , DateTime ? dateFin )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
List < int? > idStatuts ;
if ( arrIdStatuts ! = null )
@ -524,7 +526,7 @@ namespace EPAServeur.Tests.Services
public async Task GetModesFormationAsync_RetourneTousLesModesDeFormation ( )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
IEnumerable < ModeFormationDTO > modeFormationDTOs = await formationService . GetModesFormationAsync ( ) ;
@ -542,7 +544,7 @@ namespace EPAServeur.Tests.Services
public async Task GetOriginesAsyncFormation_RetourneToutesLesOriginesDeFormation ( )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
IEnumerable < OrigineFormationDTO > origineFormationDTOs = await formationService . GetOriginesFormationAsync ( ) ;
@ -560,7 +562,7 @@ namespace EPAServeur.Tests.Services
public async Task GetStatutsFormationAsyncFormation_RetourneTousLesStatutsDeFormation ( )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
IEnumerable < StatutFormationDTO > statutFormationDTOs = await formationService . GetStatutsFormationAsync ( ) ;
@ -578,7 +580,7 @@ namespace EPAServeur.Tests.Services
public async Task GetTypesFormationAsync_RetourneTousLesTypesDeFormation ( )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
IEnumerable < TypeFormationDTO > typeFormationDTOs = await formationService . GetTypesFormationAsync ( ) ;
@ -623,7 +625,7 @@ namespace EPAServeur.Tests.Services
EstCertifiee = false
} ;
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
FormationDTO formationAjoute = await formationService . AddFormationAsync ( formation ) ;
@ -652,7 +654,7 @@ namespace EPAServeur.Tests.Services
// Arrange
FormationDTO formation = null ;
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
AsyncTestDelegate throwException = ( ) = > formationService . AddFormationAsync ( formation ) ;
@ -701,7 +703,7 @@ namespace EPAServeur.Tests.Services
EstCertifiee = false
} ;
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
AsyncTestDelegate throwException = ( ) = > formationService . AddFormationAsync ( formation ) ;
@ -747,7 +749,7 @@ namespace EPAServeur.Tests.Services
EstCertifiee = false
} ;
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
AsyncTestDelegate throwException = ( ) = > formationService . AddFormationAsync ( formation ) ;
@ -773,7 +775,7 @@ namespace EPAServeur.Tests.Services
OrigineFormationDTO origineFormationCollaborateur = epContext . OrigineFormation . Where ( mode = > mode . IdOrigineFormation = = idOrigine )
. Select ( mode = > new OrigineFormationDTO { Id = mode . IdOrigineFormation , Libelle = mode . Libelle } ) . FirstOrDefault ( ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
FormationDTO formation = await formationService . GetFormationByIdAsync ( idFormation ) ;
@ -837,7 +839,7 @@ namespace EPAServeur.Tests.Services
OrigineFormationDTO origineFormationCollaborateur = epContext . OrigineFormation . Where ( mode = > mode . IdOrigineFormation = = idOrigine )
. Select ( mode = > new OrigineFormationDTO { Id = mode . IdOrigineFormation , Libelle = mode . Libelle } ) . FirstOrDefault ( ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
FormationDTO formation = await formationService . GetFormationByIdAsync ( idFormation ) ;
@ -876,7 +878,7 @@ namespace EPAServeur.Tests.Services
OrigineFormationDTO origineFormationCollaborateur = epContext . OrigineFormation . Where ( mode = > mode . IdOrigineFormation = = idOrigine )
. Select ( mode = > new OrigineFormationDTO { Id = mode . IdOrigineFormation , Libelle = mode . Libelle } ) . FirstOrDefault ( ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
FormationDTO formation = await formationService . GetFormationByIdAsync ( 1 ) ;
@ -914,7 +916,7 @@ namespace EPAServeur.Tests.Services
OrigineFormationDTO origineFormationCollaborateur = epContext . OrigineFormation . Where ( mode = > mode . IdOrigineFormation = = idOrigine )
. Select ( mode = > new OrigineFormationDTO { Id = mode . IdOrigineFormation , Libelle = mode . Libelle } ) . FirstOrDefault ( ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
FormationDTO formation = new FormationDTO
{
@ -950,7 +952,7 @@ namespace EPAServeur.Tests.Services
public async Task DeleteFormationByIdAsync_SupprimeUneFormationAvecUnIdValide_FormationSupprimeAvecSucces ( long idFormation )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
bool existFormation = true ;
// Act
@ -967,7 +969,7 @@ namespace EPAServeur.Tests.Services
public void DeleteFormationByIdAsync_SupprimeUneFormationAvecUnIdInvalide_LeveUneFormationNotFoundException ( long idFormation )
{
// Arrange
FormationService formationService = new FormationService ( epContext , collaborateurService ) ;
FormationService formationService = new FormationService ( epContext , collaborateurService , transformDTO ) ;
// Act
AsyncTestDelegate throwException = ( ) = > formationService . DeleteFormationByIdAsync ( idFormation ) ;