예제 #1
0
        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();
        }
예제 #2
0
 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;
 }
예제 #5
0
 public void Add(FinancierDbContext dbContext, Entities.Currency currencyEntity)
 {
     dbContext.Currencies.Add(currencyEntity);
     dbContext.SaveChanges();
 }