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.
3.01-QCM_MuscuMaths/WebApi/UnitTestsEntityManagers/AbstractUnitTestEM.cs

42 lines
1.0 KiB

using DbConnectionLibrairie;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UnitTestsEntityManagers
{
/// <summary>
/// an abstract class to init the dbContext
/// (every unit tests need to implement it)
/// </summary>
public abstract class AbstractUnitTestEM
{
protected MyDbContext dbContext;
/// <summary>
/// constructor of the class :
/// initialise the dbContext
/// </summary>
public AbstractUnitTestEM()
{
var opt = new DbContextOptionsBuilder<MyDbContext>()
.UseSqlite("DataSource=:memory:")
.Options;
dbContext = new MyDbContext(opt);
}
/// <summary>
/// destructor of the class :
/// dispose the database context
/// </summary>
~AbstractUnitTestEM()
{
dbContext.DisposeAsync();
}
}
}