You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.3 KiB
50 lines
1.3 KiB
using DbConnectionLibrairie;
|
|
using Microsoft.Data.Sqlite;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using StubbedDbContextLibrary;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
|
|
|
|
namespace UnitTestsEntityManagers
|
|
{
|
|
/// <summary>
|
|
/// an abstract class to init the dbContext
|
|
/// (every unit tests need to implement it)
|
|
/// </summary>
|
|
public abstract class AbstractUnitTestEM
|
|
{
|
|
protected DbContextOptions<MyDbContext> opt;
|
|
|
|
/// <summary>
|
|
/// constructor of the class :
|
|
/// initialise the database context
|
|
/// </summary>
|
|
public AbstractUnitTestEM()
|
|
{
|
|
|
|
}
|
|
|
|
protected void creerOpt(string provider, string connectionString)
|
|
{
|
|
if(provider == "sqlite")
|
|
{
|
|
var connection = new SqliteConnection("DataSource=:memory:");
|
|
|
|
connection.Open();
|
|
|
|
opt = new DbContextOptionsBuilder<MyDbContext>()
|
|
.UseSqlite(connection)
|
|
.Options;
|
|
}
|
|
else
|
|
{
|
|
throw new Exception("provider unknown");
|
|
}
|
|
}
|
|
}
|
|
}
|