public SqliteMemoryWrapper() { m_connection = new SqliteConnection("DataSource=:memory:"); m_connection.Open(); var dbContextOptionsBuilder = new DbContextOptionsBuilder <FinancierDbContext>() .UseSqlite(m_connection); DbContext = new FinancierDbContext(dbContextOptionsBuilder.Options); DbContext.Database.EnsureCreated(); }
public void TestCreateInMemoryInDbContext() { using (var sqliteMemoryWrapper = new SqliteMemoryWrapper()) { FinancierDbContext dbContext = sqliteMemoryWrapper.DbContext; Assert.AreEqual(0, dbContext.Accounts.Count()); Assert.AreEqual(0, dbContext.AccountRelationships.Count()); Assert.AreEqual(0, dbContext.Budgets.Count()); Assert.AreEqual(0, dbContext.BudgetTransactions.Count()); Assert.AreEqual(0, dbContext.Currencies.Count()); Assert.AreEqual(0, dbContext.Transactions.Count()); Assert.AreEqual(0, dbContext.TransactionRelationships.Count()); } }
public DatabaseSerializationXmlService(ILoggerFactory loggerFactory, FinancierDbContext dbContext) { m_logger = loggerFactory.CreateLogger <DatabaseSerializationXmlService>(); m_dbContext = dbContext; }
public AccountRelationshipService(ILoggerFactory loggerFactory, FinancierDbContext dbContext) { m_logger = loggerFactory.CreateLogger <AccountRelationshipService>(); m_dbContext = dbContext; }
public void Add(FinancierDbContext dbContext, Entities.Currency currencyEntity) { dbContext.Currencies.Add(currencyEntity); dbContext.SaveChanges(); }