public async Task Update_SumChangedAndAccountChangedAndCategoryChanged_TypeOfFlowId2() { var oldItem = new PayingItem() { Summ = 500, AccountID = 1, Account = new Account() { Cash = 1000 }, CategoryID = 1 }; var newItem = new PayingItem() { Summ = 600, Category = new Category() { TypeOfFlowID = 2 }, Account = new Account() { Cash = 1000 }, AccountID = 2, CategoryID = 2 }; var newAccount = newItem.Account; var oldAccount = oldItem.Account; var target = new PayingItemServiceTrigger(null, _accountService.Object); _accountService.Setup(x => x.GetItemAsync(newItem.AccountID)).ReturnsAsync(newAccount); _accountService.Setup(x => x.GetItemAsync(oldItem.AccountID)).ReturnsAsync(oldAccount); await target.Update(oldItem, newItem); Assert.AreEqual(oldAccount.Cash, 1500); Assert.AreEqual(newAccount.Cash, 400); }
public async Task Insert_CategoryServiceThrowsServiceException() { _categoryService.Setup(m => m.GetItemAsync(It.IsAny <int>())).Throws <ServiceException>(); var target = new PayingItemServiceTrigger(_categoryService.Object, _accountService.Object); await target.Insert(new PayingItem()); }
public async Task Update_NewSummGreaterThanOldSumm_TypeOfFlowId2() { var oldItem = new PayingItem() { Summ = 500 }; var newItem = new PayingItem() { Summ = 600, Category = new Category() { TypeOfFlowID = 2 }, Account = new Account() { Cash = 500 } }; var account = newItem.Account; var target = new PayingItemServiceTrigger(null, _accountService.Object); _accountService.Setup(x => x.GetItemAsync(It.IsAny <int>())).ReturnsAsync(account); await target.Update(oldItem, newItem); Assert.AreEqual(account.Cash, 400); }
public async Task Delete_TypeOfFlowId2_AccountCashIncrease() { var deletedItem = new PayingItem() { Summ = 200, Account = new Account() { Cash = 500 }, Category = new Category() { TypeOfFlowID = 2 } }; var account = deletedItem.Account; _categoryService.Setup(m => m.GetItemAsync(It.IsAny <int>())) .ReturnsAsync(new Category { TypeOfFlowID = 2 }); _accountService.Setup(m => m.GetItemAsync(It.IsAny <int>())).ReturnsAsync(account); var target = new PayingItemServiceTrigger(_categoryService.Object, _accountService.Object); await target.Delete(deletedItem); Assert.AreEqual(account.Cash, 700); }
public async Task Insert_TypeOfFlowId2_AccountCashDecrease() { var insertedItem = new PayingItem() { Summ = 200 }; var account = new Account() { Cash = 500 }; _categoryService.Setup(m => m.GetItemAsync(It.IsAny <int>())) .ReturnsAsync(new Category { TypeOfFlowID = 2 }); _accountService.Setup(m => m.GetItemAsync(It.IsAny <int>())).ReturnsAsync(account); var target = new PayingItemServiceTrigger(_categoryService.Object, _accountService.Object); await target.Insert(insertedItem); Assert.AreEqual(account.Cash, 300); }