Пример #1
0
        public void DeleteComplexTransactionTest()
        {
            ITransactionFactory transactionFactory = new RegularTransactionFactory();
            var accountStorage  = new SqLiteAccountStorage(new RegularAccountFactory());
            var categoryStorage = new SqLiteCategoryStorage(new RegularCategoryFactory());
            var storage         = new SqLiteTransactionStorage(transactionFactory, accountStorage, categoryStorage);

            categoryStorage.DeleteAllData();
            accountStorage.DeleteAllData();
            storage.DeleteAllData();
            var transaction       = CreateTransaction(accountStorage, categoryStorage, transactionFactory);
            var childTransaction  = CreateTransaction(accountStorage, categoryStorage, transactionFactory);
            var childTransaction1 = CreateTransaction(accountStorage, categoryStorage, transactionFactory);
            var newTransaction    = storage.CreateTransaction(transaction);

            storage.AddChildTransaction(newTransaction, storage.CreateTransaction(childTransaction));
            storage.AddChildTransaction(newTransaction, storage.CreateTransaction(childTransaction1));



            storage.DeleteTransaction(newTransaction);


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


            Assert.AreEqual(0, numberOfTransactions);
        }
Пример #2
0
        public void UpdateTransactionTest()
        {
            ITransactionFactory transactionFactory = new RegularTransactionFactory();
            var accountStorage  = new SqLiteAccountStorage(new RegularAccountFactory());
            var categoryStorage = new SqLiteCategoryStorage(new RegularCategoryFactory());
            var storage         = new SqLiteTransactionStorage(transactionFactory, accountStorage, categoryStorage);

            categoryStorage.DeleteAllData();
            accountStorage.DeleteAllData();
            storage.DeleteAllData();
            var transaction       = CreateTransaction(accountStorage, categoryStorage, transactionFactory);
            var childTransaction  = CreateTransaction(accountStorage, categoryStorage, transactionFactory);
            var childTransaction1 = CreateTransaction(accountStorage, categoryStorage, transactionFactory);
            var newTransaction    = storage.CreateTransaction(transaction);

            storage.AddChildTransaction(newTransaction, storage.CreateTransaction(childTransaction));
            storage.AddChildTransaction(newTransaction, storage.CreateTransaction(childTransaction1));
            childTransaction1.Name  = "New Name";
            childTransaction1.Total = 515.03m;


            storage.UpdateTransaction(childTransaction1);


            var firstTransaction = storage.GetAllTransactions().First(x => x.Id == childTransaction1.Id);

            Assert.AreEqual(childTransaction1.Name, firstTransaction.Name);
            Assert.AreEqual(childTransaction1.Category.Id, firstTransaction.Category.Id);
            Assert.AreEqual(childTransaction1.Account.Id, firstTransaction.Account.Id);
            Assert.AreEqual(childTransaction1.Total, firstTransaction.Total);
        }
Пример #3
0
        public void CreateComplexTransactionTest()
        {
            var accountStorage     = new SqLiteAccountStorage(new RegularAccountFactory());
            var categoryStorage    = new SqLiteCategoryStorage(new RegularCategoryFactory());
            var transactionFactory = new RegularTransactionFactory();
            var storage            = new SqLiteTransactionStorage(transactionFactory, accountStorage, categoryStorage);

            categoryStorage.DeleteAllData();
            accountStorage.DeleteAllData();
            storage.DeleteAllData();
            var transaction       = CreateTransaction(accountStorage, categoryStorage, transactionFactory);
            var childTransaction  = CreateTransaction(accountStorage, categoryStorage, transactionFactory);
            var childTransaction1 = CreateTransaction(accountStorage, categoryStorage, transactionFactory);

            var newTransaction = storage.CreateTransaction(transaction);

            storage.AddChildTransaction(newTransaction, storage.CreateTransaction(childTransaction));
            storage.AddChildTransaction(newTransaction, storage.CreateTransaction(childTransaction1));


            var complexTransaction = storage.GetAllTransactions().FirstOrDefault(x => x.IsComplexTransaction);

            Assert.AreEqual(transaction.Name, complexTransaction?.Name);
            Assert.AreEqual(transaction.Category.Id, complexTransaction?.Category?.Id);
            Assert.AreEqual(transaction.Account.Id, complexTransaction?.Account?.Id);
            Assert.AreEqual(426.00m, complexTransaction?.Total);
        }
Пример #4
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 RegularTransactionFactory();
            var storage            = new SqLiteTransactionStorage(transactionFactory, accountStorage, categoryStorage);

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

            storage.CreateTransaction(transaction);

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


            storage.UpdateTransaction(transaction);


            var firstTransaction = storage.GetAllTransactions().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);
        }
Пример #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 RegularTransactionFactory();
            var storage            = new SqLiteTransactionStorage(transactionFactory, accountStorage, categoryStorage);
            var transaction        = CreateTransaction();


            var newTransaction = storage.CreateTransaction(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
        public void DeleteTransactionTest()
        {
            var accountFactory     = new RegularAccountFactory();
            var categoryFactory    = new RegularCategoryFactory();
            var accountStorage     = new SqLiteAccountStorage(accountFactory);
            var categoryStorage    = new SqLiteCategoryStorage(categoryFactory);
            var transactionFactory = new RegularTransactionFactory();
            var storage            = new SqLiteTransactionStorage(transactionFactory, accountStorage, categoryStorage);

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

            storage.CreateTransaction(transaction);



            storage.DeleteTransaction(transaction);


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


            Assert.AreEqual(0, numberOfTransactions);
        }