|
|
@ -16,12 +16,12 @@ namespace TestUnitaire
|
|
|
|
var connection = new SqliteConnection("DataSource=:memory:");
|
|
|
|
var connection = new SqliteConnection("DataSource=:memory:");
|
|
|
|
connection.Open();
|
|
|
|
connection.Open();
|
|
|
|
|
|
|
|
|
|
|
|
var options = new DbContextOptionsBuilder<ChampionContext>()
|
|
|
|
var options = new DbContextOptionsBuilder<MyDbContext>()
|
|
|
|
.UseSqlite(connection)
|
|
|
|
.UseSqlite(connection)
|
|
|
|
.Options;
|
|
|
|
.Options;
|
|
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
// Act
|
|
|
|
using (var context = new ChampionContext(options))
|
|
|
|
using (var context = new MyDbContext(options))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await context.Database.EnsureCreatedAsync();
|
|
|
|
await context.Database.EnsureCreatedAsync();
|
|
|
|
var Dieu = new ChampionEntity
|
|
|
|
var Dieu = new ChampionEntity
|
|
|
@ -50,12 +50,12 @@ namespace TestUnitaire
|
|
|
|
var connection = new SqliteConnection("DataSource=:memory:");
|
|
|
|
var connection = new SqliteConnection("DataSource=:memory:");
|
|
|
|
connection.Open();
|
|
|
|
connection.Open();
|
|
|
|
|
|
|
|
|
|
|
|
var options = new DbContextOptionsBuilder<ChampionContext>()
|
|
|
|
var options = new DbContextOptionsBuilder<MyDbContext>()
|
|
|
|
.UseSqlite(connection)
|
|
|
|
.UseSqlite(connection)
|
|
|
|
.Options;
|
|
|
|
.Options;
|
|
|
|
|
|
|
|
|
|
|
|
//prepares the database with one instance of the context
|
|
|
|
//prepares the database with one instance of the context
|
|
|
|
using (var context = new ChampionContext(options))
|
|
|
|
using (var context = new MyDbContext(options))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//context.Database.OpenConnection();
|
|
|
|
//context.Database.OpenConnection();
|
|
|
|
context.Database.EnsureCreated();
|
|
|
|
context.Database.EnsureCreated();
|
|
|
@ -72,7 +72,7 @@ namespace TestUnitaire
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//uses another instance of the context to do the tests
|
|
|
|
//uses another instance of the context to do the tests
|
|
|
|
using (var context = new ChampionContext(options))
|
|
|
|
using (var context = new MyDbContext(options))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
context.Database.EnsureCreated();
|
|
|
|
context.Database.EnsureCreated();
|
|
|
|
|
|
|
|
|
|
|
@ -86,7 +86,7 @@ namespace TestUnitaire
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//uses another instance of the context to do the tests
|
|
|
|
//uses another instance of the context to do the tests
|
|
|
|
using (var context = new ChampionContext(options))
|
|
|
|
using (var context = new MyDbContext(options))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
context.Database.EnsureCreated();
|
|
|
|
context.Database.EnsureCreated();
|
|
|
|
|
|
|
|
|
|
|
|