public void CreateGroups_Null_ArgumentNullExceptionThrown() { // Arrange // Act / Assert Assert.Throws <GroupListParameterNullException>( () => AlphaGroupListGroupCollection <PaymentViewModel> .CreateGroups(null, CultureInfo.CurrentUICulture, s => "")); }
public async Task OnAppearingAsync() { try { if (isRunning) { return; } isRunning = true; List <AccountViewModel> accountVms = mapper.Map <List <AccountViewModel> >(await mediator.Send(new GetAccountsQuery())); accountVms.ForEach(async x => x.EndOfMonthBalance = await mediator.Send(new GetAccountEndOfMonthBalanceQuery(x.Id))); var includedAccountGroup = new AlphaGroupListGroupCollection <AccountViewModel>(Strings.IncludedAccountsHeader); var excludedAccountGroup = new AlphaGroupListGroupCollection <AccountViewModel>(Strings.ExcludedAccountsHeader); includedAccountGroup.AddRange(accountVms.Where(x => !x.IsExcluded)); excludedAccountGroup.AddRange(accountVms.Where(x => x.IsExcluded)); var newAccountCollection = new ObservableCollection <AlphaGroupListGroupCollection <AccountViewModel> >(); if (includedAccountGroup.Any()) { newAccountCollection.Add(includedAccountGroup); } if (excludedAccountGroup.Any()) { newAccountCollection.Add(excludedAccountGroup); } // Don't clear and add items separately since iOS doesn't handle batch updates correctly. Accounts = newAccountCollection; } finally { isRunning = false; } }
public async Task OnAppearingAsync() { try { if (isRunning) { return; } isRunning = true; Accounts.Clear(); List <AccountViewModel>?accountVms = mapper.Map <List <AccountViewModel> >(await mediator.Send(new GetAccountsQuery())); accountVms.ForEach(async x => x.EndOfMonthBalance = await mediator.Send(new GetAccountEndOfMonthBalanceQuery(x.Id))); var includedAccountGroup = new AlphaGroupListGroupCollection <AccountViewModel>(Strings.IncludedAccountsHeader); var excludedAccountGroup = new AlphaGroupListGroupCollection <AccountViewModel>(Strings.ExcludedAccountsHeader); includedAccountGroup.AddRange(accountVms.Where(x => !x.IsExcluded)); excludedAccountGroup.AddRange(accountVms.Where(x => x.IsExcluded)); if (includedAccountGroup.Any()) { Accounts.Add(includedAccountGroup); } if (excludedAccountGroup.Any()) { Accounts.Add(excludedAccountGroup); } } finally { isRunning = false; } }
public void CreateGroupReturnsCorrectGroup() { // Arrange var accountList = new List <AccountViewModel> { new AccountViewModel { Name = "a" }, new AccountViewModel { Name = "b" } }; // Act List <AlphaGroupListGroupCollection <AccountViewModel> > createdGroup = AlphaGroupListGroupCollection <AccountViewModel> .CreateGroups(accountList, CultureInfo.CurrentUICulture, s => s.Name); // Assert createdGroup.Should().HaveCount(2); createdGroup[0][0].Name.Should().Be("a"); createdGroup[1][0].Name.Should().Be("b"); }