public void CategoryRepository_Update()
        {
            var dbHelper = new DbHelper(new SQLitePlatformWinRT(), new TestDatabasePath());

            using (var db = dbHelper.GetSqlConnection())
            {
                db.DeleteAll<Category>();
            }

            var repository = new CategoryRepository(new CategoryDataAccess(dbHelper));

            var category = new Category
            {
                Name = "Ausgang"
            };

            repository.Save(category);
            Assert.AreEqual(1, repository.Data.Count);
            Assert.AreSame(category, repository.Data[0]);

            category.Name = "newName";

            repository.Save(category);

            Assert.AreEqual(1, repository.Data.Count);
            Assert.AreEqual("newName", repository.Data[0].Name);
        }
        public void RecurringTransactionRepository_Update()
        {
            var dbHelper = new DbHelper(new SQLitePlatformWinRT(), new TestDatabasePath());

            using (var db = dbHelper.GetSqlConnection())
            {
                db.DeleteAll<RecurringTransaction>();
            }

            var repository = new RecurringTransactionRepository(new RecurringTransactionDataAccess(dbHelper));

            var account = new Account
            {
                Name = "TestAccount"
            };

            var transaction = new RecurringTransaction
            {
                ChargedAccount = account,
                Amount = 20,
                AmountWithoutExchange = 20
            };

            repository.Save(transaction);
            Assert.AreEqual(1, repository.Data.Count);
            Assert.AreSame(transaction, repository.Data[0]);

            transaction.Amount = 789;

            repository.Save(transaction);

            Assert.AreEqual(1, repository.Data.Count);
            Assert.AreEqual(789, repository.Data[0].Amount);
        }
Пример #3
0
        public void DatabaseLogic_CreateDatabase()
        {
            var dbHelper = new DbHelper(new SQLitePlatformWinRT(), new TestDatabasePath());

            using (var dbConn = dbHelper.GetSqlConnection())
            {
                var temp1 = dbConn.Table<Account>().ToList();
                var temp2 = dbConn.Table<FinancialTransaction>().ToList();
                var temp3 = dbConn.Table<RecurringTransaction>().ToList();
                var temp4 = dbConn.Table<Category>().ToList();
            }
        }
        public void CategoryRepositor_LoadDataFromDbThroughRepository()
        {
            var dbHelper = new DbHelper(new SQLitePlatformWinRT(), new TestDatabasePath());

            using (var db = dbHelper.GetSqlConnection())
            {
                db.DeleteAll<Category>();
                db.InsertWithChildren(new Category
                {
                    Name = "Foooo"
                });
            }

            var repository = new CategoryRepository(new CategoryDataAccess(dbHelper));

            Assert.IsTrue(repository.Data.Any());
            Assert.AreEqual("Foooo", repository.Data[0].Name);
        }
        public void RecurringTransactionRepository_LoadDataFromDbThroughRepository()
        {
            var dbHelper = new DbHelper(new SQLitePlatformWinRT(), new TestDatabasePath());

            using (var db = dbHelper.GetSqlConnection())
            {
                db.DeleteAll<RecurringTransaction>();
                db.InsertWithChildren(new RecurringTransaction
                {
                    Amount = 999,
                    AmountWithoutExchange = 777,
                    ChargedAccount = new Account
                    {
                        Name = "testAccount"
                    }
                });
            }

            var repository = new RecurringTransactionRepository(new RecurringTransactionDataAccess(dbHelper));

            Assert.IsTrue(repository.Data.Any());
            Assert.AreEqual(999, repository.Data[0].Amount);
            Assert.AreEqual(777, repository.Data[0].AmountWithoutExchange);
        }
Пример #6
0
        public void SqlConnectionFactory_GetSqlConnectionWithParams()
        {
            var connection = new DbHelper(new SQLitePlatformWinRT(), new TestDatabasePath()).GetSqlConnection();

            Assert.IsInstanceOfType(connection, typeof(SQLiteConnection));
        }