예제 #1
0
        public void ToTransactionTest()
        {
            var categoryFactory = new RegularCategoryFactory();
            var accountFactory  = new RegularAccountFactory();

            var quickTransaction = new QuickTransaction
            {
                Account = accountFactory.CreateAccount(
                    "TestAccount", "Description", "USD"),
                Category     = categoryFactory.CreateCategory("TestAccount", "Description", 0L, null),
                Name         = "TestName",
                AskForWeight = false,
                AskForTotal  = false,
                Total        = 2.34m,
                Weight       = 1
            };

            var transaction =
                QuickTransactionConverter.ToTransaction(new RegularTransactionFactory(), quickTransaction);

            Assert.AreEqual(quickTransaction.Account, transaction.Account);
            Assert.AreEqual(quickTransaction.Category, transaction.Category);
            Assert.AreEqual(quickTransaction.Total, transaction.Total);
            Assert.AreEqual(quickTransaction.Weight, transaction.Weight);
            Assert.AreEqual(quickTransaction.Name, transaction.Name);
        }
예제 #2
0
        public void Create2CategoriesTest()
        {
            var account1 = _factory.CreateAccount("Account 1", "Description", "UAH", 5);
            var account2 = _factory.CreateAccount("Account 2", "Description 2", "USD", 5);

            _storage.CreateAccount(account1);
            _storage.CreateAccount(account2);

            var newAccount = _storage.GetAllAccounts().FirstOrDefault();

            Assert.IsNotNull(newAccount);
            Assert.AreEqual(1, _storage.GetAllAccounts().Count());
            Assert.AreEqual(account2.Name, newAccount.Name);
            Assert.AreEqual(account2.Description, newAccount.Description);
            Assert.AreEqual(5, newAccount.Id);
        }
예제 #3
0
        public void Setup()
        {
            _factory = new RegularTransactionFactory();
            var accountFactory  = new RegularAccountFactory();
            var categoryFactory = new RegularCategoryFactory();
            var account1        = accountFactory.CreateAccount("Main Account", "Description", "UAH");
            var account2        = accountFactory.CreateAccount("Reserve Account", "Description", "AUD");

            var category1 = categoryFactory.CreateCategory("Complex Transaction", "Description", 1, null);
            var category2 = categoryFactory.CreateCategory("Category 1", "Description", 2, null);
            var category3 = categoryFactory.CreateCategory("Category 2", "Description", 3, null);
            var category4 = categoryFactory.CreateCategory("Category 3", "Description", 4, null);

            _mainTransaction = _factory.CreateTransaction(account1, category1, "Complex Transaction", 20m, DateTime.Now, 1, 0, null, null);
            _child1          = _factory.CreateTransaction(account1, category2, "Child 1", 40m, DateTime.Now, 2, 0, null, null);
            _child2          = _factory.CreateTransaction(account2, category3, "Child 2", 80m, DateTime.Now, 3, 0, null, null);
            _child3          = _factory.CreateTransaction(account2, category4, "Child 3", 160m, DateTime.Now, 4, 0, null, null);
        }
예제 #4
0
        public void Setup()
        {
            _factory = new RegularAccountFactory();
            _storage = new SqLiteAccountStorage(_factory);
            _storage.DeleteAllData();
            var accountName        = "Test Account";
            var accountDescription = "Test Description";
            var accountCurrency    = "USD";


            _account = _factory.CreateAccount(accountName, accountDescription, accountCurrency);
        }
예제 #5
0
        private IAccount CreateAccount()
        {
            var factory            = new RegularAccountFactory();
            var accountName        = "Test Account";
            var accountDescription = "Test Description";
            var accountCurrency    = "USD";


            var account = factory.CreateAccount(accountName, accountDescription, accountCurrency);

            return(account);
        }
예제 #6
0
        public void TestCreateAccount()
        {
            var factory            = new RegularAccountFactory();
            var accountName        = "Test Account";
            var accountDescription = "Test Description";
            var accountCurrency    = "USD";


            var account = factory.CreateAccount(accountName, accountDescription, accountCurrency);


            Assert.AreEqual(accountName, account.Name);
            Assert.AreEqual(accountDescription, account.Description);
            Assert.AreEqual(accountCurrency, account.Currency);
        }
