Ajout des TU GetById sur les paragraphs

pull/40/head
Maxime SAPOUNTZIS 1 year ago
parent e4ab7040e3
commit f9f356d329

@ -65,6 +65,60 @@ namespace TestAPI
[Fact]
public void GetParagraphIdSuccess()
{
var paragraphsList = GetParagraphsData();
paragraphService.Setup(x => x.GetParagraphById(1))
.Returns(paragraphsList[1]);
var ParagraphsController = new ParagraphsController(paragraphService.Object, new NullLogger<ParagraphsController>());
var paragraphsResult = ParagraphsController.GetParagraphById(1);
if (paragraphsResult is OkObjectResult okObjectResult)
{
ParagraphDTO valeur = okObjectResult.Value as ParagraphDTO;
Assert.NotNull(valeur);
Assert.Equal("Le titre", valeur.Title);
Assert.Equal("pas contenu", valeur.Content);
Assert.Equal("Pas d'infos ici", valeur.Info);
Assert.Equal("Delete * from Earth", valeur.Query);
Assert.Equal("Miam", valeur.Comment);
Assert.Equal(2, valeur.LessonId);
Assert.Equal(valeur.GetHashCode(), paragraphsList[1].GetHashCode());
Assert.True(valeur.Equals(paragraphsList[1]));
Assert.False(valeur.Equals(new object()));
Assert.True(valeur.Equals(valeur));
Assert.IsType<ParagraphDTO>(valeur);
Assert.Contains(valeur, paragraphsList);
}
}
[Fact]
public void GetParagraphIdFail()
{
var paragraphsList = GetParagraphsData();
paragraphService.Setup(x => x.GetParagraphById(1))
.Returns(paragraphsList[1]);
var ParagraphsController = new ParagraphsController(paragraphService.Object, new NullLogger<ParagraphsController>());
var paragraphsResult = ParagraphsController.GetParagraphById(100);
if (paragraphsResult is NotFoundObjectResult NFObjectResult)
{
var valeur = NFObjectResult.Value;
Assert.NotNull(valeur);
Assert.IsNotType<ParagraphDTO>(valeur);
Assert.DoesNotContain(valeur, paragraphsList);
}
}
@ -102,7 +156,7 @@ namespace TestAPI
List<ParagraphDTO> paragraphsData = new List<ParagraphDTO>(4) List<ParagraphDTO> paragraphsData = new List<ParagraphDTO>(4)
{ {
new (0,"Titre 1","Le contenu","Les infos de ce paragraphes sont ","Select * from C#","Le commentaire",1), new (0,"Titre 1","Le contenu","Les infos de ce paragraphes sont ","Select * from C#","Le commentaire",1),
new (1,"Le titre","pas contenu","Pas d'infos ici ","Delete * from Earth","Miam",2), new (1,"Le titre","pas contenu","Pas d'infos ici","Delete * from Earth","Miam",2),
new (2,"Ceci n'est pas un titre","Certainement hmmm","OUOOOOO ","Autocommit = {true}","First",1), new (2,"Ceci n'est pas un titre","Certainement hmmm","OUOOOOO ","Autocommit = {true}","First",1),
new ("Title","Content","Je ne parle pas anglais","Select select from select","Mais qui est ce commentaire",3), new ("Title","Content","Je ne parle pas anglais","Select select from select","Mais qui est ce commentaire",3),

Loading…
Cancel
Save