TU Delete LessonController

pull/40/head
Maxime SAPOUNTZIS 1 year ago
parent 98b2a4ce95
commit 9131895ab5

@ -161,8 +161,39 @@ namespace TestAPI
}
[Fact]
public void DeleteLessonSuccess()
{
lessonService.Setup(x => x.DeleteLesson(1))
.Returns(true);
var LessonsController = new LessonsController(lessonService.Object, new NullLogger<LessonsController>());
var lessonsResult = LessonsController.DeleteLesson(1);
if (lessonsResult is OkObjectResult okObjectResult)
{
bool valeur = (bool)okObjectResult.Value;
Assert.True(valeur);
}
}
[Fact]
public void DeleteLessonFail()
{
lessonService.Setup(x => x.DeleteLesson(1))
.Returns(true);
var LessonsController = new LessonsController(lessonService.Object, new NullLogger<LessonsController>());
var lessonsResult = LessonsController.DeleteLesson(100);
if (lessonsResult is NotFoundObjectResult NFObjectResult)
{
Assert.Null(NFObjectResult.Value);
Assert.IsNotType<bool>(NFObjectResult.Value);
}
}

Loading…
Cancel
Save