public void ReplacesTheWholeCollection()
            {
                var        collection = new GroupedOrderedCollection <int>(i => i, i => i, i => i.ToString().Length);
                List <int> list       = new List <int> {
                    40, 70, 8, 3, 1, 2
                };

                collection.ReplaceWith(list);

                List <int> newList = new List <int> {
                    300, 100, 10
                };

                collection.ReplaceWith(newList);

                List <List <int> > expected = new List <List <int> >
                {
                    new List <int> {
                        10
                    },
                    new List <int> {
                        100, 300
                    }
                };

                CollectionAssert.AreEqual(collection, expected);
            }
            public void ReturnsNullIfEmpty()
            {
                var emptyCollection = new GroupedOrderedCollection <MockItem>(d => d.Id, d => d.Start.TimeOfDay, d => d.Start.Date, isDescending: true);
                var index           = emptyCollection.IndexOf(itemId: 0);

                index.Should().BeNull();
            }
            public void GetsTheTotalNumberOfItems()
            {
                var        intCollection = new GroupedOrderedCollection <int>(i => i, i => i, i => i.ToString().Length);
                List <int> list          = new List <int> {
                    40, 70, 8, 3, 1, 2
                };

                intCollection.ReplaceWith(list);

                intCollection.TotalCount.Should().Be(6);
                intCollection.Count.Should().Be(2);
            }
            public void SetsTheCorrectDescendingOrderForInitialItems()
            {
                var        collection = new GroupedOrderedCollection <int>(i => i, i => i, i => i.ToString().Length, isDescending: true);
                List <int> list       = new List <int> {
                    4, 7, 8, 3, 1, 2
                };

                collection.ReplaceWith(list);

                List <List <int> > expected = new List <List <int> >
                {
                    new List <int> {
                        8, 7, 4, 3, 2, 1
                    }
                };

                CollectionAssert.AreEqual(collection, expected);
            }
            public void InsertsElementInCorrectOrderWhenDescending()
            {
                List <int> list = new List <int> {
                    40, 70, 8, 3, 1, 2
                };
                var collection = new GroupedOrderedCollection <int>(i => i, i => i, i => i.ToString().Length, true);

                collection.ReplaceWith(list);

                collection.InsertItem(4);

                List <List <int> > expected = new List <List <int> >
                {
                    new List <int> {
                        70, 40
                    },
                    new List <int> {
                        8, 4, 3, 2, 1
                    },
                };

                CollectionAssert.AreEqual(collection, expected);
            }
            public TheIndexOfWithIdMethod()
            {
                mockCollection = new GroupedOrderedCollection <MockItem>(d => d.Id, d => d.Start.TimeOfDay, d => d.Start.Date, isDescending: true);
                List <MockItem> list = new List <MockItem>
                {
                    new MockItem {
                        Id = 0, Start = referenceDate.AddHours(3)
                    },
                    new MockItem {
                        Id = 1, Start = referenceDate.AddHours(1)
                    },
                    new MockItem {
                        Id = 2, Start = referenceDate.AddHours(-10)
                    },
                    new MockItem {
                        Id = 3, Start = referenceDate.AddDays(5)
                    },
                    new MockItem {
                        Id = 4, Start = referenceDate.AddDays(5).AddHours(2)
                    }
                };

                mockCollection.ReplaceWith(list);
            }
 public TheUpdateItemMethod()
 {
     intCollection = new GroupedOrderedCollection <int>(i => i, i => i, i => i.ToString().Length);
 }
 public TheConstructor()
 {
     intCollection  = new GroupedOrderedCollection <int>(i => i, i => i, i => i.ToString().Length);
     mockCollection = new GroupedOrderedCollection <MockItem>(d => d.Id, d => d.Start.TimeOfDay, d => d.Start.Date, isDescending: true);
 }
 public TheIndexOfMethod()
 {
     intCollection = new GroupedOrderedCollection <int>(i => i, i => i, i => i.ToString().Length);
 }