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 ReturnsCorrectIndex() { List <int> list = new List <int> { 40, 70, 8, 3, 1, 2 }; intCollection.ReplaceWith(list); var index = intCollection.IndexOf(70); var expected = new SectionedIndex(1, 1); index.Should().Be(expected); }
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 InsertsElementInCorrectOrder() { List <int> list = new List <int> { 40, 70, 8, 3, 1, 2 }; intCollection.ReplaceWith(list); intCollection.InsertItem(4); List <List <int> > expected = new List <List <int> > { new List <int> { 1, 2, 3, 4, 8 }, new List <int> { 40, 70 } }; CollectionAssert.AreEqual(intCollection, expected); }
public void SetsTheCorrectOrderForInitialItems() { int[] array = { 4, 7, 8, 3, 1, 2 }; intCollection.ReplaceWith(array); List <List <int> > expected = new List <List <int> > { new List <int> { 1, 2, 3, 4, 7, 8 } }; CollectionAssert.AreEqual(intCollection, expected); }
public void SetsTheCorrectOrderForInitialItemsWithDates() { List <MockItem> list = new List <MockItem> { new MockItem { Id = 0, Start = referenceDate.AddHours(3) }, new MockItem { Id = 1, Start = referenceDate.AddHours(-10) }, new MockItem { Id = 2, Start = referenceDate.AddHours(1) } }; mockCollection.ReplaceWith(list); List <List <MockItem> > expected = new List <List <MockItem> > { new List <MockItem> { new MockItem { Id = 0, Start = referenceDate.AddHours(3) }, new MockItem { Id = 2, Start = referenceDate.AddHours(1) }, new MockItem { Id = 1, Start = referenceDate.AddHours(-10) } } }; CollectionAssert.AreEqual(mockCollection, expected); }
public void ThrowsIfIndexOutOfRange() { List <int> list = new List <int> { 40, 70, 8, 3, 1, 2 }; intCollection.ReplaceWith(list); Action removeItemAt = () => intCollection.RemoveItemAt(1, 4); removeItemAt.Should().Throw <ArgumentOutOfRangeException>(); }
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); }