public void CreateGroups_Null_ArgumentNullExceptionThrown()
 {
     // Arrange
     // Act / Assert
     Assert.Throws <GroupListParameterNullException>(() =>
                                                     DateListGroupCollection <PaymentViewModel> .CreateGroups(null, s => "",
                                                                                                              s => DateTime.Now));
 }
        private void PaymentListView_OnLoaded(object sender, RoutedEventArgs e)
        {
            if (PaymentListView.Items == null || !PaymentListView.Items.Any())
            {
                return;
            }

            // Select first group with a cleared payment in it
            DateListGroupCollection <PaymentViewModel> selectedGroupCollection = PaymentListView
                                                                                 .Items.Select(x => (DateListGroupCollection <PaymentViewModel>)x)
                                                                                 .FirstOrDefault(group => group.Any(x => x.IsCleared));

            if (selectedGroupCollection == null)
            {
                return;
            }

            PaymentListView.ScrollIntoView(selectedGroupCollection, ScrollIntoViewAlignment.Leading);
        }
        public void CreateGroupReturnsCorrectGroup()
        {
            // Arrange
            var paymentList = new List <PaymentViewModel>
            {
                new PaymentViewModel {
                    Id = 1, Date = DateTime.Now
                },
                new PaymentViewModel {
                    Id = 2, Date = DateTime.Now.AddMonths(-1)
                }
            };

            // Act
            List <DateListGroupCollection <PaymentViewModel> > createdGroup
                = DateListGroupCollection <PaymentViewModel> .CreateGroups(paymentList,
                                                                           s => s.Date.ToString("D", CultureInfo.CurrentCulture),
                                                                           s => s.Date);

            // Assert
            createdGroup.Should().HaveCount(2);
            createdGroup[0][0].Id.Should().Be(1);
            createdGroup[1][0].Id.Should().Be(2);
        }