From f1029e3e444ac67f7af3456df866b7c23714ca83 Mon Sep 17 00:00:00 2001 From: masapountz Date: Fri, 15 Mar 2024 22:38:49 +0100 Subject: [PATCH] TU Delete ParagraphController --- API_SQLuedo/TestAPI/ParagraphsUnitTest.cs | 33 +++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/API_SQLuedo/TestAPI/ParagraphsUnitTest.cs b/API_SQLuedo/TestAPI/ParagraphsUnitTest.cs index c1ca68c..73e22d1 100644 --- a/API_SQLuedo/TestAPI/ParagraphsUnitTest.cs +++ b/API_SQLuedo/TestAPI/ParagraphsUnitTest.cs @@ -167,6 +167,39 @@ namespace TestAPI } + [Fact] + public void DeleteParagraphSuccess() + { + paragraphService.Setup(x => x.DeleteParagraph(1)) + .Returns(true); + var ParagraphsController = new ParagraphsController(paragraphService.Object, new NullLogger()); + + var paragraphsResult = ParagraphsController.DeleteParagraph(1); + if (paragraphsResult is OkObjectResult okObjectResult) + { + bool valeur = (bool)okObjectResult.Value; + + Assert.True(valeur); + } + + } + + + [Fact] + public void DeleteParagraphFail() + { + paragraphService.Setup(x => x.DeleteParagraph(1)) + .Returns(true); + var ParagraphsController = new ParagraphsController(paragraphService.Object, new NullLogger()); + + var paragraphsResult = ParagraphsController.DeleteParagraph(100); + if (paragraphsResult is NotFoundObjectResult NFObjectResult) + { + Assert.Null(NFObjectResult.Value); + Assert.IsNotType(NFObjectResult.Value); + } + } +