@ -7,12 +7,15 @@ namespace TestUnitaire
public class TestEfLol
public class TestEfLol
{
{
[Theory]
[Theory]
[InlineData("zeus","dieu")]
[InlineData("Zeus", "Dieu de la foudre", true)]
[InlineData("zeus", "dieu")]
[InlineData("Hades", "Dieu des enfers", true)]
[InlineData("zeus", "dieu")]
[InlineData("Aphrodite", "Déesse de l'amour", true)]
public async Task TestAddInMemory ( String name , String bio )
[ InlineData ( "AresAresAresAresAresAresAresAresAresAres" ,
"Dieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerre" +
"Dieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerre" +
"Dieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerre" , false ) ]
public async Task TestAddInMemory ( String name , String bio , bool expected )
{
{
// Arrange
var connection = new SqliteConnection ( "DataSource=:memory:" ) ;
var connection = new SqliteConnection ( "DataSource=:memory:" ) ;
connection . Open ( ) ;
connection . Open ( ) ;
@ -20,7 +23,6 @@ namespace TestUnitaire
. UseSqlite ( connection )
. UseSqlite ( connection )
. Options ;
. Options ;
// Act
using ( var context = new ChampionContext ( options ) )
using ( var context = new ChampionContext ( options ) )
{
{
await context . Database . EnsureCreatedAsync ( ) ;
await context . Database . EnsureCreatedAsync ( ) ;
@ -41,12 +43,25 @@ namespace TestUnitaire
Assert . Equal ( 1 , await context . Champions . CountAsync ( ) ) ;
Assert . Equal ( 1 , await context . Champions . CountAsync ( ) ) ;
Assert . Equal ( name , found . Name ) ;
Assert . Equal ( name , found . Name ) ;
// Test if the max length of the name is respected (30) and the max length of the bio is respected (256)
if ( expected )
{
Assert . True ( found . Name . Length < = 30 ) ;
Assert . True ( found . Bio . Length < = 256 ) ;
}
else
{
Assert . False ( found . Bio . Length < = 256 ) ;
Assert . False ( found . Name . Length < = 30 ) ;
}
}
}
}
}
[Fact]
[Fact]
public void ModifyTestInMemory ( )
public void ModifyTestInMemory ( )
{ //connection must be opened to use In-memory database
{
var connection = new SqliteConnection ( "DataSource=:memory:" ) ;
var connection = new SqliteConnection ( "DataSource=:memory:" ) ;
connection . Open ( ) ;
connection . Open ( ) ;
@ -98,7 +113,3 @@ namespace TestUnitaire
}
}
}
}
}
}