public void WhereSelectOrderByTransaction_RemoveCausingChange_Update() // Works without Transaction { ExecutionEngine.Current = new SequentialExecutionEngine(); var update = false; var dummy1 = new ObservableDummy <int>(1); var dummy2 = new Dummy <int>(3); var dummy3 = new Dummy <int>(5); var coll = new NotifyCollection <Dummy <int> >() { dummy1, dummy2, dummy3 }; var test = coll.Where(d => d.Item > 0).Select(d => new Dummy <int>(d.Item * 2)).OrderBy(d => d.Item); test.CollectionChanged += (o, e) => update = true; ((IEnumerable <Dummy <int> >)test).Select(d => d.Item).AssertSequence(dummy1.Item * 2, dummy2.Item * 2, dummy3.Item * 2); Assert.AreEqual(3, test.Sequences.Count()); Assert.IsFalse(update); ExecutionEngine.Current.BeginTransaction(); dummy1.Item = 0; Assert.IsFalse(update); ExecutionEngine.Current.CommitTransaction(); // Calling Select directly on test leads to quadrupling of the entries in test ((IEnumerable <Dummy <int> >)test).Select(d => d.Item).AssertSequence(dummy2.Item * 2, dummy3.Item * 2); Assert.AreEqual(2, test.Sequences.Count()); Assert.IsTrue(update); }
public void WhereOrderByTransaction_ChangeRemove_Update() // Works without Transaction { ExecutionEngine.Current = new SequentialExecutionEngine(); var update = false; var dummy1 = new ObservableDummy <int>(1); var dummy2 = new Dummy <int>(3); var dummy3 = new Dummy <int>(5); var coll = new NotifyCollection <Dummy <int> >() { dummy1, dummy2, dummy3 }; var test = coll.Where(d => d.Item > 0).OrderBy(d => d.Item); test.CollectionChanged += (o, e) => update = true; test.AssertSequence(dummy1, dummy2, dummy3); Assert.AreEqual(3, test.Sequences.Count()); Assert.IsFalse(update); ExecutionEngine.Current.BeginTransaction(); dummy1.Item = 0; Assert.IsFalse(update); ExecutionEngine.Current.CommitTransaction(); test.AssertSequence(dummy2, dummy3); Assert.AreEqual(2, test.Sequences.Count()); Assert.IsTrue(update); }
public void WhereTransaction_ObservableItem_Updates() { var oldEngine = ExecutionEngine.Current; try { ExecutionEngine.Current = new SequentialExecutionEngine(); var update = false; var dummy1 = new ObservableDummy <bool>(true); INotifyCollection <Dummy <bool> > coll = new NotifyCollection <Dummy <bool> >() { dummy1 }; var test = coll.Where(d => d.Item); test.CollectionChanged += (o, e) => { update = true; Assert.AreEqual(dummy1, e.OldItems[0]); }; Assert.IsTrue(Sys.Contains(test, dummy1)); Assert.IsFalse(update); ExecutionEngine.Current.BeginTransaction(); dummy1.Item = false; Assert.IsFalse(update); ExecutionEngine.Current.CommitTransaction(); Assert.IsFalse(test.Any()); Assert.IsTrue(update); } finally { ExecutionEngine.Current = oldEngine; } }
public void Transformations_Relational_Where_Exception1() { var result = source.Where(null); }