public async Task SyncBudgetGroup_DeleteBudgetItem_ExpectRemoteItemDelete() { var remoteBudgetCalls = Substitute.For <IRemoteBudgetCalls>(); var budgetGroupSync = new BudgetGroupSync(remoteBudgetCalls); var remoteBudget = CreateTestRemoteBudget(); var budget = BudgetBuilder.Build(); budget.IncomeGroup.BudgetItems.RemoveAt(0); await budgetGroupSync.SyncBudgetGroup(remoteBudget, budget.IncomeGroup); await remoteBudgetCalls.Received() .DeleteBudgetItem(remoteBudget.Id, remoteBudget.BudgetGroups[0].BudgetItems[0].Id); }
public async Task SyncBudgetGroup_UpdateBudgetItem_ExpectRemoteItemUpdate() { var remoteBudgetCalls = Substitute.For <IRemoteBudgetCalls>(); var budgetGroupSync = new BudgetGroupSync(remoteBudgetCalls); var remoteBudget = CreateTestRemoteBudget(); var budget = BudgetBuilder.Build(); decimal amount = 123.45m; budget.IncomeGroup.BudgetItems[0].Amount = amount; await budgetGroupSync.SyncBudgetGroup(remoteBudget, budget.IncomeGroup); await remoteBudgetCalls.Received() .UpdateBudgetItem(remoteBudget.Id, remoteBudget.BudgetGroups[0].BudgetItems[0].Id, amount); }
public async Task SyncBudgetGroup_AddBudgetItem_ExpectRemoteAdd() { var remoteBudgetCalls = Substitute.For <IRemoteBudgetCalls>(); var budgetGroupSync = new BudgetGroupSync(remoteBudgetCalls); var remoteBudget = CreateTestRemoteBudget(); var budget = BudgetBuilder.Build(); // Create an income group with 2 existing populated amounts and 1 new addition budget.IncomeGroup.BudgetItems[0].Amount = 10m; budget.IncomeGroup.BudgetItems[1].Amount = 10m; budget.IncomeGroup.AddNewBudgetItem(); var newItem = budget.IncomeGroup.BudgetItems.Last(); var index = budget.IncomeGroup.BudgetItems.IndexOf(newItem); budget.IncomeGroup.BudgetItems[index].Name = "test"; budget.IncomeGroup.BudgetItems[index].Amount = 13m; await budgetGroupSync.SyncBudgetGroup(remoteBudget, budget.IncomeGroup); await remoteBudgetCalls.Received().CreateBudgetItem(remoteBudget.Id, remoteBudget.BudgetGroups[0].Id, newItem.Type, newItem.Name, newItem.Amount);; }