public void Data_Create_Account()
        {
            var repository = new AccountRepository(_dataConnectionString, 1);

            var account = new MABMoney.Domain.Account {
                Name = "ADDED",
                StartingBalance = 123.45M,
                Default = true,
                Type = AccountType.Savings,
                DisplayOrder = 50,
                IncludeInNetWorth = false
            };

            var result = repository.Add(account);

            Assert.IsTrue(result.AccountID == 6);
            Assert.IsTrue(result.Name == "ADDED");
            Assert.IsTrue(result.StartingBalance == 123.45M);
            Assert.IsTrue(result.Default == true);
            Assert.IsTrue(result.Type == AccountType.Savings);
            Assert.IsTrue(result.DisplayOrder == 50);
            Assert.IsTrue(result.User_UserID == 1);
            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);
            Assert.IsTrue(result.CurrentBalance == 123.45M);
            Assert.IsTrue(result.IncludeInNetWorth == false);
        }
        public void Data_Read_Other_User_Account()
        {
            var repository = new AccountRepository(_dataConnectionString, 1);

            var data = repository.Get(5);

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

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

            // There are 5 test accounts, but one is deleted and one is for another user
            Assert.IsTrue(data.Count == 3);
            Assert.IsTrue(data[0].AccountID == 1);
            Assert.IsTrue(data[0].Name == "Current");
            Assert.IsTrue(data[1].AccountID == 2);
            Assert.IsTrue(data[1].Name == "Savings");
            Assert.IsTrue(data[2].AccountID == 3);
            Assert.IsTrue(data[2].Name == "Credit");
        }
        public void Data_Read_Account()
        {
            var repository = new AccountRepository(_dataConnectionString, 1);

            var data = repository.Get(1);

            Assert.IsTrue(data.AccountID == 1);
            Assert.IsTrue(data.Name == "Current");
            Assert.IsTrue(data.StartingBalance == 100.00M);
            Assert.IsTrue(data.Default == true);
            Assert.IsTrue(data.Type == AccountType.Current);
            Assert.IsTrue(data.DisplayOrder == 100);
            Assert.IsTrue(data.User_UserID == 1);
            Assert.IsTrue(data.CreatedBy == 1);
            Assert.IsTrue(data.CreatedDate.Date == new DateTime(2015, 1, 1));
            Assert.IsTrue(data.LastModifiedBy == 1);
            Assert.IsTrue(data.LastModifiedDate.Date == new DateTime(2015, 1, 1));
            Assert.IsTrue(data.CurrentBalance == 345.00M);
            Assert.IsTrue(data.IncludeInNetWorth == true);
        }
        public void Data_Delete_Account()
        {
            var repository = new AccountRepository(_dataConnectionString, 1);

            var result = repository.Delete(1);

            var account = repository.Get(1);

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

            var account = repository.Get(1);

            account.Name = "UPDATED";
            account.StartingBalance = 256.12M;
            account.Default = false;
            account.Type = AccountType.CreditCard;
            account.DisplayOrder = 126;
            account.IncludeInNetWorth = false;

            var result = repository.Update(account);

            Assert.IsTrue(result.Name == "UPDATED");
            Assert.IsTrue(result.StartingBalance == 256.12M);
            Assert.IsTrue(result.Default == false);
            Assert.IsTrue(result.Type == AccountType.CreditCard);
            Assert.IsTrue(result.DisplayOrder == 126);
            // This will have been updated by the total calc trigger when the test transactions are inserted
            Assert.IsTrue(result.CurrentBalance == 501.12M);
            Assert.IsTrue(result.LastModifiedBy == 1);
            Assert.IsTrue(result.LastModifiedDate.Date == DateTime.Now.Date);
        }