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); }
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); }
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); }
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); }
public void DeleteAccountTest() { var factory = new RegularAccountFactory(); var storage = new SqLiteAccountStorage(factory); storage.DeleteAllData(); var account = CreateAccount(); storage.CreateAccount(account); storage.DeleteAccount(account); var numberOfAccounts = storage.GetAllAccounts().Count(); Assert.AreEqual(0, numberOfAccounts); }
public void UpdateAccountTest() { var factory = new RegularAccountFactory(); var storage = new SqLiteAccountStorage(factory); storage.DeleteAllData(); var account = CreateAccount(); storage.CreateAccount(account); account.Name = "New Name"; account.Description = "New Description"; storage.UpdateAccount(account); var firstAccount = storage.GetAllAccounts().First(); Assert.AreEqual(account.Name, firstAccount.Name); Assert.AreEqual(account.Description, firstAccount.Description); }