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 DeleteCategoryTest() { var factory = new RegularCategoryFactory(); var storage = new SqLiteCategoryStorage(factory); storage.DeleteAllData(); var category = CreateCategory(); storage.CreateCategory(category); storage.DeleteCategory(category); var numberOfCategories = storage.GetAllCategories().Count(); Assert.AreEqual(0, numberOfCategories); }
public void UpdateCategoryTest() { var factory = new RegularCategoryFactory(); var storage = new SqLiteCategoryStorage(factory); storage.DeleteAllData(); var category = CreateCategory(); storage.CreateCategory(category); category.Name = "New Name"; category.Description = "New Description"; storage.UpdateCategory(category); var firstCategory = storage.GetAllCategories().First(); Assert.AreEqual(category.Name, firstCategory.Name); Assert.AreEqual(category.Description, firstCategory.Description); }
public void CreateTreeCategoryTest() { var factory = new RegularCategoryFactory(); var storage = new SqLiteCategoryStorage(factory); storage.DeleteAllData(); var category = CreateCategory(); storage.CreateCategory(category); var childCategory = CreateChildCategory(category); storage.CreateCategory(childCategory); var categoryList = storage.GetAllCategories().ToArray(); var categoryFromStorage = categoryList.FirstOrDefault(x => x.Id == category.Id); var childCategoryFromStorage = categoryList.FirstOrDefault(x => x.Id == childCategory.Id); Assert.AreEqual(category.Id, categoryFromStorage.Id); Assert.AreEqual(childCategory.Id, childCategoryFromStorage.Id); Assert.AreEqual(childCategoryFromStorage.Parent.Id, categoryFromStorage.Id); }
public static void CreateDefaultCategoryTree() { var storage = new SqLiteCategoryStorage(new RegularCategoryFactory()); storage.DeleteAllData(); var car = storage.CreateCategory("π Car", "Car", 1, null); storage.CreateCategory("π Ώ Parking", "Parking", 2, car); storage.CreateCategory("π· Insurance", "Insurance", 3, car); storage.CreateCategory("π Accessories", "Accessories", 4, car); storage.CreateCategory("π Other", "Other", 5, car); storage.CreateCategory("π Service", "Service", 6, car); storage.CreateCategory("β½ Fuel", "Fuel", 7, car); var relaxation = storage.CreateCategory("π Relaxation", "Relaxation", 8, null); storage.CreateCategory("π Sport", "sport", 9, relaxation); storage.CreateCategory("π Entertainment", "Entertainment", 10, relaxation); storage.CreateCategory("π Sport/Fitness", "Sport/Fitness", 11, relaxation); var home = storage.CreateCategory("π‘ Home", "home", 12, null); storage.CreateCategory("π Rent", "Rent", 13, home); storage.CreateCategory("πͺπͺ Furniture", "Furniture", 14, home); var health = storage.CreateCategory("π¨ββ Healthcare", "Healthcare", 15, null); storage.CreateCategory("π Medicine", "Medicine", 16, health); storage.CreateCategory("π₯ Hospital", "Hospital", 17, health); storage.CreateCategory("π¦· Dentist", "Dentist", 18, health); storage.CreateCategory("β Medical Insurance", "Medical Insurance", 19, health); storage.CreateCategory("π Analysis", "Analysis", 20, health); var books = storage.CreateCategory("π Books", "Books", 21, null); var bills = storage.CreateCategory("π Bills", "Bills", 22, null); storage.CreateCategory("πΏ Water", "Water", 23, bills); storage.CreateCategory("π₯ Gas", "Gas", 24, bills); storage.CreateCategory("π Electricity", "Electricity", 25, bills); storage.CreateCategory("π‘ Internet", "Internet", 26, bills); storage.CreateCategory("πΆ Mobile", "Mobile", 27, bills); storage.CreateCategory("π Rental fee", "Rental fee", 28, bills); storage.CreateCategory("π₯΅ Central Heating", "Central Heating", 29, bills); var clothes = storage.CreateCategory("π Clothes", "Clothes", 30, null); var c00per = storage.CreateCategory("π C00per clothes", "c00per clothes", 31, clothes); var gerda = storage.CreateCategory("π₯» Gerda clothes", "Gerda clothes", 32, clothes); var sam = storage.CreateCategory("π Sam clothes", "Sam clothes", 33, clothes); var food = storage.CreateCategory("π Food", "Food", 34, null); var meat = storage.CreateCategory("π₯© Meat", "Meat", 35, food); var fish = storage.CreateCategory("π¦ Fish", "Fish", 36, food); var vegetables = storage.CreateCategory("π Vegetables", "Vegetables", 37, food); var fruit = storage.CreateCategory("π Fruit", "Fruit", 38, food); var cereals = storage.CreateCategory("π₯£ Cereals", "Cereals", 39, food); var transport = storage.CreateCategory("π Transport", "Transport", 40, null); storage.CreateCategory("π Metro", "Metro", 41, transport); storage.CreateCategory("π Bus", "Bus", 42, transport); storage.CreateCategory("π Tram", "Tram", 43, transport); storage.CreateCategory("π Trolleybus", "Trolleybus", 44, transport); storage.CreateCategory("π Minibus", "Minibus", 45, transport); var cigarettes = storage.CreateCategory("π¬ Cigarettes", "Cigarettes", 46, null); var journey = storage.CreateCategory("π Journey", "Journey", 47, null); storage.CreateCategory("π Hotels", "Hotels", 48, journey); storage.CreateCategory("π Car", "Car", 49, journey); storage.CreateCategory("π Food", "Food", 50, journey); storage.CreateCategory("β Coffee", "Coffee", 51, journey); storage.CreateCategory("π Museum", "Museum", 52, journey); storage.CreateCategory("π Souvenirs", "Souvenirs", 53, journey); storage.CreateCategory("β Tickets", "Tickets", 54, journey); storage.CreateCategory("πΊ Drinks", "Drinks", 55, journey); storage.CreateCategory("π Books and Guides", "Books and Guides", 56, journey); }