public void Data_Read_Transactions_By_Account_Date_And_Category()
        {
            var repository = new TransactionRepository(_dataConnectionString, 1);

            var data = repository.GetForAccount(1, 4, new DateTime(2015, 01, 02), new DateTime(2015, 01, 06)).ToList();

            Assert.IsTrue(data.Count == 4);
            Assert.IsTrue(data[0].TransactionID == 14);
            Assert.IsTrue(data[0].Category_CategoryID == 4);
            Assert.IsTrue(data[0].CategoryName == "Bills");
            Assert.IsTrue(data[0].Description == "USER1CURRENT14");
            Assert.IsTrue(data[0].Note == "Water");
            Assert.IsTrue(data[1].TransactionID == 11);
            Assert.IsTrue(data[1].Category_CategoryID == 4);
            Assert.IsTrue(data[1].CategoryName == "Bills");
            Assert.IsTrue(data[1].Description == "USER1CURRENT11");
            Assert.IsTrue(data[1].Note == "Electricity");
            Assert.IsTrue(data[2].TransactionID == 7);
            Assert.IsTrue(data[2].Category_CategoryID == 4);
            Assert.IsTrue(data[2].CategoryName == "Bills");
            Assert.IsTrue(data[2].Description == "USER1CURRENT7");
            Assert.IsTrue(data[2].Note == "Mobile");
            Assert.IsTrue(data[3].TransactionID == 4);
            Assert.IsTrue(data[3].Category_CategoryID == 4);
            Assert.IsTrue(data[3].CategoryName == "Bills");
            Assert.IsTrue(data[3].Description == "USER1CURRENT4");
            Assert.IsTrue(data[3].Note == "Gas");
        }
        public void Data_Sum_Transactions_By_Account_Up_To_Date()
        {
            var repository = new TransactionRepository(_dataConnectionString, 1);

            var sum = repository.GetTotalForAccountUpTo(1, new DateTime(2015, 01, 03));

            Assert.IsTrue(sum == 535.50M);
        }
        public void Data_Read_Transactions_By_Account()
        {
            var repository = new TransactionRepository(_dataConnectionString, 1);

            var data = repository.GetForAccount(1).ToList();

            // There are 15 test transactions for this user (and one deleted) in date descending order
            Assert.IsTrue(data.Count == 15);
            Assert.IsTrue(data[0].TransactionID == 31);
            Assert.IsTrue(data[0].Category_CategoryID == null);
            Assert.IsTrue(data[0].CategoryName == null);
            Assert.IsTrue(data[0].Description == "USER1CURRENT15");
            Assert.IsTrue(data[0].Amount == -5.00M);
            Assert.IsTrue(data[14].TransactionID == 1);
            Assert.IsTrue(data[14].Category_CategoryID == 1);
            Assert.IsTrue(data[14].CategoryName == "Salary");
            Assert.IsTrue(data[14].Description == "USER1CURRENT1");
            Assert.IsTrue(data[14].Amount == 1000.00M);
        }
        public void Data_Read_Transactions_By_Account_And_Date()
        {
            var repository = new TransactionRepository(_dataConnectionString, 1);

            var data = repository.GetForAccount(1, new DateTime(2015, 01, 02), new DateTime(2015, 01, 04)).ToList();

            Assert.IsTrue(data.Count == 7);
            Assert.IsTrue(data[0].TransactionID == 10);
            Assert.IsTrue(data[0].Category_CategoryID == 3);
            Assert.IsTrue(data[0].CategoryName == "Food");
            Assert.IsTrue(data[0].Description == "USER1CURRENT10");
            Assert.IsTrue(data[0].Note == null);
            Assert.IsTrue(data[6].TransactionID == 4);
            Assert.IsTrue(data[6].Category_CategoryID == 4);
            Assert.IsTrue(data[6].CategoryName == "Bills");
            Assert.IsTrue(data[6].Description == "USER1CURRENT4");
            Assert.IsTrue(data[6].Note == "Gas");
        }
        public void Data_Read_Transaction()
        {
            var repository = new TransactionRepository(_dataConnectionString, 1);

            var data = repository.Get(1);

            Assert.IsTrue(data.TransactionID == 1);
            Assert.IsTrue(data.Category_CategoryID == 1);
            Assert.IsTrue(data.CategoryName == "Salary");
            Assert.IsTrue(data.Description == "USER1CURRENT1");
        }
        public void Data_Read_Transactions()
        {
            var repository = new TransactionRepository(_dataConnectionString, 1);

            var data = repository.All().ToList();

            // There are 19 test transactions for this user (and one deleted) in date descending order
            Assert.IsTrue(data.Count == 19);
            Assert.IsTrue(data[0].Account_AccountID == 1);
            Assert.IsTrue(data[0].AccountName == "Current");
            Assert.IsTrue(data[0].TransactionID == 31);
            Assert.IsTrue(data[0].Category_CategoryID == null);
            Assert.IsTrue(data[0].CategoryName == null);
            Assert.IsTrue(data[0].Description == "USER1CURRENT15");
            Assert.IsTrue(data[0].Amount == -5.00M);
            Assert.IsTrue(data[1].Account_AccountID == 1);
            Assert.IsTrue(data[1].AccountName == "Current");
            Assert.IsTrue(data[1].TransactionID == 14);
            Assert.IsTrue(data[1].Category_CategoryID == 4);
            Assert.IsTrue(data[1].CategoryName == "Bills");
            Assert.IsTrue(data[1].Description == "USER1CURRENT14");
            Assert.IsTrue(data[1].Note == "Water");
            Assert.IsTrue(data[1].Amount == -25.00M);
            Assert.IsTrue(data[6].Account_AccountID == 2);
            Assert.IsTrue(data[6].AccountName == "Savings");
            Assert.IsTrue(data[6].TransactionID == 19);
            Assert.IsTrue(data[6].Category_CategoryID == null);
            Assert.IsTrue(data[6].CategoryName == null);
            Assert.IsTrue(data[6].Description == "USER1SAVINGS19");
            Assert.IsTrue(data[6].Amount == 9.50M);
            Assert.IsTrue(data[18].Account_AccountID == 1);
            Assert.IsTrue(data[18].AccountName == "Current");
            Assert.IsTrue(data[18].TransactionID == 1);
            Assert.IsTrue(data[18].Category_CategoryID == 1);
            Assert.IsTrue(data[18].CategoryName == "Salary");
            Assert.IsTrue(data[18].Description == "USER1CURRENT1");
            Assert.IsTrue(data[18].Amount == 1000.00M);
        }
        public void Data_Read_Other_User_Transactions_By_Account()
        {
            var repository = new TransactionRepository(_dataConnectionString, 1);

            var data = repository.GetForAccount(5).ToList();

            Assert.IsTrue(data.Count == 0);
        }
        public void Data_Read_Other_User_Transaction()
        {
            var repository = new TransactionRepository(_dataConnectionString, 1);

            var data = repository.Get(21);

            Assert.IsTrue(data == null);
        }
        public void Data_Delete_Transaction()
        {
            var repository = new TransactionRepository(_dataConnectionString, 1);

            var result = repository.Delete(1);

            var transaction = repository.Get(1);

            Assert.IsTrue(transaction == null);
            Assert.IsTrue(result.Deleted == true);
            Assert.IsTrue(result.DeletedBy == 1);
            Assert.IsTrue(result.DeletedDate.Value.Date == DateTime.Now.Date);
        }
        public void Data_Create_Transaction()
        {
            var repository = new TransactionRepository(_dataConnectionString, 1);

            var transaction = new MABMoney.Domain.Transaction {
                Account_AccountID = 1,
                Category_CategoryID = 3,
                Description = "ADDED",
                Amount = -10.25M,
                Date = new DateTime(2015, 1, 10, 18, 35, 10, 0),
                Note = "BISCUITS",
                TransferGUID = "5485364b-cac5-4c14-9638-5e7c0235a7c1"
            };

            var result = repository.Add(transaction);

            Assert.IsTrue(result.TransactionID == 32);
            Assert.IsTrue(result.Account_AccountID == 1);
            Assert.IsTrue(result.AccountName == "Current");
            Assert.IsTrue(result.Category_CategoryID == 3);
            Assert.IsTrue(result.CategoryName == "Food");
            Assert.IsTrue(result.Description == "ADDED");
            Assert.IsTrue(result.Amount == -10.25M);
            Assert.IsTrue(result.Date == new DateTime(2015, 1, 10, 18, 35, 10, 0));
            Assert.IsTrue(result.Note == "BISCUITS");
            Assert.IsTrue(result.TransferGUID == "5485364b-cac5-4c14-9638-5e7c0235a7c1");
            Assert.IsTrue(result.CreatedBy == 1);
            Assert.IsTrue(result.CreatedDate.Date == DateTime.Now.Date);
            Assert.IsTrue(result.LastModifiedBy == 1);
            Assert.IsTrue(result.LastModifiedDate.Date == DateTime.Now.Date);
        }
        public void Data_Update_Transaction()
        {
            var repository = new TransactionRepository(_dataConnectionString, 1);

            var transaction = repository.Get(1);

            transaction.Account_AccountID = 3;
            transaction.Category_CategoryID = 6;
            transaction.Description = "UPDATED";
            transaction.Amount = -30.00M;
            transaction.Date = new DateTime(2015, 1, 11, 11, 40, 30, 0);
            transaction.Note = "MOVEDTOCREDIT";
            transaction.TransferGUID = "5485364b-cac5-4c14-9638-5e7c0235a7c1";

            var result = repository.Update(transaction);

            Assert.IsTrue(result.TransactionID == 1);
            Assert.IsTrue(result.Account_AccountID == 3);
            Assert.IsTrue(result.AccountName == "Credit");
            Assert.IsTrue(result.Category_CategoryID == 6);
            Assert.IsTrue(result.CategoryName == "Payments");
            Assert.IsTrue(result.Description == "UPDATED");
            Assert.IsTrue(result.Amount == -30.00M);
            Assert.IsTrue(result.Date == new DateTime(2015, 1, 11, 11, 40, 30, 0));
            Assert.IsTrue(result.Note == "MOVEDTOCREDIT");
            Assert.IsTrue(result.TransferGUID == "5485364b-cac5-4c14-9638-5e7c0235a7c1");
            Assert.IsTrue(result.LastModifiedBy == 1);
            Assert.IsTrue(result.LastModifiedDate.Date == DateTime.Now.Date);
        }