@ -16,11 +16,11 @@ namespace TestAPI
public class ParagraphsUnitTest
public class ParagraphsUnitTest
{
{
private readonly Mock < IParagraphService < ParagraphD TO > > paragraphService ;
private readonly Mock < IParagraphService < ParagraphD to > > paragraphService ;
public ParagraphsUnitTest ( )
public ParagraphsUnitTest ( )
{
{
paragraphService = new Mock < IParagraphService < ParagraphD TO > > ( ) ;
paragraphService = new Mock < IParagraphService < ParagraphD to > > ( ) ;
}
}
[Fact]
[Fact]
@ -39,7 +39,7 @@ namespace TestAPI
Assert . NotNull ( valeur ) ;
Assert . NotNull ( valeur ) ;
Assert . Equal ( GetParagraphsData ( ) . ToString ( ) , valeur . ToString ( ) ) ;
Assert . Equal ( GetParagraphsData ( ) . ToString ( ) , valeur . ToString ( ) ) ;
Assert . True ( paragraphsList . SequenceEqual ( valeur as IEnumerable < ParagraphD TO > , new ParagraphIdEqualityComparer ( ) ) ) ;
Assert . True ( paragraphsList . SequenceEqual ( valeur as IEnumerable < ParagraphD to > , new ParagraphIdEqualityComparer ( ) ) ) ;
}
}
@ -49,7 +49,7 @@ namespace TestAPI
public void GetParagraphsListFail ( )
public void GetParagraphsListFail ( )
{
{
paragraphService . Setup ( x = > x . GetParagraphs ( 1 , 4 , 0 ) )
paragraphService . Setup ( x = > x . GetParagraphs ( 1 , 4 , 0 ) )
. Returns ( new List < ParagraphD TO > ( ) ) ;
. Returns ( new List < ParagraphD to > ( ) ) ;
var ParagraphsController = new ParagraphsController ( paragraphService . Object , new NullLogger < ParagraphsController > ( ) ) ;
var ParagraphsController = new ParagraphsController ( paragraphService . Object , new NullLogger < ParagraphsController > ( ) ) ;
var paragraphsResult = ParagraphsController . GetParagraphs ( 1 , 4 , 0 ) ;
var paragraphsResult = ParagraphsController . GetParagraphs ( 1 , 4 , 0 ) ;
@ -76,7 +76,7 @@ namespace TestAPI
var paragraphsResult = ParagraphsController . GetParagraphById ( 1 ) ;
var paragraphsResult = ParagraphsController . GetParagraphById ( 1 ) ;
if ( paragraphsResult is OkObjectResult okObjectResult )
if ( paragraphsResult is OkObjectResult okObjectResult )
{
{
ParagraphD TO valeur = okObjectResult . Value as ParagraphD TO ;
ParagraphD to valeur = okObjectResult . Value as ParagraphD to ;
Assert . NotNull ( valeur ) ;
Assert . NotNull ( valeur ) ;
Assert . Equal ( "Le titre" , valeur . Title ) ;
Assert . Equal ( "Le titre" , valeur . Title ) ;
@ -91,7 +91,7 @@ namespace TestAPI
Assert . True ( valeur . Equals ( paragraphsList [ 1 ] ) ) ;
Assert . True ( valeur . Equals ( paragraphsList [ 1 ] ) ) ;
Assert . False ( valeur . Equals ( new object ( ) ) ) ;
Assert . False ( valeur . Equals ( new object ( ) ) ) ;
Assert . True ( valeur . Equals ( valeur ) ) ;
Assert . True ( valeur . Equals ( valeur ) ) ;
Assert . IsType < ParagraphD TO > ( valeur ) ;
Assert . IsType < ParagraphD to > ( valeur ) ;
Assert . Contains ( valeur , paragraphsList ) ;
Assert . Contains ( valeur , paragraphsList ) ;
}
}
@ -111,7 +111,7 @@ namespace TestAPI
var valeur = NFObjectResult . Value ;
var valeur = NFObjectResult . Value ;
Assert . NotNull ( valeur ) ;
Assert . NotNull ( valeur ) ;
Assert . IsNotType < ParagraphD TO > ( valeur ) ;
Assert . IsNotType < ParagraphD to > ( valeur ) ;
Assert . DoesNotContain ( valeur , paragraphsList ) ;
Assert . DoesNotContain ( valeur , paragraphsList ) ;
}
}
@ -129,7 +129,7 @@ namespace TestAPI
var paragraphsResult = ParagraphsController . GetParagraphByTitle ( "Title" ) ;
var paragraphsResult = ParagraphsController . GetParagraphByTitle ( "Title" ) ;
if ( paragraphsResult is OkObjectResult okObjectResult )
if ( paragraphsResult is OkObjectResult okObjectResult )
{
{
ParagraphD TO valeur = okObjectResult . Value as ParagraphD TO ;
ParagraphD to valeur = okObjectResult . Value as ParagraphD to ;
Assert . NotNull ( valeur ) ;
Assert . NotNull ( valeur ) ;
Assert . Equal ( "Title" , valeur . Title ) ;
Assert . Equal ( "Title" , valeur . Title ) ;
@ -138,7 +138,7 @@ namespace TestAPI
Assert . Equal ( "Select select from select" , valeur . Query ) ;
Assert . Equal ( "Select select from select" , valeur . Query ) ;
Assert . Equal ( "Mais qui est ce commentaire" , valeur . Comment ) ;
Assert . Equal ( "Mais qui est ce commentaire" , valeur . Comment ) ;
Assert . Equal ( 3 , valeur . LessonId ) ;
Assert . Equal ( 3 , valeur . LessonId ) ;
Assert . IsType < ParagraphD TO > ( valeur ) ;
Assert . IsType < ParagraphD to > ( valeur ) ;
Assert . Contains ( valeur , paragraphsList ) ;
Assert . Contains ( valeur , paragraphsList ) ;
}
}
@ -160,7 +160,7 @@ namespace TestAPI
var valeur = NFObjectResult . Value ;
var valeur = NFObjectResult . Value ;
Assert . NotNull ( valeur ) ;
Assert . NotNull ( valeur ) ;
Assert . IsNotType < ParagraphD TO > ( valeur ) ;
Assert . IsNotType < ParagraphD to > ( valeur ) ;
Assert . DoesNotContain ( valeur , paragraphsList ) ;
Assert . DoesNotContain ( valeur , paragraphsList ) ;
Assert . False ( paragraphsList = = valeur ) ;
Assert . False ( paragraphsList = = valeur ) ;
}
}
@ -205,13 +205,13 @@ namespace TestAPI
public void CreateParagraphSuccess ( )
public void CreateParagraphSuccess ( )
{
{
paragraphService . Setup ( x = > x . CreateParagraph ( "Le nouveau titre" , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) )
paragraphService . Setup ( x = > x . CreateParagraph ( "Le nouveau titre" , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) )
. Returns ( new ParagraphD TO ( "Le nouveau titre" , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) ) ;
. Returns ( new ParagraphD to ( "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 ParagraphsController = new ParagraphsController ( paragraphService . Object , new NullLogger < ParagraphsController > ( ) ) ;
var paragraphsResult = ParagraphsController . CreateParagraph ( new ParagraphD TO ( "Le nouveau titre" , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) ) ;
var paragraphsResult = ParagraphsController . CreateParagraph ( new ParagraphD to ( "Le nouveau titre" , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) ) ;
if ( paragraphsResult is CreatedResult createdObjectResult )
if ( paragraphsResult is CreatedResult createdObjectResult )
{
{
ParagraphD TO valeur = createdObjectResult . Value as ParagraphD TO ;
ParagraphD to valeur = createdObjectResult . Value as ParagraphD to ;
Assert . NotNull ( valeur ) ;
Assert . NotNull ( valeur ) ;
Assert . Equal ( "Le nouveau titre" , valeur . Title ) ;
Assert . Equal ( "Le nouveau titre" , valeur . Title ) ;
@ -228,10 +228,10 @@ namespace TestAPI
public void CreateParagraphFail ( )
public void CreateParagraphFail ( )
{
{
paragraphService . Setup ( x = > x . CreateParagraph ( "Le nouveau titre" , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) )
paragraphService . Setup ( x = > x . CreateParagraph ( "Le nouveau titre" , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) )
. Returns ( new ParagraphD TO ( "Le nouveau titre" , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) ) ;
. Returns ( new ParagraphD to ( "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 ParagraphsController = new ParagraphsController ( paragraphService . Object , new NullLogger < ParagraphsController > ( ) ) ;
var paragraphsResult = ParagraphsController . CreateParagraph ( new ParagraphD TO ( null , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) ) ;
var paragraphsResult = ParagraphsController . CreateParagraph ( new ParagraphD to ( null , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) ) ;
if ( paragraphsResult is BadRequestResult BDObjectResult )
if ( paragraphsResult is BadRequestResult BDObjectResult )
{
{
@ -244,14 +244,14 @@ namespace TestAPI
[Fact]
[Fact]
public void UpdateParagraphSuccess ( )
public void UpdateParagraphSuccess ( )
{
{
paragraphService . Setup ( x = > x . UpdateParagraph ( 1 , new ParagraphD TO ( 1 , "Le nouveau titre" , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) ) )
paragraphService . Setup ( x = > x . UpdateParagraph ( 1 , new ParagraphD to ( 1 , "Le nouveau titre" , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) ) )
. Returns ( new ParagraphD TO ( 1 , "Le nouveau titre" , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) ) ;
. Returns ( new ParagraphD to ( 1 , "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 ParagraphsController = new ParagraphsController ( paragraphService . Object , new NullLogger < ParagraphsController > ( ) ) ;
var paragraphsResult = ParagraphsController . UpdateParagraph ( 1 , new ParagraphD TO ( 1 , "Le nouveau titre" , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) ) ;
var paragraphsResult = ParagraphsController . UpdateParagraph ( 1 , new ParagraphD to ( 1 , "Le nouveau titre" , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) ) ;
if ( paragraphsResult is OkObjectResult okObjectResult )
if ( paragraphsResult is OkObjectResult okObjectResult )
{
{
ParagraphD TO valeur = okObjectResult . Value as ParagraphD TO ;
ParagraphD to valeur = okObjectResult . Value as ParagraphD to ;
Assert . NotNull ( valeur ) ;
Assert . NotNull ( valeur ) ;
Assert . Equal ( "Le nouveau titre" , valeur . Title ) ;
Assert . Equal ( "Le nouveau titre" , valeur . Title ) ;
@ -267,11 +267,11 @@ namespace TestAPI
[Fact]
[Fact]
public void UpdateParagraphFail ( )
public void UpdateParagraphFail ( )
{
{
paragraphService . Setup ( x = > x . UpdateParagraph ( 1 , new ParagraphD TO ( 1 , "Le nouveau titre" , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) ) )
paragraphService . Setup ( x = > x . UpdateParagraph ( 1 , new ParagraphD to ( 1 , "Le nouveau titre" , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) ) )
. Returns ( new ParagraphD TO ( 1 , "Le nouveau titre" , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) ) ;
. Returns ( new ParagraphD to ( 1 , "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 ParagraphsController = new ParagraphsController ( paragraphService . Object , new NullLogger < ParagraphsController > ( ) ) ;
var paragraphsResult = ParagraphsController . UpdateParagraph ( 1 , new ParagraphD TO ( 2 , "Le nouveau titre" , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) ) ;
var paragraphsResult = ParagraphsController . UpdateParagraph ( 1 , new ParagraphD to ( 2 , "Le nouveau titre" , "Le nouveau content" , "Les infos" , "La requête requêtante" , "Commentaires" , 2 ) ) ;
if ( paragraphsResult is BadRequestResult BDObjectResult )
if ( paragraphsResult is BadRequestResult BDObjectResult )
{
{
@ -279,9 +279,9 @@ namespace TestAPI
Assert . Equal ( 400 , BDObjectResult . StatusCode ) ;
Assert . Equal ( 400 , BDObjectResult . StatusCode ) ;
}
}
}
}
private List < ParagraphD TO > GetParagraphsData ( )
private List < ParagraphD to > GetParagraphsData ( )
{
{
List < ParagraphD TO > paragraphsData = new List < ParagraphD TO > ( 4 )
List < ParagraphD to > paragraphsData = new List < ParagraphD to > ( 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 ) ,