using EPAServeur.Context; using EPAServeur.Exceptions; using EPAServeur.Models.Formation; using EPAServeur.Services; using IO.Swagger.Controllers; using IO.Swagger.DTO; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using NUnit.Framework; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.DependencyInjection; using EPAServeur.IServices; using Moq; using IO.Swagger.ApiCollaborateur; using IO.Swagger.Enum; namespace EPAServeur.Tests.Controllers { [TestFixture] public class ParticipationFormationApiTests { #region Variables private IParticipationFormationService participationFormationService; private Mock mockEnvironment; private EpContext epContext; #endregion #region Setup [SetUp] public void Setup() { // Création d'une collection de services pour l'injection de dépendance var services = new ServiceCollection(); // Utilisation d'une base de données en mémoire var optionBuider = new DbContextOptionsBuilder() .UseInMemoryDatabase("server_ep_test") .Options; services.AddDbContext(b => b.UseInMemoryDatabase("server_ep_test")); epContext = new EpContext(optionBuider); epContext.Database.EnsureDeleted(); epContext.Database.EnsureCreated(); epContext.SaveChanges(); // Ajout du jeu de données pour les tests DataSeeder.AddFormations(epContext); DataSeeder.AddChamps(epContext); // 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 foreach (var entity in epContext.ChangeTracker.Entries()) { entity.State = EntityState.Detached; } services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); // Récupère le service qui sera utilsé pour tester le contrôleur var serviceProvider = services.BuildServiceProvider(); participationFormationService = serviceProvider.GetService(); // Simule l'interface IWebHostEnvironment avec Moq mockEnvironment = new Mock(); mockEnvironment .Setup(m => m.EnvironmentName) .Returns("Development"); } #endregion #region Tests GetEvaluationCollaborateur [Test] public void GetEvaluationCollaborateur_PasseEnParamUnIdInconnu_RetourneUnObjetNotFoundResult() { // Arrange ParticipationsFormationsApiController ParticipationsFormationsApiController = new ParticipationsFormationsApiController(participationFormationService, new NullLogger(), mockEnvironment.Object); long idParticipationFormation = 99999; // Act var notFoundResult = ParticipationsFormationsApiController.GetEvaluationCollaborateur(idParticipationFormation); // Assert Assert.IsInstanceOf(notFoundResult.Result); } [Test] public void GetEvaluationCollaborateur_PasseEnParamUnIdConnu_RetourneUnObjetOkResult() { // Arrange ParticipationsFormationsApiController ParticipationsFormationsApiController = new ParticipationsFormationsApiController(participationFormationService, new NullLogger(), mockEnvironment.Object); long idParticipationFormation = 5; // Act var okResult = ParticipationsFormationsApiController.GetEvaluationCollaborateur(idParticipationFormation); // Assert Assert.IsInstanceOf(okResult.Result); } [Test] public void GetEvaluationCollaborateur_PasseEnParamUnIdConnu_RetourneLaBonneEvaluation() { // Arrange ParticipationsFormationsApiController ParticipationsFormationsApiController = new ParticipationsFormationsApiController(participationFormationService, new NullLogger(), mockEnvironment.Object); long idParticipationFormation = 5; // Act var okResult = ParticipationsFormationsApiController.GetEvaluationCollaborateur(idParticipationFormation).Result as OkObjectResult; // Assert Assert.IsInstanceOf(okResult.Value); Assert.AreEqual(idParticipationFormation, (okResult.Value as EvaluationDTO).Id); } #endregion #region Tests GetParticipationsByCollaborateur [Test] public void GetParticipationByCollaborateur_PasseDesParamsPresentsDansLaBDD_RetourneUnObjetOkResult() { // Arrange ParticipationsFormationsApiController ParticipationsFormationsApiController = new ParticipationsFormationsApiController(participationFormationService, new NullLogger(), mockEnvironment.Object); Guid idCollaborateur = Guid.Parse("842650db-a548-4472-a3af-4c5fff3c1ab8"); // Act var okResult = ParticipationsFormationsApiController.GetParticipationsByCollaborateur(idCollaborateur); // Assert Assert.IsInstanceOf(okResult.Result); } [Test] public void GetParticipationByCollaborateur_PasseDesParamsPresentsDansLaBDD_RetourneLesParticipationsDUnCollaborateur() { // Arrange ParticipationsFormationsApiController ParticipationsFormationsApiController = new ParticipationsFormationsApiController(participationFormationService, new NullLogger(), mockEnvironment.Object); Guid idCollaborateur = Guid.Parse("842650db-a548-4472-a3af-4c5fff3c1ab8"); int nbFormation = 1; int idFirstParticipationFormation = 5; // Act var okResult = ParticipationsFormationsApiController.GetParticipationsByCollaborateur(idCollaborateur).Result as OkObjectResult; // Assert Assert.IsInstanceOf>(okResult.Value); Assert.AreEqual(nbFormation, (okResult.Value as IEnumerable).Count()); Assert.AreEqual(idFirstParticipationFormation, (okResult.Value as IEnumerable).First().Id); } #endregion #region Tests EvaluerFormation [Test] public async Task EvaluerFormation_EvaluerUneFormationAvecDesObjetsEnfantsInvalides_RetourneUnObjetObjectResultDansCatchParticipationFormationInvalidException() { // Arrange long idParticipationFormation = 5; ParticipationsFormationsApiController ParticipationsFormationsApiController = new ParticipationsFormationsApiController(participationFormationService, new NullLogger(), mockEnvironment.Object); EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) .Where(p => p.IdParticipationFormation == idParticipationFormation) .Select(p => new EvaluationDTO() { Id = p.IdParticipationFormation, Intitule = p.Formation.Intitule, DateDebut = p.Formation.DateDebut, EstCertifiee = p.Formation.EstCertifiee, Saisies = new List() }).FirstOrDefaultAsync(); // Act var objectResult = ParticipationsFormationsApiController.EvaluerFormation(evaluationDTO, idParticipationFormation); // Assert Assert.IsInstanceOf(objectResult.Result); } [Test] public async Task EvaluerFormation_EvaluerUneFormationAvecDesObjetsEnfantsInvalides_RetourneUnObjetObjectResultDansCatchParticipationFormationIncompatibleIdException() { // Arrange long idParticipationFormation = 5; ParticipationsFormationsApiController ParticipationsFormationsApiController = new ParticipationsFormationsApiController(participationFormationService, new NullLogger(), mockEnvironment.Object); EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) .Where(p => p.IdParticipationFormation == idParticipationFormation) .Select(p => new EvaluationDTO() { Id = p.IdParticipationFormation, Intitule = p.Formation.Intitule, DateDebut = p.Formation.DateDebut, EstCertifiee = p.Formation.EstCertifiee, Saisies = new List() }).FirstOrDefaultAsync(); ChampDTO c1 = new ChampDTO { Id = 35, Section = "Evaluation", Ordre = 0, Texte = "Accueil et organisation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c2 = new ChampDTO { Id = 36, Section = "Evaluation", Ordre = 1, Texte = "Compétences animateur", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c3 = new ChampDTO { Id = 37, Section = "Evaluation", Ordre = 2, Texte = "Pédagogie/Animation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c4 = new ChampDTO { Id = 38, Section = "Evaluation", Ordre = 3, Texte = "Exhaustivité des sujets traités", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c5 = new ChampDTO { Id = 39, Section = "Evaluation", Ordre = 4, Texte = "Utilité/Apport de la formation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c6 = new ChampDTO { Id = 40, Section = "Evaluation", Ordre = 5, Texte = "Contenu théorique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c7 = new ChampDTO { Id = 41, Section = "Evaluation", Ordre = 6, Texte = "Contenu pratique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c8 = new ChampDTO { Id = 42, Section = "Evaluation", Ordre = 7, Texte = "Equilibre pratique/théorie", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c9 = new ChampDTO { Id = 43, Section = "Evaluation", Ordre = 8, Texte = "Support de cours", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c10 = new ChampDTO { Id = 44, Section = "Evaluation", Ordre = 9, Texte = "Durée", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; SaisieDTO s1 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c1 }; SaisieDTO s2 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c2 }; SaisieDTO s3 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c3 }; SaisieDTO s4 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c4 }; SaisieDTO s5 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c5 }; SaisieDTO s6 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c6 }; SaisieDTO s7 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c7 }; SaisieDTO s8 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c8 }; SaisieDTO s9 = new SaisieDTO { Note = 3, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c9 }; SaisieDTO s10 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c10 }; evaluationDTO.Saisies.Add(s1); evaluationDTO.Saisies.Add(s2); evaluationDTO.Saisies.Add(s3); evaluationDTO.Saisies.Add(s4); evaluationDTO.Saisies.Add(s5); evaluationDTO.Saisies.Add(s6); evaluationDTO.Saisies.Add(s7); evaluationDTO.Saisies.Add(s8); evaluationDTO.Saisies.Add(s9); evaluationDTO.Saisies.Add(s10); idParticipationFormation = 1; // Act var objectResult = ParticipationsFormationsApiController.EvaluerFormation(evaluationDTO, idParticipationFormation); // Assert Assert.IsInstanceOf(objectResult.Result); } [Test] public async Task EvaluerFormation_EvaluerUneFormationInexistante_RetourneUnObjetObjectResultDansCatchParticipationFormationNotFoundExceptionn() { // Arrange long idParticipationFormation = 5; long idParticipationFormationInexistant = 999; ParticipationsFormationsApiController ParticipationsFormationsApiController = new ParticipationsFormationsApiController(participationFormationService, new NullLogger(), mockEnvironment.Object); EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) .Where(p => p.IdParticipationFormation == idParticipationFormation) .Select(p => new EvaluationDTO() { Id = p.IdParticipationFormation, Intitule = p.Formation.Intitule, DateDebut = p.Formation.DateDebut, EstCertifiee = p.Formation.EstCertifiee, Saisies = new List() }).FirstOrDefaultAsync(); ChampDTO c1 = new ChampDTO { Id = 35, Section = "Evaluation", Ordre = 0, Texte = "Accueil et organisation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c2 = new ChampDTO { Id = 36, Section = "Evaluation", Ordre = 1, Texte = "Compétences animateur", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c3 = new ChampDTO { Id = 37, Section = "Evaluation", Ordre = 2, Texte = "Pédagogie/Animation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c4 = new ChampDTO { Id = 38, Section = "Evaluation", Ordre = 3, Texte = "Exhaustivité des sujets traités", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c5 = new ChampDTO { Id = 39, Section = "Evaluation", Ordre = 4, Texte = "Utilité/Apport de la formation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c6 = new ChampDTO { Id = 40, Section = "Evaluation", Ordre = 5, Texte = "Contenu théorique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c7 = new ChampDTO { Id = 41, Section = "Evaluation", Ordre = 6, Texte = "Contenu pratique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c8 = new ChampDTO { Id = 42, Section = "Evaluation", Ordre = 7, Texte = "Equilibre pratique/théorie", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c9 = new ChampDTO { Id = 43, Section = "Evaluation", Ordre = 8, Texte = "Support de cours", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c10 = new ChampDTO { Id = 44, Section = "Evaluation", Ordre = 9, Texte = "Durée", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; SaisieDTO s1 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c1 }; SaisieDTO s2 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c2 }; SaisieDTO s3 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c3 }; SaisieDTO s4 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c4 }; SaisieDTO s5 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c5 }; SaisieDTO s6 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c6 }; SaisieDTO s7 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c7 }; SaisieDTO s8 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c8 }; SaisieDTO s9 = new SaisieDTO { Note = 3, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c9 }; SaisieDTO s10 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c10 }; evaluationDTO.Saisies.Add(s1); evaluationDTO.Saisies.Add(s2); evaluationDTO.Saisies.Add(s3); evaluationDTO.Saisies.Add(s4); evaluationDTO.Saisies.Add(s5); evaluationDTO.Saisies.Add(s6); evaluationDTO.Saisies.Add(s7); evaluationDTO.Saisies.Add(s8); evaluationDTO.Saisies.Add(s9); evaluationDTO.Saisies.Add(s10); evaluationDTO.Id = idParticipationFormationInexistant; // Act var objectResult = ParticipationsFormationsApiController.EvaluerFormation(evaluationDTO, idParticipationFormationInexistant); // Assert Assert.IsInstanceOf(objectResult.Result); } [Test] public async Task EvaluerFormation_EvaluerUneFormationValide_RetourneUnObjetOkObjectResult() { // Arrange long idParticipationFormation = 5; ParticipationsFormationsApiController ParticipationsFormationsApiController = new ParticipationsFormationsApiController(participationFormationService, new NullLogger(), mockEnvironment.Object); EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) .Where(p => p.IdParticipationFormation == idParticipationFormation) .Select(p => new EvaluationDTO() { Id = p.IdParticipationFormation, Intitule = p.Formation.Intitule, DateDebut = p.Formation.DateDebut, EstCertifiee = p.Formation.EstCertifiee, Saisies = new List() }).FirstOrDefaultAsync(); ChampDTO c1 = new ChampDTO { Id = 35, Section = "Evaluation", Ordre = 0, Texte = "Accueil et organisation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c2 = new ChampDTO { Id = 36, Section = "Evaluation", Ordre = 1, Texte = "Compétences animateur", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c3 = new ChampDTO { Id = 37, Section = "Evaluation", Ordre = 2, Texte = "Pédagogie/Animation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c4 = new ChampDTO { Id = 38, Section = "Evaluation", Ordre = 3, Texte = "Exhaustivité des sujets traités", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c5 = new ChampDTO { Id = 39, Section = "Evaluation", Ordre = 4, Texte = "Utilité/Apport de la formation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c6 = new ChampDTO { Id = 40, Section = "Evaluation", Ordre = 5, Texte = "Contenu théorique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c7 = new ChampDTO { Id = 41, Section = "Evaluation", Ordre = 6, Texte = "Contenu pratique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c8 = new ChampDTO { Id = 42, Section = "Evaluation", Ordre = 7, Texte = "Equilibre pratique/théorie", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c9 = new ChampDTO { Id = 43, Section = "Evaluation", Ordre = 8, Texte = "Support de cours", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c10 = new ChampDTO { Id = 44, Section = "Evaluation", Ordre = 9, Texte = "Durée", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; SaisieDTO s1 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c1 }; SaisieDTO s2 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c2 }; SaisieDTO s3 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c3 }; SaisieDTO s4 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c4 }; SaisieDTO s5 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c5 }; SaisieDTO s6 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c6 }; SaisieDTO s7 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c7 }; SaisieDTO s8 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c8 }; SaisieDTO s9 = new SaisieDTO { Note = 3, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c9 }; SaisieDTO s10 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c10 }; evaluationDTO.Saisies.Add(s1); evaluationDTO.Saisies.Add(s2); evaluationDTO.Saisies.Add(s3); evaluationDTO.Saisies.Add(s4); evaluationDTO.Saisies.Add(s5); evaluationDTO.Saisies.Add(s6); evaluationDTO.Saisies.Add(s7); evaluationDTO.Saisies.Add(s8); evaluationDTO.Saisies.Add(s9); evaluationDTO.Saisies.Add(s10); // Act var okObjectResult = ParticipationsFormationsApiController.EvaluerFormation(evaluationDTO, idParticipationFormation); // Assert Assert.IsInstanceOf(okObjectResult.Result); } [Test] public async Task EvaluerFormation_EvaluerUneFormationValide_RetourneLEvaluationEvaluee() { // Arrange long idParticipationFormation = 5; ParticipationsFormationsApiController ParticipationsFormationsApiController = new ParticipationsFormationsApiController(participationFormationService, new NullLogger(), mockEnvironment.Object); EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) .Where(p => p.IdParticipationFormation == idParticipationFormation) .Select(p => new EvaluationDTO() { Id = p.IdParticipationFormation, Intitule = p.Formation.Intitule, DateDebut = p.Formation.DateDebut, EstCertifiee = p.Formation.EstCertifiee, Saisies = new List() }).FirstOrDefaultAsync(); ChampDTO c1 = new ChampDTO { Id = 35, Section = "Evaluation", Ordre = 0, Texte = "Accueil et organisation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c2 = new ChampDTO { Id = 36, Section = "Evaluation", Ordre = 1, Texte = "Compétences animateur", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c3 = new ChampDTO { Id = 37, Section = "Evaluation", Ordre = 2, Texte = "Pédagogie/Animation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c4 = new ChampDTO { Id = 38, Section = "Evaluation", Ordre = 3, Texte = "Exhaustivité des sujets traités", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c5 = new ChampDTO { Id = 39, Section = "Evaluation", Ordre = 4, Texte = "Utilité/Apport de la formation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c6 = new ChampDTO { Id = 40, Section = "Evaluation", Ordre = 5, Texte = "Contenu théorique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c7 = new ChampDTO { Id = 41, Section = "Evaluation", Ordre = 6, Texte = "Contenu pratique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c8 = new ChampDTO { Id = 42, Section = "Evaluation", Ordre = 7, Texte = "Equilibre pratique/théorie", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c9 = new ChampDTO { Id = 43, Section = "Evaluation", Ordre = 8, Texte = "Support de cours", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; ChampDTO c10 = new ChampDTO { Id = 44, Section = "Evaluation", Ordre = 9, Texte = "Durée", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; SaisieDTO s1 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c1 }; SaisieDTO s2 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c2 }; SaisieDTO s3 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c3 }; SaisieDTO s4 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c4 }; SaisieDTO s5 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c5 }; SaisieDTO s6 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c6 }; SaisieDTO s7 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c7 }; SaisieDTO s8 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c8 }; SaisieDTO s9 = new SaisieDTO { Note = 3, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c9 }; SaisieDTO s10 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c10 }; evaluationDTO.Saisies.Add(s1); evaluationDTO.Saisies.Add(s2); evaluationDTO.Saisies.Add(s3); evaluationDTO.Saisies.Add(s4); evaluationDTO.Saisies.Add(s5); evaluationDTO.Saisies.Add(s6); evaluationDTO.Saisies.Add(s7); evaluationDTO.Saisies.Add(s8); evaluationDTO.Saisies.Add(s9); evaluationDTO.Saisies.Add(s10); // Act var okObjectResult = ParticipationsFormationsApiController.EvaluerFormation(evaluationDTO, idParticipationFormation).Result as OkObjectResult; // Assert Assert.IsInstanceOf(okObjectResult.Value); Assert.AreEqual(idParticipationFormation, (okObjectResult.Value as EvaluationDTO).Id); } #endregion } }