public void TransactionDataAccess_CrudTransaction()
        {
            var transactionDataAccess =
                new TransactionDataAccess(new SqliteConnectionCreator(new WindowsSqliteConnectionFactory()));

            const double firstAmount = 76.30;
            const double secondAmount = 22.90;

            var transaction = new FinancialTransaction
            {
                ChargedAccount = new Account {Id = 4},
                Amount = firstAmount,
                Date = DateTime.Today,
                Note = "this is a note!!!",
                IsCleared = false
            };

            transactionDataAccess.SaveItem(transaction);

            var list = transactionDataAccess.LoadList();

            Assert.Equal(1, list.Count);
            Assert.Equal(firstAmount, list.First().Amount);

            transaction.Amount = secondAmount;

            transactionDataAccess.SaveItem(transaction);

            transactionDataAccess.LoadList();
            list = transactionDataAccess.LoadList();

            Assert.Equal(1, list.Count);
            Assert.Equal(secondAmount, list.First().Amount);

            transactionDataAccess.DeleteItem(transaction);

            transactionDataAccess.LoadList();
            list = transactionDataAccess.LoadList();
            Assert.False(list.Any());
        }
        public void SaveTransaction_ChargedAccountSet_AccountIdAssociated()
        {
            var transactionDataAccess =
                new TransactionDataAccess(new SqliteConnectionCreator(new WindowsSqliteConnectionFactory()));

            var transaction = new FinancialTransaction
            {
                ChargedAccount = new Account {Id = 4},
                Amount = 76.30,
                Date = DateTime.Today,
                Note = "this is a note!!!",
                IsCleared = false
            };

            transactionDataAccess.SaveItem(transaction);

            transaction.ChargedAccountId.ShouldBe(4);
        }
        public void LoadRecurringList_ListWithRecurringTransaction()
        {
            var dbHelper = new SqliteConnectionCreator(new WindowsSqliteConnectionFactory());

            var transactionDataAccess =
                new TransactionDataAccess(dbHelper);
            var recTransactionDataAccess =
                new RecurringTransactionDataAccess(dbHelper);
            var repository = new TransactionRepository(transactionDataAccess, recTransactionDataAccess);

            transactionDataAccess.SaveItem(new FinancialTransaction {Amount = 999, IsRecurring = false});
            transactionDataAccess.SaveItem(new FinancialTransaction
            {
                Amount = 123,
                IsRecurring = true,
                RecurringTransaction = new RecurringTransaction {IsEndless = true}
            });

            repository.Load();
            var result = repository.LoadRecurringList().ToList();

            result.Count.ShouldBe(1);

            result.First().Id.ShouldBe(2);
            result.First().RecurringTransaction.Id.ShouldBe(1);
        }