public void ThenBy_NoObservableSequenceItemRemoved_NoUpdate() { var update = false; var coll = new OrderableList <int>(); coll.Sequences.Add(new List <int>() { 6, 4, 5 }); var list = new List <int>() { 3, 1, 2 }; coll.Sequences.Add(list); var test = coll.ThenBy(i => i); test.CollectionChanged += (o, e) => update = true; test.AssertSequence(4, 5, 6, 1, 2, 3); Assert.IsFalse(update); Assert.AreEqual(6, test.Sequences.Count()); list.Remove(2); Assert.IsFalse(update); }
public void ThenBy_SequenceAdded_Update() { var update = false; var coll = new OrderableList <int>(); coll.Sequences.Add(new List <int>() { 3, 1, 2 }); var test = coll.ThenBy(i => i); test.CollectionChanged += (o, e) => { update = true; Assert.IsTrue(e.NewItems.Contains(4)); Assert.IsTrue(e.NewItems.Contains(5)); Assert.IsTrue(e.NewItems.Contains(6)); Assert.AreEqual(3, e.NewItems.Count); Assert.IsNull(e.OldItems); }; test.AssertSequence(1, 2, 3); Assert.IsFalse(update); coll.Sequences.Add(new List <int>() { 6, 4, 5 }); Assert.IsTrue(update); test.AssertSequence(1, 2, 3, 4, 5, 6); }
public void ThenBy_NoObservableItemSelectorChanges_NoUpdate() { var update = false; var coll = new OrderableList <Dummy <int> >(); var dummy = new Dummy <int> [6]; for (int i = 0; i < 6; i++) { dummy[i] = new Dummy <int>(i); } coll.Sequences.Add(new List <Dummy <int> >() { dummy[3], dummy[4], dummy[5] }); coll.Sequences.Add(new List <Dummy <int> >() { dummy[0], dummy[1], dummy[2] }); var test = coll.ThenBy(d => d.Item); test.CollectionChanged += (o, e) => { update = true; }; test.AssertSequence(dummy[3], dummy[4], dummy[5], dummy[0], dummy[1], dummy[2]); Assert.IsFalse(update); dummy[0].Item = 3; Assert.IsFalse(update); }
public void ThenBy_ObservableSequenceDoubleRemoved_Update() { var update = false; var updateSequences = false; var update1Sequence = false; var coll = new OrderableList <int>(); coll.Sequences.Add(new List <int>() { 6, 4, 5 }); var list = new ObservableCollection <int>() { 3, 1, 1, 2 }; coll.Sequences.Add(list); var test = coll.ThenBy(i => i); test.CollectionChanged += (o, e) => { Assert.AreEqual(1, e.OldItems[0]); Assert.IsNull(e.NewItems); update = true; }; test.Sequences.CollectionChanged += (o, e) => updateSequences = true; test.AssertSequence(4, 5, 6, 1, 1, 2, 3); Assert.IsFalse(update); Assert.IsFalse(updateSequences); Assert.AreEqual(6, test.Sequences.Count()); var sequenceFor1 = test.Sequences.FirstOrDefault(s => s.Contains(1)) as INotifyCollectionChanged; sequenceFor1.CollectionChanged += (o, e) => { update1Sequence = true; Assert.AreEqual(1, e.OldItems[0]); Assert.IsNull(e.NewItems); }; list.Remove(1); Assert.IsTrue(update); Assert.IsFalse(updateSequences); Assert.IsTrue(update1Sequence); test.AssertSequence(4, 5, 6, 1, 2, 3); Assert.AreEqual(6, test.Sequences.Count()); }
public void ThenBy_ObservableSequenceNewItemAdded_Update() { var update = false; var updateSequences = false; var coll = new OrderableList <int>(); coll.Sequences.Add(new List <int>() { 6, 4, 5 }); var list = new ObservableCollection <int>() { 3, 1, 2 }; coll.Sequences.Add(list); var test = coll.ThenBy(i => i); test.CollectionChanged += (o, e) => { Assert.AreEqual(0, e.NewItems[0]); Assert.IsNull(e.OldItems); update = true; }; test.Sequences.CollectionChanged += (o, e) => { Assert.IsInstanceOfType(e.NewItems[0], typeof(IEnumerable <int>)); Assert.IsNull(e.OldItems); updateSequences = true; }; test.AssertSequence(4, 5, 6, 1, 2, 3); Assert.IsFalse(update); Assert.IsFalse(updateSequences); Assert.AreEqual(6, test.Sequences.Count()); list.Add(0); Assert.IsTrue(update); Assert.IsTrue(updateSequences); test.AssertSequence(4, 5, 6, 0, 1, 2, 3); Assert.AreEqual(7, test.Sequences.Count()); foreach (var sequence in test.Sequences) { Assert.AreEqual(1, sequence.Count()); } }
public void ThenBy_NoObservableSequenceItemAdded_NoUpdate() { var update = false; var coll = new OrderableList<int>(); coll.Sequences.Add(new List<int>() { 6, 4, 5 }); var list = new List<int>() { 3, 1, 2 }; coll.Sequences.Add(list); var test = coll.ThenBy(i => i); test.CollectionChanged += (o, e) => update = true; test.AssertSequence(4, 5, 6, 1, 2, 3); Assert.IsFalse(update); Assert.AreEqual(6, test.Sequences.Count()); list.Add(0); Assert.IsFalse(update); }
public void ThenBy_ObservableSequenceNewItemAdded_Update() { var update = false; var updateSequences = false; var coll = new OrderableList<int>(); coll.Sequences.Add(new List<int>() { 6, 4, 5 }); var list = new ObservableCollection<int>() { 3, 1, 2 }; coll.Sequences.Add(list); var test = coll.ThenBy(i => i); test.CollectionChanged += (o, e) => { Assert.AreEqual(0, e.NewItems[0]); Assert.IsNull(e.OldItems); update = true; }; test.Sequences.CollectionChanged += (o, e) => { Assert.IsInstanceOfType(e.NewItems[0], typeof(IEnumerable<int>)); Assert.IsNull(e.OldItems); updateSequences = true; }; test.AssertSequence(4, 5, 6, 1, 2, 3); Assert.IsFalse(update); Assert.IsFalse(updateSequences); Assert.AreEqual(6, test.Sequences.Count()); list.Add(0); Assert.IsTrue(update); Assert.IsTrue(updateSequences); test.AssertSequence(4, 5, 6, 0, 1, 2, 3); Assert.AreEqual(7, test.Sequences.Count()); foreach (var sequence in test.Sequences) { Assert.AreEqual(1, sequence.Count()); } }
public void ThenBy_SequenceReset_Update() { var update = false; var coll = new OrderableList <int>(); coll.Sequences.Add(new List <int>() { 3, 1, 2 }); var test = coll.ThenBy(i => i); test.CollectionChanged += (o, e) => { Assert.AreEqual(NotifyCollectionChangedAction.Reset, e.Action); update = true; }; coll.Sequences.Clear(); Assert.IsTrue(update); }
public void ThenBy_SequenceAdded_NoUpdateWhenDetached() { var update = false; var coll = new OrderableList <int>(); coll.Sequences.Add(new List <int>() { 3, 1, 2 }); var test = coll.ThenBy(i => i); test.CollectionChanged += (o, e) => update = true; test.AssertSequence(1, 2, 3); Assert.IsFalse(update); test.Detach(); update = false; coll.Sequences.Add(new List <int>() { 6, 4, 5 }); Assert.IsFalse(update); test.Attach(); Assert.IsTrue(update); test.AssertSequence(1, 2, 3, 4, 5, 6); update = false; coll.Sequences.Remove(coll.Sequences[1]); Assert.IsTrue(update); }
public void ThenBy_ObservableSequenceExistingItemAdded_Update() { var update = false; var coll = new OrderableList <int>(); coll.Sequences.Add(new List <int>() { 6, 4, 5 }); var list = new ObservableCollection <int>() { 3, 1, 2 }; coll.Sequences.Add(list); var test = coll.ThenBy(i => i); test.CollectionChanged += (o, e) => { Assert.AreEqual(NotifyCollectionChangedAction.Add, e.Action); Assert.AreEqual(1, e.NewItems[0]); Assert.IsNull(e.OldItems); update = true; }; test.AssertSequence(4, 5, 6, 1, 2, 3); Assert.IsFalse(update); Assert.AreEqual(6, test.Sequences.Count()); list.Add(1); Assert.IsTrue(update); test.AssertSequence(4, 5, 6, 1, 1, 2, 3); Assert.AreEqual(6, test.Sequences.Count()); }
public void ThenBy_SequenceReset_Update() { var update = false; var coll = new OrderableList<int>(); coll.Sequences.Add(new List<int>() { 3, 1, 2 }); var test = coll.ThenBy(i => i); test.CollectionChanged += (o, e) => { Assert.AreEqual(NotifyCollectionChangedAction.Reset, e.Action); update = true; }; coll.Sequences.Clear(); Assert.IsTrue(update); }
public void ThenBy_SequenceRemoved_Update() { var update = false; var coll = new OrderableList<int>(); coll.Sequences.Add(new List<int>() { 3, 1, 2 }); var list = new List<int>() { 4, 5, 6 }; coll.Sequences.Add(list); var test = coll.ThenBy(i => i); test.CollectionChanged += (o, e) => { update = true; Assert.IsTrue(e.OldItems.Contains(4)); Assert.IsTrue(e.OldItems.Contains(5)); Assert.IsTrue(e.OldItems.Contains(6)); Assert.AreEqual(3, e.OldItems.Count); Assert.IsNull(e.NewItems); }; test.AssertSequence(1, 2, 3, 4, 5, 6); Assert.IsFalse(update); coll.Sequences.Remove(list); Assert.IsTrue(update); test.AssertSequence(1, 2, 3); }
public void ThenBy_SequenceAdded_NoUpdateWhenDetached() { var update = false; var coll = new OrderableList<int>(); coll.Sequences.Add(new List<int>() { 3, 1, 2 }); var test = coll.ThenBy(i => i); test.CollectionChanged += (o, e) => update = true; test.AssertSequence(1, 2, 3); Assert.IsFalse(update); test.Detach(); update = false; coll.Sequences.Add(new List<int>() { 6, 4, 5 }); Assert.IsFalse(update); test.Attach(); Assert.IsTrue(update); test.AssertSequence(1, 2, 3, 4, 5, 6); update = false; coll.Sequences.Remove(coll.Sequences[1]); Assert.IsTrue(update); }
public void ThenBy_ObservableItemSelectorChanges_NoUpdateWhenDetached() { var update = false; var coll = new OrderableList<Dummy<int>>(); var dummy = new Dummy<int>[6]; for (int i = 0; i < 6; i++) { dummy[i] = new ObservableDummy<int>(i); } coll.Sequences.Add(new List<Dummy<int>>() { dummy[3], dummy[4], dummy[5] }); coll.Sequences.Add(new List<Dummy<int>>() { dummy[0], dummy[1], dummy[2] }); var test = coll.ThenBy(d => d.Item); test.CollectionChanged += (o, e) => { update = true; }; test.AssertSequence(dummy[3], dummy[4], dummy[5], dummy[0], dummy[1], dummy[2]); Assert.IsFalse(update); test.Detach(); update = false; dummy[0].Item = 3; Assert.IsFalse(update); test.Attach(); Assert.IsTrue(update); test.AssertSequence(dummy[3], dummy[4], dummy[5], dummy[1], dummy[2], dummy[0]); update = false; dummy[0].Item = 0; Assert.IsTrue(update); }
public void ThenBy_ObservableSequenceDoubleRemoved_Update() { var update = false; var updateSequences = false; var update1Sequence = false; var coll = new OrderableList<int>(); coll.Sequences.Add(new List<int>() { 6, 4, 5 }); var list = new ObservableCollection<int>() { 3, 1, 1, 2 }; coll.Sequences.Add(list); var test = coll.ThenBy(i => i); test.CollectionChanged += (o, e) => { Assert.AreEqual(1, e.OldItems[0]); Assert.IsNull(e.NewItems); update = true; }; test.Sequences.CollectionChanged += (o, e) => updateSequences = true; test.AssertSequence(4, 5, 6, 1, 1, 2, 3); Assert.IsFalse(update); Assert.IsFalse(updateSequences); Assert.AreEqual(6, test.Sequences.Count()); var sequenceFor1 = test.Sequences.FirstOrDefault(s => s.Contains(1)) as INotifyCollectionChanged; sequenceFor1.CollectionChanged += (o, e) => { update1Sequence = true; Assert.AreEqual(1, e.OldItems[0]); Assert.IsNull(e.NewItems); }; list.Remove(1); Assert.IsTrue(update); Assert.IsFalse(updateSequences); Assert.IsTrue(update1Sequence); test.AssertSequence(4, 5, 6, 1, 2, 3); Assert.AreEqual(6, test.Sequences.Count()); }