public void AutoGroupTest() { var cw = new DependencyCollectionView(); CreateGroups(cw); Enumerable.Range(0, 100) .ToList() .ForEach(i => cw.Add(i)); Assert.AreEqual(cw.CollectionGroups.Count, 5); foreach (ICollectionViewGroup item in cw.CollectionGroups) { Assert.AreEqual(20, item.GroupItems.Count); } cw.Remove(13); Assert.AreEqual( 19, cw .CollectionGroups .OfType<SelfServiceDependencyCollectionViewGroupBase>() .Where(g => (int)g.Group == 3) .Select(g => g.GroupItems.Count).First()); Assert.AreEqual( 99, cw.Count); var incFac = new DependencyCollectionViewDelegateIncrementalLoader( (v, inc) => true, async (v, inc, c) => { Enumerable.Range((int)v[v.Count - 1] + 1, c) .ToList().ForEach(val => v.Add(val)); await Task.Yield(); return new LoadMoreItemsResult { Count = (uint)c }; } ); cw.IncrementalLoader = incFac; var t= cw.LoadMoreItemsAsync(10); Assert.AreEqual( 109, cw.Count); Assert.AreEqual( 21, cw .CollectionGroups .OfType<SelfServiceDependencyCollectionViewGroupBase>() .Where(g => (int)g.Group == 3) .Select(g => g.GroupItems.Count).First()); }
public void AddRemoveTest() { var cw = new DependencyCollectionView(); cw.Add("a"); cw.Add("b"); cw.Remove("b"); Assert.AreEqual(cw.Count, 1); }
public void AutoGroupTest() { var cw = new DependencyCollectionView(); CreateGroups(cw); Enumerable.Range(0, 100) .ToList() .ForEach(i => cw.Add(i)); Assert.AreEqual(cw.CollectionGroups.Count, 5); foreach (ICollectionViewGroup item in cw.CollectionGroups) { Assert.AreEqual(20, item.GroupItems.Count); } cw.Remove(13); Assert.AreEqual( 19, cw .CollectionGroups .OfType <SelfServiceDependencyCollectionViewGroupBase>() .Where(g => (int)g.Group == 3) .Select(g => g.GroupItems.Count).First()); Assert.AreEqual( 99, cw.Count); var incFac = new DependencyCollectionViewDelegateIncrementalLoader( (v, inc) => true, async(v, inc, c) => { Enumerable.Range((int)v[v.Count - 1] + 1, c) .ToList().ForEach(val => v.Add(val)); await Task.Yield(); return(new LoadMoreItemsResult { Count = (uint)c }); } ); cw.IncrementalLoader = incFac; var t = cw.LoadMoreItemsAsync(10); Assert.AreEqual( 109, cw.Count); Assert.AreEqual( 21, cw .CollectionGroups .OfType <SelfServiceDependencyCollectionViewGroupBase>() .Where(g => (int)g.Group == 3) .Select(g => g.GroupItems.Count).First()); }