コード例 #1
0
ファイル: OrderByTest.cs プロジェクト: walcher/NMF
        public void OrderByTransaction_ChangeReplace_Update()
        {
            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 newDummy = new Dummy <int>(2);

            var test = coll.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;
            coll[0]     = newDummy;
            Assert.IsFalse(update);

            ExecutionEngine.Current.CommitTransaction();

            test.AssertSequence(newDummy, dummy2, dummy3);
            Assert.AreEqual(3, test.Sequences.Count());
            Assert.IsTrue(update);
        }