From 9131895ab562aca4fca6f6ce0b29cfb3ccc6beca Mon Sep 17 00:00:00 2001 From: masapountz Date: Sat, 16 Mar 2024 10:45:34 +0100 Subject: [PATCH] TU Delete LessonController --- API_SQLuedo/TestAPI/LessonUnitTest.cs | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/API_SQLuedo/TestAPI/LessonUnitTest.cs b/API_SQLuedo/TestAPI/LessonUnitTest.cs index e368d50..c11aed1 100644 --- a/API_SQLuedo/TestAPI/LessonUnitTest.cs +++ b/API_SQLuedo/TestAPI/LessonUnitTest.cs @@ -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()); + + 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()); + + var lessonsResult = LessonsController.DeleteLesson(100); + if (lessonsResult is NotFoundObjectResult NFObjectResult) + { + Assert.Null(NFObjectResult.Value); + Assert.IsNotType(NFObjectResult.Value); + } + } +