Example #1
0
        public void Setup()
        {
            _accountStorage     = new MemoryAccountStorage(new RegularAccountFactory());
            _categoryStorage    = new MemoryCategoryStorage(new RegularCategoryFactory());
            _transactionStorage = new MemoryTransactionStorage(new RegularTransactionFactory());

            _transactionStorage.DeleteAllData();

            _account1 = _accountStorage.CreateAccount("Main Account", "Description", "UAH");
            _account2 = _accountStorage.CreateAccount("Reserve Account", "Description", "UAH");

            var category1 = _categoryStorage.CreateCategory("Category 1", "category Description", 0, null);
            var category2 = _categoryStorage.CreateCategory("Category 2", "category Description", 0, category1);
            var category3 = _categoryStorage.CreateCategory("Category 3", "category Description", 0, null);
            var category4 = _categoryStorage.CreateCategory("Category 4", "category Description", 0, category1);
            var category5 = _categoryStorage.CreateCategory("Category 5", "category Description", 0, null);

            _transactionStorage.CreateTransaction(_account1, category1, "Simple Transaction", 100, DateTime.Now, 0, 0, null, null);
            _transactionStorage.CreateTransaction(_account1, category2, "Simple Transaction", 100, DateTime.Now, 0, 0, null, null);
            _transactionStorage.CreateTransaction(_account1, category3, "Simple Transaction", 100, DateTime.Now, 0, 0, null, null);
            _transactionStorage.CreateTransaction(_account1, category4, "Simple Transaction", 100, DateTime.Now, 0, 0, null, null);
            _transactionStorage.CreateTransaction(_account2, category1, "Simple Transaction", 100, DateTime.Now.AddDays(-1), 0, 0, null, null);
            _transactionStorage.CreateTransaction(_account2, category3, "Simple Transaction", 100, DateTime.Now.AddDays(-1), 0, 0, null, null);
            _transactionStorage.CreateTransaction(_account2, category3, "Simple Transaction", 100, DateTime.Now.AddDays(-1), 0, 0, null, null);
            _transactionStorage.CreateTransaction(_account2, category5, "Simple Transaction", 100, DateTime.Now.AddDays(-1), 0, 0, null, null);
            _transactionStorage.CreateTransaction(_account2, category1, "Simple Transaction", 100, DateTime.Now.AddDays(-1), 0, 0, null, null);
            _transactionStorage.CreateTransaction(_account1, category2, "Simple Transaction", 100, DateTime.Now, 0, 0, null, null);
            _transactionStorage.CreateTransaction(_account1, category1, "Simple Transaction", 100, DateTime.Now, 0, 0, null, null);
        }
Example #2
0
        public void EventErrorStringTest()
        {
            var storage   = new MemoryAccountStorage(new RegularAccountFactory());
            var viewModel = new EditAccountViewModel(storage);

            viewModel.PropertyChanged += ViewModel_PropertyChanged;
            viewModel.ErrorString      = "Name";
            Assert.AreEqual("ErrorString", _fieldName);
        }
Example #3
0
        public void EventCurrencyTest()
        {
            var storage   = new MemoryAccountStorage(new RegularAccountFactory());
            var viewModel = new EditAccountViewModel(storage);

            viewModel.PropertyChanged += ViewModel_PropertyChanged;
            viewModel.Currency         = "Name";
            Assert.AreEqual("Currency", _fieldName);
        }
Example #4
0
        public void EventDescriptionTest()
        {
            var storage   = new MemoryAccountStorage(new RegularAccountFactory());
            var viewModel = new EditAccountViewModel(storage);

            viewModel.PropertyChanged += ViewModel_PropertyChanged;
            viewModel.Description      = "Desc";
            Assert.AreEqual("Description", _fieldName);
        }
Example #5
0
        public void CreateNewAccountTest()
        {
            var storage   = new MemoryAccountStorage(new RegularAccountFactory());
            var viewModel = new EditAccountViewModel(storage)
            {
                Name        = TestAccount,
                Description = Description,
                Currency    = Usd
            };

            viewModel.CreateNewAccount();
            var newAccount = storage.GetAllAccounts().FirstOrDefault();

            Assert.IsNotNull(newAccount);
            Assert.AreEqual(TestAccount, newAccount.Name);
            Assert.AreEqual(Description, newAccount.Description);
            Assert.AreEqual(Usd, newAccount.Currency);
        }
