Esempio n. 1
0
        public void DbSetup()
        {
            string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "expensemanager.db3");

            if (File.Exists(dbPath))
            {
                File.Delete(dbPath);
            }

            _repository = new RepositoryCore(new LogService());
            _db         = _repository.CreateDataBase(dbPath, new SQLitePlatformIOS(), true);
        }
Esempio n. 2
0
        public void CreateDataBase_IfDbDoesNotExist_CheckDb()
        {
            if (File.Exists(_dbPath))
            {
                File.Delete(_dbPath);
            }

            var core = new RepositoryCore(new LogService());

            core.CreateDataBase(_dbPath, new SQLitePlatformIOS(), true);

            Assert.IsTrue(File.Exists(_dbPath));
        }
Esempio n. 3
0
        public void CreateDataBase_IfDbDoesNotExist_CheckCategoryTable()
        {
            if (File.Exists(_dbPath))
            {
                File.Delete(_dbPath);
            }

            var core = new RepositoryCore(new LogService());

            core.CreateDataBase(_dbPath, new SQLitePlatformIOS(), true);

            var db         = new SQLiteConnection(new SQLitePlatformIOS(), _dbPath);
            var categories = db.Table <Category>();

            Assert.IsTrue(categories.Count() > 0, "Category table hasn't been created.");
        }
        public static void SetUpDatabase(bool deleteIfExist, bool withSeeding)
        {
            string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "expensemanager.db3");

            if (File.Exists(dbPath) && deleteIfExist)
            {
                File.Delete(dbPath);
            }

            var repositoryCore = new RepositoryCore(GetLogService());

            if (File.Exists(dbPath))
            {
                repositoryCore.SetUpDataBaseConnection(dbPath, new SQLitePlatformIOS());
            }
            else
            {
                repositoryCore.CreateDataBase(dbPath, new SQLitePlatformIOS(), withSeeding);
            }
        }