예제 #1
0
        public void Do_Should_override_oldest_operation_When_max_capacity()
        {
            IUnDoManager manager = new UnDoManager(2);

            IUnDo operation1 = Substitute.For <IUnDo>();
            IUnDo operation2 = Substitute.For <IUnDo>();
            IUnDo operation3 = Substitute.For <IUnDo>();

            operation1.Description.Returns("un");
            operation2.Description.Returns("dos");
            operation3.Description.Returns("tres");

            manager.Do(operation1);
            manager.Do(operation2);
            manager.Do(operation3);

            Check.That(manager.UndoDescriptions).ContainsExactly("tres", "dos");

            manager.Undo();
            manager.Undo();

            Check.That(manager.RedoDescriptions).ContainsExactly("dos", "tres");

            manager.Redo();
            manager.Redo();

            Check.That(manager.UndoDescriptions).ContainsExactly("tres", "dos");
        }
예제 #2
0
        public void DoAdd_ICollection_Should_keep_index_When_source_is_IList()
        {
            IUnDoManager      manager = new UnDoManager();
            ICollection <int> source  = new List <int> {
                0, 1
            };

            manager.DoAdd(source, 2);

            source.Add(3);

            manager.Undo();

            Check.That(source).ContainsExactly(0, 1, 3);

            manager.Redo();

            Check.That(source).ContainsExactly(0, 1, 2, 3);
        }