|
|
@ -370,14 +370,140 @@ namespace EPAServeur.Tests.Services |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Test Supprimer Note |
|
|
|
#region Test Supprimer Note |
|
|
|
|
|
|
|
[TestCase(5)] |
|
|
|
|
|
|
|
[TestCase(7)] |
|
|
|
|
|
|
|
[TestCase(8)] |
|
|
|
|
|
|
|
public async Task SupprimerNote_Succes(long id) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context); |
|
|
|
|
|
|
|
await noteService.SupprimerNoteAsync(id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Note note = await context.Note.FindAsync(id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.IsNull(note); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[TestCase(0)] |
|
|
|
|
|
|
|
[TestCase(-1)] |
|
|
|
|
|
|
|
[TestCase(-999)] |
|
|
|
|
|
|
|
[TestCase(20)] |
|
|
|
|
|
|
|
[TestCase(30)] |
|
|
|
|
|
|
|
[TestCase(100)] |
|
|
|
|
|
|
|
public void SupprimerNote_NoteNotFoundException(long id) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context); |
|
|
|
|
|
|
|
AsyncTestDelegate exception = () => noteService.SupprimerNoteAsync(id); |
|
|
|
|
|
|
|
Assert.ThrowsAsync(typeof(NoteNotFoundException), exception); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Tests UpdateNote |
|
|
|
#region Tests UpdateNote |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[TestCase(1)] |
|
|
|
|
|
|
|
[TestCase(2)] |
|
|
|
|
|
|
|
[TestCase(6)] |
|
|
|
|
|
|
|
[TestCase(9)] |
|
|
|
|
|
|
|
public async Task UpdateNote_UpdateTitreEtTexte(long id) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context); |
|
|
|
|
|
|
|
DetailsNoteDTO note = await noteService.GetNoteByIdAsync(id); |
|
|
|
|
|
|
|
note.Titre = "Titre à jour " + id; |
|
|
|
|
|
|
|
note.Texte= "Texte à jour " + id; |
|
|
|
|
|
|
|
DetailsNoteDTO noteUpdate = await noteService.UpdateNoteAsync(id, note); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.IsNotNull(noteUpdate); |
|
|
|
|
|
|
|
Assert.AreEqual(note.Id, noteUpdate.Id); |
|
|
|
|
|
|
|
Assert.AreEqual(note.IdAuteur, noteUpdate.IdAuteur); |
|
|
|
|
|
|
|
Assert.AreEqual(note.Collaborateur.Id, noteUpdate.Collaborateur.Id); |
|
|
|
|
|
|
|
Assert.AreEqual(note.DateCreation, noteUpdate.DateCreation); |
|
|
|
|
|
|
|
Assert.AreEqual(note.Titre, noteUpdate.Titre); |
|
|
|
|
|
|
|
Assert.AreEqual(note.Texte, noteUpdate.Texte); |
|
|
|
|
|
|
|
Assert.AreNotEqual(note.DateMiseAjour, noteUpdate.DateMiseAjour); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[TestCase(1)] |
|
|
|
|
|
|
|
[TestCase(2)] |
|
|
|
|
|
|
|
[TestCase(6)] |
|
|
|
|
|
|
|
[TestCase(9)] |
|
|
|
|
|
|
|
public async Task UpdateNote_UpdateTexte(long id) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context); |
|
|
|
|
|
|
|
DetailsNoteDTO note = await noteService.GetNoteByIdAsync(id); |
|
|
|
|
|
|
|
note.Texte = "Texte à jour " + id; |
|
|
|
|
|
|
|
DetailsNoteDTO noteUpdate = await noteService.UpdateNoteAsync(id, note); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.IsNotNull(noteUpdate); |
|
|
|
|
|
|
|
Assert.AreEqual(note.Id, noteUpdate.Id); |
|
|
|
|
|
|
|
Assert.AreEqual(note.IdAuteur, noteUpdate.IdAuteur); |
|
|
|
|
|
|
|
Assert.AreEqual(note.Collaborateur.Id, noteUpdate.Collaborateur.Id); |
|
|
|
|
|
|
|
Assert.AreEqual(note.DateCreation, noteUpdate.DateCreation); |
|
|
|
|
|
|
|
Assert.AreEqual(note.Titre, noteUpdate.Titre); |
|
|
|
|
|
|
|
Assert.AreEqual(note.Texte, noteUpdate.Texte); |
|
|
|
|
|
|
|
Assert.AreNotEqual(note.DateMiseAjour, noteUpdate.DateMiseAjour); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[TestCase(1)] |
|
|
|
|
|
|
|
[TestCase(2)] |
|
|
|
|
|
|
|
[TestCase(6)] |
|
|
|
|
|
|
|
[TestCase(9)] |
|
|
|
|
|
|
|
public async Task UpdateNote_UpdateTitre(long id) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context); |
|
|
|
|
|
|
|
DetailsNoteDTO note = await noteService.GetNoteByIdAsync(id); |
|
|
|
|
|
|
|
note.Titre = "Titre à jour " + id; |
|
|
|
|
|
|
|
DetailsNoteDTO noteUpdate = await noteService.UpdateNoteAsync(id, note); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.IsNotNull(noteUpdate); |
|
|
|
|
|
|
|
Assert.AreEqual(note.Id, noteUpdate.Id); |
|
|
|
|
|
|
|
Assert.AreEqual(note.IdAuteur, noteUpdate.IdAuteur); |
|
|
|
|
|
|
|
Assert.AreEqual(note.Collaborateur.Id, noteUpdate.Collaborateur.Id); |
|
|
|
|
|
|
|
Assert.AreEqual(note.DateCreation, noteUpdate.DateCreation); |
|
|
|
|
|
|
|
Assert.AreEqual(note.Titre, noteUpdate.Titre); |
|
|
|
|
|
|
|
Assert.AreEqual(note.Texte, noteUpdate.Texte); |
|
|
|
|
|
|
|
Assert.AreNotEqual(note.DateMiseAjour, noteUpdate.DateMiseAjour); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[TestCase(1,2)] |
|
|
|
|
|
|
|
[TestCase(1,3)] |
|
|
|
|
|
|
|
[TestCase(2,4)] |
|
|
|
|
|
|
|
[TestCase(2,5)] |
|
|
|
|
|
|
|
[TestCase(9,6)] |
|
|
|
|
|
|
|
[TestCase(9,7)] |
|
|
|
|
|
|
|
public async Task UpdateNote_NoteIdImcompatibleExceptionId(long id, long mauvaisId) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context); |
|
|
|
|
|
|
|
DetailsNoteDTO note = await noteService.GetNoteByIdAsync(id); |
|
|
|
|
|
|
|
note.Titre = "Titre à jour " + id; |
|
|
|
|
|
|
|
note.Texte = "Texte à jour " + id; |
|
|
|
|
|
|
|
AsyncTestDelegate exception = () => noteService.UpdateNoteAsync(mauvaisId, note); |
|
|
|
|
|
|
|
Assert.ThrowsAsync(typeof(NoteIdImcompatibleException), exception); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[TestCase(1)] |
|
|
|
|
|
|
|
[TestCase(2)] |
|
|
|
|
|
|
|
[TestCase(6)] |
|
|
|
|
|
|
|
[TestCase(9)] |
|
|
|
|
|
|
|
public async Task UpdateNote_NoteIdImcompatibleExceptionDate(long id) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context); |
|
|
|
|
|
|
|
DetailsNoteDTO note = await noteService.GetNoteByIdAsync(id); |
|
|
|
|
|
|
|
note.Titre = "Titre à jour " + id; |
|
|
|
|
|
|
|
note.Texte = "Texte à jour " + id; |
|
|
|
|
|
|
|
note.DateCreation = DateTime.Now; |
|
|
|
|
|
|
|
AsyncTestDelegate exception = () => noteService.UpdateNoteAsync(id, note); |
|
|
|
|
|
|
|
Assert.ThrowsAsync(typeof(NoteIdImcompatibleException), exception); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
#region Tests GetNoteByAuteur |
|
|
|
#region Tests GetNoteByAuteur |
|
|
|
#endregion |
|
|
|
#endregion. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|