Example #1
0
 public void Test()
 {
     Assert.AreEqual(0, notifyCollectionChangedActions.Count);
     target.Add(100);
     Assert.AreEqual(1, notifyCollectionChangedActions.Count);
     target.RemoveAt(0);
     Assert.AreEqual(2, notifyCollectionChangedActions.Count);
     Assert.IsTrue(target.Undo());
     Assert.AreEqual(3, notifyCollectionChangedActions.Count);
     Assert.IsTrue(target.Undo());
     Assert.AreEqual(4, notifyCollectionChangedActions.Count);
     Assert.IsFalse(target.Undo());
     Assert.AreEqual(4, notifyCollectionChangedActions.Count);
     Assert.IsTrue(target.Redo());
     Assert.AreEqual(5, notifyCollectionChangedActions.Count);
     Assert.IsTrue(target.Redo());
     Assert.AreEqual(6, notifyCollectionChangedActions.Count);
     Assert.IsFalse(target.Redo());
     Assert.AreEqual(6, notifyCollectionChangedActions.Count);
 }
Example #2
0
        public void UndoRedoObservableCollectionTest()
        {
            // ObservableCollection which support undo/redo.
            var target = new UndoRedoObservableCollection <int>();

            target.CollectionChanged += ObservableCollection_CollectionChanged;

            target.Add(100);

            // You can undo/redo also.
            Assert.IsTrue(target.CanUndo);
            Assert.IsFalse(target.CanRedo);

            Assert.IsTrue(target.Undo());
            Assert.IsTrue(target.Redo());