public async Task RemoteSyncBudget_SyncStatus_ExpectChanges() { var remoteBudgetCalls = Substitute.For <IRemoteBudgetCalls>(); var budgetGroupSync = Substitute.ForPartsOf <BudgetGroupSync>(remoteBudgetCalls); var budgetSync = new BudgetSync(remoteBudgetCalls, budgetGroupSync); Budget budget = BudgetBuilder.Build(); var testBudget = CreateTestRemoteBudget(); remoteBudgetCalls.GetCurrentBudget().ReturnsForAnyArgs(testBudget); bool statusChanged = false; string status = ""; budgetSync.PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(budgetSync.SyncingStatus)) { statusChanged = true; status = (sender as BudgetSync).SyncingStatus; } }; await budgetSync.RemoteSyncBudget(budget); statusChanged.Should().BeTrue(); status.Should().NotBeNullOrWhiteSpace(); }
public async Task RemoteSyncBudget_ExpectAllBudgetGroupsSyncs() { var remoteBudgetCalls = Substitute.For <IRemoteBudgetCalls>(); //???? var budgetGroupSync = Substitute.ForPartsOf <BudgetGroupSync>(remoteBudgetCalls); //???? var sync = new BudgetSync(remoteBudgetCalls, budgetGroupSync); Budget budget = BudgetBuilder.Build(); var testBudget = CreateTestRemoteBudget(); remoteBudgetCalls.GetCurrentBudget().ReturnsForAnyArgs(testBudget); await sync.RemoteSyncBudget(budget); await budgetGroupSync.Received().SyncBudgetGroup(testBudget, budget.IncomeGroup); await budgetGroupSync.Received().SyncBudgetGroup(testBudget, budget.HousingGroup); await budgetGroupSync.Received().SyncBudgetGroup(testBudget, budget.TransportationGroup); await budgetGroupSync.Received().SyncBudgetGroup(testBudget, budget.FoodGroup); await budgetGroupSync.Received().SyncBudgetGroup(testBudget, budget.PersonalGroup); await budgetGroupSync.Received().SyncBudgetGroup(testBudget, budget.GivingGroup); await budgetGroupSync.Received().SyncBudgetGroup(testBudget, budget.DebtGroup); await budgetGroupSync.Received(7).SyncBudgetGroup(Arg.Any <RemoteBudget.RemoteBudget>(), Arg.Any <BudgetGroup>()); }
public void Constructor_ValidArguments_ExpectPopulatedParameters() { var remoteBudgetCalls = Substitute.For <IRemoteBudgetCalls>(); var budgetGroupSync = new BudgetGroupSync(remoteBudgetCalls); var profileSync = new BudgetSync(remoteBudgetCalls, budgetGroupSync); profileSync.Should().NotBeNull(); }
public void RemoteSyncBudget_NullBudget_ExpectException() { var remoteBudgetCalls = Substitute.For <IRemoteBudgetCalls>(); var budgetGroupSync = Substitute.ForPartsOf <BudgetGroupSync>(remoteBudgetCalls); var sync = new BudgetSync(remoteBudgetCalls, budgetGroupSync); Func <Task> testAction = async() => await sync.RemoteSyncBudget(null); testAction.Should().Throw <ArgumentNullException>(); }