@ -201,7 +201,44 @@ namespace TestAPI
}
}
[Fact]
public void CreateParagraphSuccess ( )
{
paragraphService . Setup ( x = > x . CreateParagraph ( "Le nouveau titre" , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) )
. Returns ( new ParagraphDTO ( "Le nouveau titre" , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) ) ;
var ParagraphsController = new ParagraphsController ( paragraphService . Object , new NullLogger < ParagraphsController > ( ) ) ;
var paragraphsResult = ParagraphsController . CreateParagraph ( new ParagraphDTO ( "Le nouveau titre" , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) ) ;
if ( paragraphsResult is CreatedResult createdObjectResult )
{
ParagraphDTO valeur = createdObjectResult . Value as ParagraphDTO ;
Assert . NotNull ( valeur ) ;
Assert . Equal ( "Le nouveau titre" , valeur . Title ) ;
Assert . Equal ( "Le nouveau content" , valeur . Content ) ;
Assert . Equal ( "Les infos" , valeur . Info ) ;
Assert . Equal ( "La requête requêtante" , valeur . Query ) ;
Assert . Equal ( "Commentaires" , valeur . Comment ) ;
Assert . Equal ( 2 , valeur . LessonId ) ;
}
}
[Fact]
public void CreateParagraphFail ( )
{
paragraphService . Setup ( x = > x . CreateParagraph ( "Le nouveau titre" , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) )
. Returns ( new ParagraphDTO ( "Le nouveau titre" , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) ) ;
var ParagraphsController = new ParagraphsController ( paragraphService . Object , new NullLogger < ParagraphsController > ( ) ) ;
var paragraphsResult = ParagraphsController . CreateParagraph ( new ParagraphDTO ( null , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) ) ;
if ( paragraphsResult is BadRequestResult BDObjectResult )
{
Assert . Equal ( 400 , BDObjectResult . StatusCode ) ;
}
}