Ejemplo n.º 1
0
        public void InitContext()
        {
            var builder = new DbContextOptionsBuilder <SQLiteLogQuakeContext>()
                          .UseInMemoryDatabase(databaseName: "Add_writes_to_database");

            _context = new SQLiteLogQuakeContext(builder.Options);

            IMemoryCache cache = new MemoryCache(new MemoryCacheOptions());

            LoggerFactory loggerFactoryServices = new LoggerFactory();

            loggerFactoryServices.AddConsole(LogLevel.None);
            loggerFactoryServices.AddDebug(LogLevel.None);
            _loggerLogQuakeServices = new Logger <LogQuakeService>(loggerFactoryServices);

            _unitOfWork = new UnitOfWork(_context, cache, _configuration);

            _logQuakeService = new LogQuakeService(_unitOfWork, cache, _loggerLogQuakeServices, _configuration);

            LoggerFactory loggerFactory = new LoggerFactory();

            loggerFactory.AddConsole(LogLevel.None);
            loggerFactory.AddDebug(LogLevel.None);
            _loggerGamesController = new Logger <GamesController>(loggerFactory);

            _configuration = new ConfigurationBuilder()
                             .SetBasePath(System.AppContext.BaseDirectory)
                             .AddJsonFile("appsettings.json")
                             .Build();
        }
Ejemplo n.º 2
0
        public void InitContext()
        {
            var builder = new DbContextOptionsBuilder <SQLiteLogQuakeContext>()
                          .UseInMemoryDatabase(databaseName: "Add_writes_to_database");

            _context = new SQLiteLogQuakeContext(builder.Options);

            IMemoryCache cache = new MemoryCache(new MemoryCacheOptions());

            _killRepository = new KillRepository(_context, cache, _configuration);

            _configuration = new ConfigurationBuilder()
                             .SetBasePath(System.AppContext.BaseDirectory)
                             .AddJsonFile("appsettings.json")
                             .Build();
        }
Ejemplo n.º 3
0
        public Startup(IConfiguration configuration, ILogger <Startup> logger)
        {
            Configuration = configuration;
            _logger       = logger;

            string BancoDeDados = Configuration["DataBase"].ToString().ToUpper();

            if (BancoDeDados == "SQLITE")
            {
                string stringConnection = this.Configuration.GetConnectionString("SQLiteConnectionString");
                DbContextOptionsBuilder optionsBuilder = new DbContextOptionsBuilder <LogQuakeContext>();
                optionsBuilder.UseSqlite(stringConnection);

                // Cria o Banco de Dados para SqLite
                using (var client = new SQLiteLogQuakeContext(optionsBuilder.Options))
                {
                    client.Database.EnsureCreated();
                }
            }
        }
Ejemplo n.º 4
0
 public void Cleanup()
 {
     _context.Database.EnsureDeleted();
     _context.Dispose();
     _context = null;
 }