예제 #7
0
        private ITransaction CreateTransaction()
        {
            var factory         = new RegularTransactionFactory();
            var accountFactory  = new RegularAccountFactory();
            var categoryFactory = new RegularCategoryFactory();

            var account  = accountFactory.CreateAccount("Account", "Description", "UAH");
            var category = categoryFactory.CreateCategory("Category", "category Description", 0, null);

            var transaction = factory.CreateTransaction(
                account, category, "Simple Transaction", 100
                );

            return(transaction);
        }
예제 #8
0
        public void CreateTransactionTest()
        {
            var factory         = new RegularTransactionFactory();
            var accountFactory  = new RegularAccountFactory();
            var categoryFactory = new RegularCategoryFactory();

            var account  = accountFactory.CreateAccount("Account", "Description", "UAH");
            var category = categoryFactory.CreateCategory("Category", "category Description", 0, null);

            var transaction = factory.CreateTransaction(
                account, category, "Simple Transaction", 100
                );

            Assert.AreEqual(account, transaction.Account);
            Assert.AreEqual(category, transaction.Category);
        }
예제 #9
0
        public void ToTransactionIncompleteCategoryTransactionTest()
        {
            var accountFactory   = new RegularAccountFactory();
            var quickTransaction = new QuickTransaction
            {
                Account = accountFactory.CreateAccount(
                    "TestAccount", "Description", "USD"),
                Name         = "TestName",
                AskForWeight = false,
                AskForTotal  = false,
                Total        = 2.34m,
                Weight       = 1
            };

            var result = QuickTransactionValidator.IsRequireInteractionForTransaction(quickTransaction);

            Assert.IsTrue(result, "Interaction required");
        }
예제 #10
0
        public void CreateBarCodeBasedTransactionText()
        {
            var transactionStorage = new MemoryTransactionStorage(new RegularTransactionFactory());
            var barCodeStorage     = new MemoryBarCodeStorage(new BarCodeFactory(), transactionStorage);
            var accountFactory     = new RegularAccountFactory();
            var categoryFactory    = new RegularCategoryFactory();
            var account            = accountFactory.CreateAccount("Account", "Description", "UAH");
            var category           = categoryFactory.CreateCategory("Category", "category Description", 0, null);
            var transaction        = transactionStorage.CreateTransaction(account, category, "test", 26.38m, DateTime.Now, 0, 0, null, null);
            var barCode            = barCodeStorage.CreateBarCode(CreateBarCode("2734336010584", true, 6));

            barCode.Transaction = transaction;
            barCodeStorage.UpdateBarCode(barCode);
            barCodeStorage.CreateBarCode(CreateBarCode("5060207697224"));

            barCodeStorage.CreateTransactionBarCodeRelatedFromStorage("2734336");

            var transactions = transactionStorage.GetAllTransactions();

            Assert.AreEqual(2, transactions.Count());
        }
예제 #11
0
        public void CreateQuickTransactionTest()
        {
            var factory         = new RegularQuickTransactionFactory();
            var accountFactory  = new RegularAccountFactory();
            var categoryFactory = new RegularCategoryFactory();

            var account  = accountFactory.CreateAccount("Account", "Description", "UAH");
            var category = categoryFactory.CreateCategory("Category", "category Description", 0, null);

            var transaction = factory.CreateQuickTransaction(
                account, category, "Simple Transaction", 100, 5, 0, false, false
                );

            Assert.AreEqual(account, transaction.Account);
            Assert.AreEqual(category, transaction.Category);
            Assert.AreEqual("Simple Transaction", transaction.Name);
            Assert.AreEqual(100m, transaction.Total);
            Assert.AreEqual(5, transaction.Id);
            Assert.AreEqual(0, transaction.Weight);
            Assert.AreEqual(false, transaction.AskForTotal);
            Assert.AreEqual(false, transaction.AskForWeight);
        }