Ajout des tests unitaires sur le GetNotById de NoteService

develop
Yanaël GRETTE 4 years ago
parent 67c115f0aa
commit bcdd8faa83
  1. 57
      EPAServeur.Tests/Services/NoteServiceTests.cs
  2. 14
      EPAServeur/Context/DataSeeder.cs

@ -309,6 +309,63 @@ namespace EPAServeur.Tests.Services
#endregion
#region Tests GetNoteById
[TestCase(1)]
[TestCase(2)]
[TestCase(4)]
[TestCase(5)]
[TestCase(6)]
[TestCase(9)]
public async Task GetNote_NoteNotNull(long id)
{
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context);
DetailsNoteDTO detailsNoteDTO = await noteService.GetNoteByIdAsync(id);
Assert.NotNull(detailsNoteDTO);
Assert.NotNull(detailsNoteDTO.Titre);
Assert.NotNull(detailsNoteDTO.Texte);
Assert.NotNull(detailsNoteDTO.IdAuteur);
Assert.NotNull(detailsNoteDTO.Collaborateur);
Assert.NotNull(detailsNoteDTO.DateCreation);
Assert.NotNull(detailsNoteDTO.DateMiseAjour);
Assert.AreEqual(id, detailsNoteDTO.Id);
}
[TestCase(-999)]
[TestCase(-1)]
[TestCase(0)]
[TestCase(11)]
[TestCase(20)]
[TestCase(30)]
[TestCase(100)]
public void GetNote_NoteNotFoundException(long id)
{
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context);
AsyncTestDelegate exception = () => noteService.GetNoteByIdAsync(id);
Assert.ThrowsAsync(typeof(NoteNotFoundException), exception);
}
[TestCase(3)]
[TestCase(7)]
public void GetNote_ReferentNotFoundException(long id)
{
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context);
AsyncTestDelegate exception = () => noteService.GetNoteByIdAsync(id);
Assert.ThrowsAsync(typeof(ReferentNotFoundException), exception);
}
[TestCase(8)]
[TestCase(10)]
public void GetNote_CollaborateurNotFoundException(long id)
{
INoteService noteService = new NoteService(collaborateurApi, collaborateurService, context);
AsyncTestDelegate exception = () => noteService.GetNoteByIdAsync(id);
Assert.ThrowsAsync(typeof(CollaborateurNotFoundException), exception);
}
#endregion

@ -829,7 +829,7 @@ namespace EPAServeur.Context
Titre = "Titre1",
Texte = "Texte1",
IdAuteur = new Guid("ecf528c3-e509-402f-87bb-c8821467e350"),
IdCollaborateur = new Guid("779bf1cf-4d38-48fb-8550-3d583384523b"),
IdCollaborateur = new Guid("fc1d7593-83c3-44de-b3f5-53dbe53c0830"),
DateCreation = DateTime.Now,
DateMiseAJour = DateTime.Now
@ -842,7 +842,7 @@ namespace EPAServeur.Context
Titre = "Titre2",
Texte = "Texte2",
IdAuteur = new Guid("ecf528c3-e509-402f-87bb-c8821467e350"),
IdCollaborateur = new Guid("779bf1cf-4d38-48fb-8550-3d583384523b"),
IdCollaborateur = new Guid("fc1d7593-83c3-44de-b3f5-53dbe53c0830"),
DateCreation = DateTime.Now,
DateMiseAJour = DateTime.Now
@ -854,8 +854,8 @@ namespace EPAServeur.Context
IdNote = 3,
Titre = "Titre3",
Texte = "Texte3",
IdAuteur = new Guid("ecf528c3-e509-402f-87bb-c8821467e350"),
IdCollaborateur = new Guid("779bf1cf-4d38-48fb-8550-3d583384523b"),
IdAuteur = new Guid("073a4fb0-45c3-11eb-b378-0242ac130002"),
IdCollaborateur = new Guid("fc1d7593-83c3-44de-b3f5-53dbe53c0830"),
DateCreation = DateTime.Now,
DateMiseAJour = DateTime.Now
@ -906,7 +906,7 @@ namespace EPAServeur.Context
IdNote = 7,
Titre = "Titre7",
Texte = "Texte7",
IdAuteur = new Guid("6aa62dcb-f7c9-4c0c-af40-e934a4d6a7eb"),
IdAuteur = new Guid("073a4fb0-45c3-11eb-b378-0242ac130002"),
IdCollaborateur = new Guid("006226f6-51b2-4a02-a302-7447f7fccc04"),
DateCreation = DateTime.Now,
DateMiseAJour = DateTime.Now
@ -920,7 +920,7 @@ namespace EPAServeur.Context
Titre = "Titre8",
Texte = "Texte8",
IdAuteur = new Guid("571463f3-b286-4a21-9eab-0707dc506dec"),
IdCollaborateur = new Guid("006226f6-51b2-4a02-a302-7447f7fccc04"),
IdCollaborateur = new Guid("227e0e1a-45c3-11eb-b378-0242ac130002"),
DateCreation = DateTime.Now,
DateMiseAJour = DateTime.Now
@ -946,7 +946,7 @@ namespace EPAServeur.Context
Titre = "Titre10",
Texte = "Texte10",
IdAuteur = new Guid("6aa62dcb-f7c9-4c0c-af40-e934a4d6a7eb"),
IdCollaborateur = new Guid("006226f6-51b2-4a02-a302-7447f7fccc04"),
IdCollaborateur = new Guid("694ffef2-45c3-11eb-b378-0242ac130002"),
DateCreation = DateTime.Now,
DateMiseAJour = DateTime.Now

Loading…
Cancel
Save