Ejemplo n.º 1
0
        public void IndicatesUndoPossible()
        {
            var manager = new UndoManager(5);
            manager.SaveState(new ProjectState(""));
            Assert.False(manager.CanUndo());

            manager.SaveState(new ProjectState(""));
            Assert.True(manager.CanUndo());

            manager.Undo();
            Assert.False(manager.CanUndo());
        }
Ejemplo n.º 2
0
        public void LimitsHistoryCount()
        {
            const uint size = 5u;
            var manager = new UndoManager(size);

            for (int i = 0; i < size * 2; i++)
                manager.SaveState(new ProjectState(""));

            uint counter = 0;
            while (manager.Undo() != null)
                counter++;

            Assert.Equal(size, counter);
        }
Ejemplo n.º 3
0
        public void Redoes()
        {
            var steps = new[] { "b", "c" }.Select(s => new ProjectState(s)).ToList();

            var manager = new UndoManager(5);

            manager.SaveState(new ProjectState("a"));

            foreach (ProjectState step in steps)
                manager.SaveState(step);

            for (int i = 0; i < 2; i++)
                manager.Undo();

            var result = new List<ProjectState>();
            for (int i = 0; i < 2; i++)
                result.Add(manager.Redo());

            Assert.Equal(steps, result);
        }
Ejemplo n.º 4
0
        public void ReturnsNullWhenOutOfItems()
        {
            var manager = new UndoManager(3);
            manager.SaveState(new ProjectState(""));

            manager.Undo();
            Assert.Null(manager.Undo());

            manager.Redo();
            Assert.Null(manager.Redo());
        }
Ejemplo n.º 5
0
 public void WorksWithZeroCapacity()
 {
     var manager = new UndoManager(0);
     manager.SaveState(new ProjectState(""));
     Assert.Null(manager.Undo());
     Assert.Null(manager.Redo());
 }