Example #6
0
        public void UpdateAccountTest()
        {
            var storage = new MemoryAccountStorage(new RegularAccountFactory());
            var account = storage.CreateAccount("New Account", "Old description", "UAH");

            var viewModel = new EditAccountViewModel(storage, account);

            viewModel.Name        = TestAccount;
            viewModel.Description = Description;
            viewModel.Currency    = Usd;

            viewModel.UpdateAccount();
            var newAccount = storage.GetAllAccounts().FirstOrDefault();

            Assert.IsNotNull(newAccount);
            Assert.AreEqual(account.Id, newAccount.Id);
            Assert.AreEqual(TestAccount, newAccount.Name);
            Assert.AreEqual(Description, newAccount.Description);
            Assert.AreEqual(Usd, newAccount.Currency);
        }
Example #7
0
        public void CategoryAccountPairCompareTest()
        {
            var accountStorage  = new MemoryAccountStorage(new RegularAccountFactory());
            var categoryStorage = new MemoryCategoryStorage(new RegularCategoryFactory());
            var category1       = categoryStorage.CreateCategory("Category 1", "", 0, null);
            var category2       = categoryStorage.CreateCategory("Category 2", "", 0, category1);
            var account         = accountStorage.CreateAccount("Main account", "", "UAH");
            var account2        = accountStorage.CreateAccount("Reserve account", "", "TUR");



            var mainPair        = new Report1.CategoryAccountPair(account, category1);
            var samePair        = new Report1.CategoryAccountPair(account, category1);
            var diffPair        = new Report1.CategoryAccountPair(account2, category1);
            var anotherDiffPair = new Report1.CategoryAccountPair(account2, category2);


            Assert.IsTrue(mainPair.Equals(samePair));
            Assert.IsFalse(mainPair.Equals(diffPair));
            Assert.IsFalse(samePair.Equals(diffPair));
            Assert.IsFalse(samePair.Equals(anotherDiffPair));
        }
Example #8
0
        public void ExecuteTest()
        {
            var accountStorage     = new MemoryAccountStorage(new RegularAccountFactory());
            var categoryStorage    = new MemoryCategoryStorage(new RegularCategoryFactory());
            var transactionStorage = new MemoryTransactionStorage(new RegularTransactionFactory());

            var category1  = categoryStorage.CreateCategory("Category 1", "", 0, null);
            var category2  = categoryStorage.CreateCategory("Category 2", "", 0, category1);
            var category3  = categoryStorage.CreateCategory("Category 3", "", 0, category2);
            var category31 = categoryStorage.CreateCategory("Category 3-1", "", 0, category3);
            var category32 = categoryStorage.CreateCategory("Category 3-2", "", 0, category3);
            var category4  = categoryStorage.CreateCategory("Category 4", "", 0, category1);
            var category5  = categoryStorage.CreateCategory("Category 5", "", 0, category1);
            var account    = accountStorage.CreateAccount("Main account", "", "UAH");
            var account2   = accountStorage.CreateAccount("Reserve account", "", "TUR");


            var transaction1 = CreateTransaction(transactionStorage, account, category31);

            CreateTransaction(transactionStorage, account, category31);
            CreateTransaction(transactionStorage, account, category32);
            CreateTransaction(transactionStorage, account, category31);
            CreateTransaction(transactionStorage, account, category5);
            CreateTransaction(transactionStorage, account, category31);
            CreateTransaction(transactionStorage, account, category32);
            CreateTransaction(transactionStorage, account, category32);


            CreateTransaction(transactionStorage, account2, category32);
            CreateTransaction(transactionStorage, account2, category31);
            CreateTransaction(transactionStorage, account2, category4);


            var report1 = new Report1(transactionStorage, categoryStorage);
            var list    = report1.Execute(new AllTransactionFilteredSource()).GroupBy(x => x.Key.Account);
        }
Example #9
0
 public void Setup()
 {
     _factory = new RegularAccountFactory();
     _storage = new MemoryAccountStorage(_factory);
     _account = CreateAccount();
 }