Esempio n. 1
0
        public void CreateCategoryWithCodeTest()
        {
            var category = _factory.CreateCategory("Category", "Description", 5, null);


            var newCategory = _storage.CreateCategory(category);


            Assert.AreEqual(5, newCategory.Id);
        }
Esempio n. 2
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);
        }
Esempio n. 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);
        }
Esempio n. 4
0
        private ICategory CreateChildCategory(ICategory parent)
        {
            var factory     = new RegularCategoryFactory();
            var name        = $"Child {parent.Name} Category";
            var description = $"Child {parent.Name} Description";
            var category    = factory.CreateCategory(name, description, 0, parent);

            return(category);
        }
Esempio n. 5
0
        private ICategory CreateCategory()
        {
            var factory     = new RegularCategoryFactory();
            var name        = "Test Category";
            var description = "Test Description";
            var category    = factory.CreateCategory(name, description, 0, null);

            return(category);
        }
Esempio n. 6
0
        public void TestCreateCategory()
        {
            var factory             = new RegularCategoryFactory();
            var categoryName        = "Category Name";
            var categoryDescription = "Category Descriptor";


            var category = factory.CreateCategory(categoryName, categoryDescription, 0, null);


            Assert.AreEqual(categoryName, category.Name);
            Assert.AreEqual(categoryDescription, category.Description);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 9
0
        public void ToTransactionIncompleteAccountTransactionTest()
        {
            var categoryFactory  = new RegularCategoryFactory();
            var quickTransaction = new QuickTransaction
            {
                Category     = categoryFactory.CreateCategory("TestAccount", "Description", 0L, null),
                Name         = "TestName",
                AskForWeight = false,
                AskForTotal  = false,
                Total        = 2.34m,
                Weight       = 1
            };

            var result = QuickTransactionValidator.IsRequireInteractionForTransaction(quickTransaction);

            Assert.IsTrue(result, "Interaction required");
        }
Esempio n. 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());
        }
Esempio n. 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);
        }