コード例 #1
0
        public void UpdateTransactionTest()
        {
            var accountFactory     = new RegularAccountFactory();
            var categoryFactory    = new RegularCategoryFactory();
            var accountStorage     = new SqLiteAccountStorage(accountFactory);
            var categoryStorage    = new SqLiteCategoryStorage(categoryFactory);
            var transactionFactory = new RegularQuickTransactionFactory();
            var storage            = new SqLiteQuickTransactionStorage(transactionFactory, accountStorage, categoryStorage);

            storage.DeleteAllData();
            var transaction = CreateTransaction();

            storage.CreateQuickTransaction(transaction);

            transaction.Name  = "New Name";
            transaction.Total = 515.03m;


            storage.UpdateQuickTransaction(transaction);


            var firstTransaction = storage.GetAllQuickTransactions().First();

            Assert.AreEqual(transaction.Name, firstTransaction.Name);
            Assert.AreEqual(transaction.Category.Id, firstTransaction.Category.Id);
            Assert.AreEqual(transaction.Account.Id, firstTransaction.Account.Id);
            Assert.AreEqual(transaction.Total, firstTransaction.Total);
        }
コード例 #2
0
        public GlobalSettings()
        {
            var accountFactory          = new RegularAccountFactory();
            var categoryFactory         = new RegularCategoryFactory();
            var transactionFactory      = new RegularTransactionFactory();
            var quickTransactionFactory = new RegularQuickTransactionFactory();

            var accountStorage = new CachedAccountStorage(
                new SqLiteAccountStorage(accountFactory));
            var categoryStorage = new CachedCategoryStorage(
                new SqLiteCategoryStorage(categoryFactory));
            var transactionStorage = new CachedTransactionStorage(
                new SqLiteTransactionStorage(transactionFactory, accountStorage, categoryStorage));

            Storages = new Storages
            {
                AccountStorage  = accountStorage,
                CategoryStorage = categoryStorage,

                TransactionStorage = transactionStorage,
                BarCodeStorage     = new CachedBarCodeStorage(
                    new SqLiteBarCodeStorage(new BarCodeFactory(), transactionStorage)),
                QuickTransactionStorage = new CachedQuickTransactionStorage(
                    new SqLiteQuickTransactionStorage(quickTransactionFactory, accountStorage, categoryStorage))
            };
        }
コード例 #3
0
        private IQuickTransaction CreateTransaction()
        {
            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
                );

            return(transaction);
        }
コード例 #4
0
        public void UpdateTransactionTest()
        {
            var factory     = new RegularQuickTransactionFactory();
            var storage     = new MemoryQuickTransactionStorage(factory);
            var transaction = CreateTransaction();

            storage.CreateQuickTransaction(transaction);
            transaction.Total = 120;


            storage.UpdateQuickTransaction(transaction);
            var storedTransaction = storage.GetAllQuickTransactions().First();


            Assert.AreEqual(transaction.Total, storedTransaction.Total);
        }
コード例 #5
0
        public void CreateTransactionTest()
        {
            var accountFactory     = new RegularAccountFactory();
            var categoryFactory    = new RegularCategoryFactory();
            var accountStorage     = new SqLiteAccountStorage(accountFactory);
            var categoryStorage    = new SqLiteCategoryStorage(categoryFactory);
            var transactionFactory = new RegularQuickTransactionFactory();
            var storage            = new SqLiteQuickTransactionStorage(transactionFactory, accountStorage, categoryStorage);
            var transaction        = CreateTransaction();


            var newTransaction = storage.CreateQuickTransaction(transaction);


            Assert.AreEqual(transaction.Name, newTransaction.Name);
            Assert.AreEqual(transaction.Category.Id, newTransaction.Category.Id);
            Assert.AreEqual(transaction.Account.Id, newTransaction.Account.Id);
            Assert.AreEqual(transaction.Total, newTransaction.Total);
        }
コード例 #6
0
        private IQuickTransaction CreateTransaction()
        {
            var accountFactory  = new RegularAccountFactory();
            var categoryFactory = new RegularCategoryFactory();
            var accountManager  = new SqLiteAccountStorage(accountFactory);
            var categoryManager = new SqLiteCategoryStorage(categoryFactory);

            var factory = new RegularQuickTransactionFactory();


            var account  = accountManager.CreateAccount("Test account", "Account Description", "EUR");
            var category = categoryManager.CreateCategory("Sample category", "Category Description", 0, null);


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

            return(transaction);
        }
コード例 #7
0
        public void DeleteTransactionTest()
        {
            var factory     = new RegularQuickTransactionFactory();
            var storage     = new MemoryQuickTransactionStorage(factory);
            var transaction = CreateTransaction();

            storage.CreateQuickTransaction(transaction);

            var numberOfTransactionsAfterCreate = storage.GetAllQuickTransactions().Count();

            storage.DeleteQuickTransaction(transaction);


            var numberOfTransactions = storage.GetAllQuickTransactions().Count();


            Assert.AreEqual(0, numberOfTransactions);
            Assert.AreEqual(1, numberOfTransactionsAfterCreate);
        }
コード例 #8
0
        public void CreateTransactionTest()
        {
            var factory = new RegularQuickTransactionFactory();
            var storage = new MemoryQuickTransactionStorage(factory);

            var transaction = CreateTransaction();


            var newTransaction = storage.CreateQuickTransaction(transaction);


            Assert.AreEqual(transaction.Account, newTransaction.Account);
            Assert.AreEqual(transaction.Category, newTransaction.Category);
            Assert.AreEqual("Simple Transaction", newTransaction.Name);
            Assert.AreEqual(100m, newTransaction.Total);
            Assert.AreEqual(5, newTransaction.Id);
            Assert.AreEqual(0, newTransaction.Weight);
            Assert.AreEqual(false, newTransaction.AskForTotal);
            Assert.AreEqual(false, newTransaction.AskForWeight);
        }
コード例 #9
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);
        }
コード例 #10
0
        public void DeleteTransactionTest()
        {
            var accountFactory     = new RegularAccountFactory();
            var categoryFactory    = new RegularCategoryFactory();
            var accountStorage     = new SqLiteAccountStorage(accountFactory);
            var categoryStorage    = new SqLiteCategoryStorage(categoryFactory);
            var transactionFactory = new RegularQuickTransactionFactory();
            var storage            = new SqLiteQuickTransactionStorage(transactionFactory, accountStorage, categoryStorage);

            storage.DeleteAllData();
            var transaction = CreateTransaction();

            storage.CreateQuickTransaction(transaction);



            storage.DeleteQuickTransaction(transaction);


            var numberOfTransactions = storage.GetAllQuickTransactions().Count();


            Assert.AreEqual(0, numberOfTransactions);
        }