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");
            }
        }
    }
}
